asciidoctor 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of asciidoctor might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/LICENSE +2 -2
- data/README.adoc +461 -0
- data/asciidoctor.gemspec +27 -16
- data/compat/asciidoc.conf +139 -0
- data/lib/asciidoctor.rb +212 -69
- data/lib/asciidoctor/abstract_block.rb +41 -0
- data/lib/asciidoctor/abstract_node.rb +128 -81
- data/lib/asciidoctor/attribute_list.rb +5 -2
- data/lib/asciidoctor/backends/base_template.rb +16 -4
- data/lib/asciidoctor/backends/docbook45.rb +112 -42
- data/lib/asciidoctor/backends/html5.rb +206 -90
- data/lib/asciidoctor/block.rb +5 -5
- data/lib/asciidoctor/cli/invoker.rb +38 -34
- data/lib/asciidoctor/cli/options.rb +3 -3
- data/lib/asciidoctor/document.rb +115 -13
- data/lib/asciidoctor/helpers.rb +16 -0
- data/lib/asciidoctor/lexer.rb +486 -359
- data/lib/asciidoctor/path_resolver.rb +360 -0
- data/lib/asciidoctor/reader.rb +122 -23
- data/lib/asciidoctor/renderer.rb +1 -33
- data/lib/asciidoctor/section.rb +1 -1
- data/lib/asciidoctor/substituters.rb +103 -19
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +6 -6
- data/man/asciidoctor.ad +5 -3
- data/stylesheets/asciidoctor.css +274 -0
- data/test/attributes_test.rb +133 -10
- data/test/blocks_test.rb +302 -17
- data/test/document_test.rb +269 -6
- data/test/fixtures/basic-docinfo.html +1 -0
- data/test/fixtures/basic-docinfo.xml +4 -0
- data/test/fixtures/basic.asciidoc +4 -0
- data/test/fixtures/docinfo.html +1 -0
- data/test/fixtures/docinfo.xml +2 -0
- data/test/fixtures/include-file.asciidoc +22 -1
- data/test/fixtures/stylesheets/custom.css +3 -0
- data/test/invoker_test.rb +38 -6
- data/test/lexer_test.rb +64 -21
- data/test/links_test.rb +4 -0
- data/test/lists_test.rb +251 -12
- data/test/paragraphs_test.rb +225 -30
- data/test/paths_test.rb +174 -0
- data/test/reader_test.rb +89 -2
- data/test/sections_test.rb +518 -16
- data/test/substitutions_test.rb +121 -10
- data/test/tables_test.rb +53 -13
- data/test/test_helper.rb +2 -2
- data/test/text_test.rb +5 -5
- metadata +46 -50
- data/README.asciidoc +0 -296
- data/lib/asciidoctor/errors.rb +0 -5
@@ -59,41 +59,48 @@ class DocumentTemplate < BaseTemplate
|
|
59
59
|
def template
|
60
60
|
@template ||= @eruby.new <<-EOS
|
61
61
|
<%#encoding:UTF-8%><!DOCTYPE html>
|
62
|
-
<html lang="<%= attr :lang, 'en' %>"
|
62
|
+
<html<% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>>
|
63
63
|
<head>
|
64
64
|
<meta http-equiv="Content-Type" content="text/html; charset=<%= attr :encoding %>">
|
65
65
|
<meta name="generator" content="Asciidoctor <%= attr 'asciidoctor-version' %>">
|
66
|
-
|
67
|
-
<% if attr? :
|
66
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
67
|
+
<% if attr? :description %>
|
68
|
+
<meta name="description" content="<%= attr :description %>">
|
69
|
+
<% end %>
|
70
|
+
<% if attr? :keywords %>
|
71
|
+
<meta name="keywords" content="<%= attr :keywords %>">
|
72
|
+
<% end %>
|
68
73
|
<title><%= doctitle %></title>
|
69
|
-
<% if attr
|
74
|
+
<% if DEFAULT_STYLESHEET_KEYS.include?(attr 'stylesheet') %>
|
75
|
+
<% if @safe >= SafeMode::SECURE || (attr? 'linkcss') %>
|
76
|
+
<link rel="stylesheet" href="<%= normalize_web_path(DEFAULT_STYLESHEET_NAME, (attr :stylesdir, '')) %>">
|
77
|
+
<% else %>
|
78
|
+
<style>
|
79
|
+
<%= read_asset DEFAULT_STYLESHEET_PATH %>
|
80
|
+
</style>
|
81
|
+
<% end %>
|
82
|
+
<% elsif attr? :stylesheet %>
|
83
|
+
<% if attr? 'linkcss' %>
|
84
|
+
<link rel="stylesheet" href="<%= normalize_web_path((attr :stylesheet), attr(:stylesdir, '')) %>">
|
85
|
+
<% else %>
|
70
86
|
<style>
|
71
|
-
|
72
|
-
#toc ol { list-style-type: none; }
|
87
|
+
<%= read_asset normalize_system_path(attr(:stylesheet), attr(:stylesdir, '')), true %>
|
73
88
|
</style>
|
74
89
|
<% end %>
|
75
|
-
<% unless attr(:stylesheet, '').empty? %>
|
76
|
-
<link rel="stylesheet" href="<%= (attr? :stylesdir) ? File.join((attr :stylesdir), (attr :stylesheet)) : (attr :stylesheet) %>">
|
77
90
|
<% end %>
|
78
|
-
<%
|
79
|
-
case attr 'source-highlighter' %><%
|
91
|
+
<% case attr 'source-highlighter' %><%
|
80
92
|
when 'coderay' %>
|
93
|
+
<% if (attr 'coderay-css', 'class') == 'class' %>
|
81
94
|
<style>
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
pre.highlight .line-numbers { background-color: #D5F6F6; color: gray; }
|
86
|
-
pre.highlight .line-numbers pre { color: gray; }
|
87
|
-
<% if (attr 'coderay-css', 'class') == 'class' %><%= template.class.default_coderay_stylesheet %><% end %>
|
88
|
-
</style><%
|
95
|
+
<%= template.class.default_coderay_stylesheet %>
|
96
|
+
</style>
|
97
|
+
<% end %><%
|
89
98
|
when 'highlightjs' %>
|
90
99
|
<link rel="stylesheet" href="<%= (attr :highlightjsdir, 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/7.3') %>/styles/<%= (attr 'highlightjs-theme', 'default') %>.min.css">
|
91
|
-
<style>
|
92
|
-
pre code { background-color: #F8F8F8; padding: 0; }
|
93
|
-
</style>
|
94
100
|
<script src="<%= (attr :highlightjsdir, 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/7.3') %>/highlight.min.js"></script>
|
95
101
|
<script>hljs.initHighlightingOnLoad()</script>
|
96
102
|
<% end %>
|
103
|
+
<%= docinfo %>
|
97
104
|
</head>
|
98
105
|
<body#{id} class="<%= doctype %>"<% if attr? 'max-width' %> style="max-width: <%= attr 'max-width' %>;"<% end %>>
|
99
106
|
<% unless noheader %>
|
@@ -102,14 +109,14 @@ pre code { background-color: #F8F8F8; padding: 0; }
|
|
102
109
|
<% unless notitle %>
|
103
110
|
<h1><%= @header.title %></h1>
|
104
111
|
<% end %>
|
105
|
-
<% if attr? :author %><span id="author"><%= attr :author %></span><br
|
106
|
-
<% if attr? :email %><span id="email"
|
112
|
+
<% if attr? :author %><span id="author"><%= attr :author %></span><br>
|
113
|
+
<% if attr? :email %><span id="email"><%= sub_macros(attr :email) %></span><br><% end %><% end %>
|
107
114
|
<% if attr? :revnumber %><span id="revnumber">version <%= attr :revnumber %><%= attr?(:revdate) ? ',' : '' %></span><% end %>
|
108
115
|
<% if attr? :revdate %><span id="revdate"><%= attr :revdate %></span><% end %>
|
109
116
|
<% if attr? :revremark %><br><span id="revremark"><%= attr :revremark %></span><% end %>
|
110
117
|
<% end %>
|
111
|
-
<% if attr? :toc %>
|
112
|
-
<div id="toc">
|
118
|
+
<% if (attr? :toc) && (attr? 'toc-placement', 'auto') %>
|
119
|
+
<div id="toc" class="<%= attr 'toc-class', 'toc' %>">
|
113
120
|
<div id="toctitle"><%= attr 'toc-title' %></div>
|
114
121
|
<%= template.class.outline(self, (attr :toclevels, 2).to_i) %>
|
115
122
|
</div>
|
@@ -119,8 +126,7 @@ pre code { background-color: #F8F8F8; padding: 0; }
|
|
119
126
|
<div id="content">
|
120
127
|
<%= content %>
|
121
128
|
</div>
|
122
|
-
<%
|
123
|
-
<div id="footnotes">
|
129
|
+
<% unless !footnotes? || attr?(:nofootnotes) %><div id="footnotes">
|
124
130
|
<hr>
|
125
131
|
<% footnotes.each do |fn| %>
|
126
132
|
<div class="footnote" id="_footnote_<%= fn.index %>">
|
@@ -146,10 +152,49 @@ class EmbeddedTemplate < BaseTemplate
|
|
146
152
|
@template ||= @eruby.new <<-EOS
|
147
153
|
<%#encoding:UTF-8%><% unless notitle || !has_header? %><h1#{id}><%= header.title %></h1>
|
148
154
|
<% end %><%= content %>
|
155
|
+
<% unless !footnotes? || attr?(:nofootnotes) %><div id="footnotes">
|
156
|
+
<hr>
|
157
|
+
<% footnotes.each do |fn| %>
|
158
|
+
<div class="footnote" id="_footnote_<%= fn.index %>">
|
159
|
+
<a href="#_footnoteref_<%= fn.index %>"><%= fn.index %></a>. <%= fn.text %>
|
160
|
+
</div>
|
161
|
+
<% end %>
|
162
|
+
</div><% end %>
|
149
163
|
EOS
|
150
164
|
end
|
151
165
|
end
|
152
166
|
|
167
|
+
class BlockTocTemplate < BaseTemplate
|
168
|
+
def result(node)
|
169
|
+
doc = node.document
|
170
|
+
|
171
|
+
return '' unless doc.attr?('toc')
|
172
|
+
|
173
|
+
if node.id
|
174
|
+
id_attr = %( id="#{node.id}")
|
175
|
+
title_id_attr = ''
|
176
|
+
elsif doc.embedded? || !doc.attr?('toc-placement', 'auto')
|
177
|
+
id_attr = ' id="toc"'
|
178
|
+
title_id_attr = ' id="toctitle"'
|
179
|
+
else
|
180
|
+
id_attr = ''
|
181
|
+
title_id_attr = ''
|
182
|
+
end
|
183
|
+
title = node.title? ? node.title : (doc.attr 'toc-title')
|
184
|
+
levels = node.attr?('levels') ? node.attr('levels').to_i : doc.attr('toclevels', 2).to_i
|
185
|
+
role = node.attr?('role') ? node.attr('role') : doc.attr('toc-class', 'toc')
|
186
|
+
|
187
|
+
%(\n<div#{id_attr} class="#{role}">
|
188
|
+
<div#{title_id_attr} class="title">#{title}</div>
|
189
|
+
#{DocumentTemplate.outline(doc, levels)}
|
190
|
+
</div>)
|
191
|
+
end
|
192
|
+
|
193
|
+
def template
|
194
|
+
:invoke_result
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
153
198
|
class BlockPreambleTemplate < BaseTemplate
|
154
199
|
def template
|
155
200
|
@template ||= @eruby.new <<-EOS
|
@@ -163,25 +208,42 @@ class BlockPreambleTemplate < BaseTemplate
|
|
163
208
|
end
|
164
209
|
|
165
210
|
class SectionTemplate < BaseTemplate
|
211
|
+
def result(sec)
|
212
|
+
slevel = sec.level
|
213
|
+
# QUESTION should this check be done in section?
|
214
|
+
if slevel == 0 && sec.special
|
215
|
+
slevel = 1
|
216
|
+
end
|
217
|
+
htag = "h#{slevel + 1}"
|
218
|
+
id = sec.id && " id=\"#{sec.id}\""
|
219
|
+
|
220
|
+
if slevel == 0
|
221
|
+
%(<h1#{id}>#{sec.title}</h1>
|
222
|
+
#{sec.content})
|
223
|
+
else
|
224
|
+
role = sec.attr?('role') ? " #{sec.attr('role')}" : nil
|
225
|
+
if !sec.special && (sec.attr? 'numbered') && slevel < 4
|
226
|
+
sectnum = "#{sec.sectnum} "
|
227
|
+
else
|
228
|
+
sectnum = nil
|
229
|
+
end
|
230
|
+
|
231
|
+
if slevel == 1
|
232
|
+
content = %( <div class="sectionbody">
|
233
|
+
#{sec.content}
|
234
|
+
</div>)
|
235
|
+
else
|
236
|
+
content = sec.content
|
237
|
+
end
|
238
|
+
%(<div class="sect#{slevel}#{role}">
|
239
|
+
<#{htag}#{id}>#{sectnum}#{sec.attr 'caption'}#{sec.title}</#{htag}>
|
240
|
+
#{content}
|
241
|
+
</div>)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
166
245
|
def template
|
167
|
-
|
168
|
-
<%#encoding:UTF-8%><%
|
169
|
-
if @level == 0 %>
|
170
|
-
<h1#{id}><%= title %></h1>
|
171
|
-
<%= content %>
|
172
|
-
<% else %>
|
173
|
-
<div class="sect<%= @level %>#{role_class}">
|
174
|
-
<h<%= @level + 1 %>#{id}><% if !@special && (attr? :numbered) && @level < 4 %><%= sectnum %> <% end %><%= attr :caption %><%= title %></h<%= @level + 1 %>>
|
175
|
-
<% if @level == 1 %>
|
176
|
-
<div class="sectionbody">
|
177
|
-
<%= content %>
|
178
|
-
</div>
|
179
|
-
<% else %>
|
180
|
-
<%= content %>
|
181
|
-
<% end %>
|
182
|
-
</div>
|
183
|
-
<% end %>
|
184
|
-
EOS
|
246
|
+
:invoke_result
|
185
247
|
end
|
186
248
|
end
|
187
249
|
|
@@ -221,8 +283,8 @@ if attr? :style, 'qanda' %>
|
|
221
283
|
#{title_div}
|
222
284
|
<table>
|
223
285
|
<colgroup>
|
224
|
-
<col<% if attr? :labelwidth %> style="width
|
225
|
-
<col<% if attr? :itemwidth %> style="width
|
286
|
+
<col<% if attr? :labelwidth %> style="width:<%= attr :labelwidth %>%;"<% end %>>
|
287
|
+
<col<% if attr? :itemwidth %> style="width:<%= attr :itemwidth %>%;"<% end %>>
|
226
288
|
</colgroup>
|
227
289
|
<% content.each do |dt, dd| %>
|
228
290
|
<tr>
|
@@ -231,7 +293,7 @@ if attr? :style, 'qanda' %>
|
|
231
293
|
<br>
|
232
294
|
</td>
|
233
295
|
<td class="hdlist2"><% unless dd.nil? %><% if dd.text? %>
|
234
|
-
<p style="margin-top: 0"><%= dd.text %></p><% end %><% if dd.blocks? %>
|
296
|
+
<p style="margin-top: 0;"><%= dd.text %></p><% end %><% if dd.blocks? %>
|
235
297
|
<%= dd.content %><% end %><% end %>
|
236
298
|
</td>
|
237
299
|
</tr>
|
@@ -297,7 +359,7 @@ end
|
|
297
359
|
class BlockAdmonitionTemplate < BaseTemplate
|
298
360
|
def template
|
299
361
|
@template ||= @eruby.new <<-EOS
|
300
|
-
<%#encoding:UTF-8%><div#{id} class="admonitionblock
|
362
|
+
<%#encoding:UTF-8%><div#{id} class="admonitionblock <%= attr :name %>#{role_class}">
|
301
363
|
<table>
|
302
364
|
<tr>
|
303
365
|
<td class="icon">
|
@@ -320,17 +382,18 @@ end
|
|
320
382
|
|
321
383
|
class BlockParagraphTemplate < BaseTemplate
|
322
384
|
def paragraph(id, role, title, content)
|
323
|
-
%(<div#{id && " id=\"#{id}\""} class=\"paragraph#{role && " #{role}"}\"
|
324
|
-
|
385
|
+
%(<div#{id && " id=\"#{id}\""} class=\"paragraph#{role && " #{role}"}\">#{title && "
|
386
|
+
<div class=\"title\">#{title}</div>"}
|
325
387
|
<p>#{content}</p>
|
326
388
|
</div>)
|
327
389
|
end
|
328
390
|
|
391
|
+
def result(node)
|
392
|
+
paragraph(node.id, node.attr('role'), (node.title? ? node.title : nil), node.content)
|
393
|
+
end
|
394
|
+
|
329
395
|
def template
|
330
|
-
|
331
|
-
@template ||= @eruby.new <<-EOS
|
332
|
-
<%#encoding:UTF-8%><%= template.paragraph(@id, (attr 'role'), title? ? title : nil, content) %>
|
333
|
-
EOS
|
396
|
+
:invoke_result
|
334
397
|
end
|
335
398
|
end
|
336
399
|
|
@@ -497,7 +560,7 @@ class BlockTableTemplate < BaseTemplate
|
|
497
560
|
def template
|
498
561
|
@template ||= @eruby.new <<-EOS
|
499
562
|
<%#encoding:UTF-8%><table#{id} class="tableblock frame-<%= attr :frame, 'all' %> grid-<%= attr :grid, 'all'%>#{role_class}" style="<%
|
500
|
-
if !(attr? 'autowidth-option') %>width
|
563
|
+
if !(attr? 'autowidth-option') %>width:<%= attr :tablepcwidth %>%; <% end %><%
|
501
564
|
if attr? :float %>float: <%= attr :float %>; <% end %>">
|
502
565
|
<% if title? %>
|
503
566
|
<caption class="title"><% unless @caption.nil? %><%= @caption %><% end %><%= title %></caption>
|
@@ -510,7 +573,7 @@ if attr? :float %>float: <%= attr :float %>; <% end %>">
|
|
510
573
|
<% end %>
|
511
574
|
<% else %>
|
512
575
|
<% @columns.each do |col| %>
|
513
|
-
<col style="width
|
576
|
+
<col style="width:<%= col.attr :colpcwidth %>%;">
|
514
577
|
<% end %>
|
515
578
|
<% end %>
|
516
579
|
</colgroup>
|
@@ -558,52 +621,103 @@ class BlockImageTemplate < BaseTemplate
|
|
558
621
|
end
|
559
622
|
end
|
560
623
|
|
561
|
-
class
|
624
|
+
class BlockAudioTemplate < BaseTemplate
|
562
625
|
def template
|
563
626
|
@template ||= @eruby.new <<-EOS
|
564
|
-
<%#encoding:UTF-8%><
|
627
|
+
<%#encoding:UTF-8%><div#{id} class="audioblock#{style_class}#{role_class}">
|
628
|
+
#{title_div :caption => true}
|
629
|
+
<div class="content">
|
630
|
+
<audio src="<%= media_uri(attr :target) %>"<% if
|
631
|
+
attr? 'autoplay-option' %> autoplay<% end %><%
|
632
|
+
unless attr? 'nocontrols-option' %> controls<% end %><%
|
633
|
+
if attr? 'loop-option' %> loop<% end %>>
|
634
|
+
Your browser does not support the audio tag.
|
635
|
+
</audio>
|
636
|
+
</div>
|
637
|
+
</div>
|
565
638
|
EOS
|
566
639
|
end
|
567
640
|
end
|
568
641
|
|
569
|
-
class
|
642
|
+
class BlockVideoTemplate < BaseTemplate
|
570
643
|
def template
|
571
644
|
@template ||= @eruby.new <<-EOS
|
572
|
-
<%#encoding:UTF-8%><div
|
645
|
+
<%#encoding:UTF-8%><div#{id} class="videoblock#{style_class}#{role_class}">
|
646
|
+
#{title_div :caption => true}
|
647
|
+
<div class="content">
|
648
|
+
<video src="<%= media_uri(attr :target) %>"#{attribute('width', :width)}#{attribute('height', :height)}<%
|
649
|
+
if attr? 'poster' %> poster="<%= media_uri(attr :poster) %>"<% end %><%
|
650
|
+
if attr? 'autoplay-option' %> autoplay<% end %><%
|
651
|
+
unless attr? 'nocontrols-option' %> controls<% end %><%
|
652
|
+
if attr? 'loop-option' %> loop<% end %>>
|
653
|
+
Your browser does not support the video tag.
|
654
|
+
</video>
|
655
|
+
</div>
|
656
|
+
</div>
|
573
657
|
EOS
|
574
658
|
end
|
575
659
|
end
|
576
660
|
|
661
|
+
class BlockRulerTemplate < BaseTemplate
|
662
|
+
def result(node)
|
663
|
+
'<hr>'
|
664
|
+
end
|
665
|
+
|
666
|
+
def template
|
667
|
+
:invoke_result
|
668
|
+
end
|
669
|
+
end
|
670
|
+
|
671
|
+
class BlockPageBreakTemplate < BaseTemplate
|
672
|
+
def result(node)
|
673
|
+
'<div style="page-break-after: always;"></div>'
|
674
|
+
end
|
675
|
+
|
676
|
+
def template
|
677
|
+
:invoke_result
|
678
|
+
end
|
679
|
+
end
|
680
|
+
|
577
681
|
class InlineBreakTemplate < BaseTemplate
|
682
|
+
def result(node)
|
683
|
+
"#{node.text}<br>"
|
684
|
+
end
|
685
|
+
|
578
686
|
def template
|
579
|
-
|
580
|
-
<%#encoding:UTF-8%><%= "\#@text<br>" %>
|
581
|
-
EOS
|
687
|
+
:invoke_result
|
582
688
|
end
|
583
689
|
end
|
584
690
|
|
585
691
|
class InlineCalloutTemplate < BaseTemplate
|
692
|
+
def result(node)
|
693
|
+
if node.attr? 'icons'
|
694
|
+
src = node.icon_uri("callouts/#{node.text}")
|
695
|
+
%(<img src="#{src}" alt="#{node.text}">)
|
696
|
+
else
|
697
|
+
"<b><#{node.text}></b>"
|
698
|
+
end
|
699
|
+
end
|
700
|
+
|
586
701
|
def template
|
587
|
-
|
588
|
-
<%#encoding:UTF-8%><% if attr? :icons %><img src="<%= icon_uri("callouts/\#@text") %>" alt="<%= @text %>"><% else %><b><<%= @text %>></b><% end %>
|
589
|
-
EOS
|
702
|
+
:invoke_result
|
590
703
|
end
|
591
704
|
end
|
592
705
|
|
593
706
|
class InlineQuotedTemplate < BaseTemplate
|
707
|
+
NO_TAGS = ['', '']
|
708
|
+
|
594
709
|
QUOTED_TAGS = {
|
595
710
|
:emphasis => ['<em>', '</em>'],
|
596
711
|
:strong => ['<strong>', '</strong>'],
|
597
|
-
:monospaced => ['<
|
712
|
+
:monospaced => ['<code>', '</code>'],
|
598
713
|
:superscript => ['<sup>', '</sup>'],
|
599
714
|
:subscript => ['<sub>', '</sub>'],
|
600
715
|
:double => ['“', '”'],
|
601
716
|
:single => ['‘', '’']
|
602
|
-
#:none => ['', '']
|
603
717
|
}
|
604
718
|
|
605
|
-
def
|
606
|
-
start_tag, end_tag = QUOTED_TAGS[type] ||
|
719
|
+
def quote_text(text, type, role)
|
720
|
+
start_tag, end_tag = QUOTED_TAGS[type] || NO_TAGS
|
607
721
|
if role
|
608
722
|
"#{start_tag}<span class=\"#{role}\">#{text}</span>#{end_tag}"
|
609
723
|
else
|
@@ -611,11 +725,12 @@ class InlineQuotedTemplate < BaseTemplate
|
|
611
725
|
end
|
612
726
|
end
|
613
727
|
|
728
|
+
def result(node)
|
729
|
+
quote_text(node.text, node.type, node.attr('role'))
|
730
|
+
end
|
731
|
+
|
614
732
|
def template
|
615
|
-
|
616
|
-
@template ||= @eruby.new <<-EOS
|
617
|
-
<%#encoding:UTF-8%><%= template.quote(@text, @type, attr('role')) %>
|
618
|
-
EOS
|
733
|
+
:invoke_result
|
619
734
|
end
|
620
735
|
end
|
621
736
|
|
@@ -627,18 +742,19 @@ class InlineAnchorTemplate < BaseTemplate
|
|
627
742
|
%(<a href="##{target}">#{text}</a>)
|
628
743
|
when :ref
|
629
744
|
%(<a id="#{target}"></a>)
|
630
|
-
when :bibref
|
631
|
-
%(<a id="#{target}"></a>[#{target}])
|
632
745
|
when :link
|
633
746
|
%(<a href="#{target}"#{window && " target=\"#{window}\""}>#{text}</a>)
|
747
|
+
when :bibref
|
748
|
+
%(<a id="#{target}"></a>[#{target}])
|
634
749
|
end
|
635
750
|
end
|
636
751
|
|
752
|
+
def result(node)
|
753
|
+
anchor(node.target, node.text, node.type, node.document, (node.type == :link ? node.attr('window') : nil))
|
754
|
+
end
|
755
|
+
|
637
756
|
def template
|
638
|
-
|
639
|
-
@template ||= @eruby.new <<-EOS
|
640
|
-
<%#encoding:UTF-8%><%= template.anchor(@target, @text, @type, @document, @type == :link ? attr('window') : nil) %>
|
641
|
-
EOS
|
757
|
+
:invoke_result
|
642
758
|
end
|
643
759
|
end
|
644
760
|
|
@@ -646,13 +762,11 @@ class InlineImageTemplate < BaseTemplate
|
|
646
762
|
def template
|
647
763
|
# care is taken here to avoid a space inside the optional <a> tag
|
648
764
|
@template ||= @eruby.new <<-EOS
|
649
|
-
<%#encoding:UTF-8%><span class="image#{role_class}"
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
%>
|
655
|
-
</span>
|
765
|
+
<%#encoding:UTF-8%><span class="image#{role_class}"><%
|
766
|
+
if attr? :link %><a class="image" href="<%= attr :link %>"><%
|
767
|
+
end %><img src="<%= image_uri(@target) %>" alt="<%= attr :alt %>"#{attribute('width', :width)}#{attribute('height', :height)}#{attribute('title', :title)}><%
|
768
|
+
if attr? :link%></a><% end
|
769
|
+
%></span>
|
656
770
|
EOS
|
657
771
|
end
|
658
772
|
end
|
@@ -671,10 +785,12 @@ end %>
|
|
671
785
|
end
|
672
786
|
|
673
787
|
class InlineIndextermTemplate < BaseTemplate
|
788
|
+
def result(node)
|
789
|
+
node.type == :visible ? node.text : ''
|
790
|
+
end
|
791
|
+
|
674
792
|
def template
|
675
|
-
|
676
|
-
<%#encoding:UTF-8%><%= "\#{@type == :visible ? @text : ''}" %>
|
677
|
-
EOS
|
793
|
+
:invoke_result
|
678
794
|
end
|
679
795
|
end
|
680
796
|
|