asciidoctor 0.0.9 → 0.1.0
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.
- data/README.asciidoc +163 -41
- data/Rakefile +3 -1
- data/asciidoctor.gemspec +13 -5
- data/bin/asciidoctor +6 -3
- data/bin/asciidoctor-safe +13 -0
- data/lib/asciidoctor.rb +237 -26
- data/lib/asciidoctor/abstract_node.rb +27 -17
- data/lib/asciidoctor/attribute_list.rb +6 -0
- data/lib/asciidoctor/backends/base_template.rb +3 -4
- data/lib/asciidoctor/backends/docbook45.rb +114 -55
- data/lib/asciidoctor/backends/html5.rb +173 -104
- data/lib/asciidoctor/cli/invoker.rb +105 -0
- data/lib/asciidoctor/cli/options.rb +146 -0
- data/lib/asciidoctor/document.rb +135 -35
- data/lib/asciidoctor/lexer.rb +86 -33
- data/lib/asciidoctor/list_item.rb +2 -2
- data/lib/asciidoctor/reader.rb +6 -7
- data/lib/asciidoctor/section.rb +17 -5
- data/lib/asciidoctor/substituters.rb +216 -97
- data/lib/asciidoctor/table.rb +9 -2
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +212 -0
- data/man/asciidoctor.ad +156 -0
- data/test/attributes_test.rb +108 -5
- data/test/blocks_test.rb +102 -15
- data/test/document_test.rb +214 -3
- data/test/fixtures/encoding.asciidoc +4 -0
- data/test/fixtures/sample.asciidoc +26 -0
- data/test/invoker_test.rb +254 -0
- data/test/lexer_test.rb +53 -0
- data/test/links_test.rb +30 -0
- data/test/lists_test.rb +648 -9
- data/test/options_test.rb +68 -0
- data/test/paragraphs_test.rb +65 -1
- data/test/reader_test.rb +18 -4
- data/test/{headers_test.rb → sections_test.rb} +237 -0
- data/test/substitutions_test.rb +247 -5
- data/test/tables_test.rb +22 -4
- data/test/test_helper.rb +47 -3
- data/test/text_test.rb +20 -4
- metadata +34 -6
- data/noof.rb +0 -16
@@ -97,7 +97,7 @@ class Asciidoctor::AbstractNode
|
|
97
97
|
# If the 'icon' attribute is set on this block, the name is ignored and the
|
98
98
|
# value of this attribute is used as the target image path. Otherwise,
|
99
99
|
# construct a target image path by concatenating the value of the 'iconsdir'
|
100
|
-
# attribute, the icon name and the value of the '
|
100
|
+
# attribute, the icon name and the value of the 'icontype' attribute
|
101
101
|
# (defaulting to 'png').
|
102
102
|
#
|
103
103
|
# The target image path is then passed through the #image_uri() method. If
|
@@ -113,7 +113,7 @@ class Asciidoctor::AbstractNode
|
|
113
113
|
if attr? 'icon'
|
114
114
|
image_uri(attr('icon'), nil)
|
115
115
|
else
|
116
|
-
image_uri(name + '.' + @document.attr('
|
116
|
+
image_uri(name + '.' + @document.attr('icontype', 'png'), 'iconsdir')
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -166,16 +166,22 @@ class Asciidoctor::AbstractNode
|
|
166
166
|
image_path = normalize_asset_path(target_image)
|
167
167
|
end
|
168
168
|
|
169
|
-
|
169
|
+
bindata = nil
|
170
|
+
if IO.respond_to? :binread
|
171
|
+
bindata = IO.binread(image_path)
|
172
|
+
else
|
173
|
+
bindata = File.open(image_path, 'rb') {|file| file.read }
|
174
|
+
end
|
175
|
+
'data:' + mimetype + ';base64,' + Base64.encode64(bindata).delete("\n")
|
170
176
|
end
|
171
177
|
|
172
178
|
# Public: Normalize the asset file or directory to a concrete and rinsed path
|
173
179
|
#
|
174
180
|
# The most important functionality in this method is to prevent the asset
|
175
181
|
# reference from resolving to a directory outside of the chroot directory
|
176
|
-
# (which defaults to the directory of the source file, stored in the
|
177
|
-
#
|
178
|
-
# (a condition which is true by default).
|
182
|
+
# (which defaults to the directory of the source file, stored in the base_dir
|
183
|
+
# instance variable on Document) if the document safe level is set to
|
184
|
+
# SafeMode::SAFE or greater (a condition which is true by default).
|
179
185
|
#
|
180
186
|
# asset_ref - the String asset file or directory referenced in the document
|
181
187
|
# or configuration attribute
|
@@ -185,28 +191,28 @@ class Asciidoctor::AbstractNode
|
|
185
191
|
# Examples
|
186
192
|
#
|
187
193
|
# # given these fixtures
|
188
|
-
# document.
|
189
|
-
# # => "/path/to/
|
194
|
+
# document.base_dir
|
195
|
+
# # => "/path/to/chroot"
|
190
196
|
# document.safe >= Asciidoctor::SafeMode::SAFE
|
191
197
|
# # => true
|
192
198
|
#
|
193
199
|
# # then
|
194
200
|
# normalize_asset_path('images')
|
195
|
-
# # => "/path/to/
|
201
|
+
# # => "/path/to/chroot/images"
|
196
202
|
# normalize_asset_path('/etc/images')
|
197
|
-
# # => "/path/to/
|
203
|
+
# # => "/path/to/chroot/images"
|
198
204
|
# normalize_asset_path('../images')
|
199
|
-
# # => "/path/to/
|
205
|
+
# # => "/path/to/chroot/images"
|
200
206
|
#
|
201
207
|
# # given these fixtures
|
202
|
-
# document.
|
203
|
-
# # => "/path/to/
|
208
|
+
# document.base_dir
|
209
|
+
# # => "/path/to/chroot"
|
204
210
|
# document.safe >= Asciidoctor::SafeMode::SAFE
|
205
211
|
# # => false
|
206
212
|
#
|
207
213
|
# # then
|
208
214
|
# normalize_asset_path('images')
|
209
|
-
# # => "/path/to/
|
215
|
+
# # => "/path/to/chroot/images"
|
210
216
|
# normalize_asset_path('/etc/images')
|
211
217
|
# # => "/etc/images"
|
212
218
|
# normalize_asset_path('../images')
|
@@ -217,11 +223,11 @@ class Asciidoctor::AbstractNode
|
|
217
223
|
# TODO this method is missing a coordinate; it should be able to resolve
|
218
224
|
# both the directory reference and the path to an asset in it; callers
|
219
225
|
# of this method are still doing a File.join to finish the task
|
220
|
-
def normalize_asset_path(asset_ref, asset_name = 'path')
|
226
|
+
def normalize_asset_path(asset_ref, asset_name = 'path', autocorrect = true)
|
221
227
|
# TODO we may use pathname enough to make it a top-level require
|
222
228
|
Asciidoctor.require_library 'pathname'
|
223
229
|
|
224
|
-
input_path =
|
230
|
+
input_path = @document.base_dir
|
225
231
|
asset_path = Pathname.new(asset_ref)
|
226
232
|
|
227
233
|
if asset_path.relative?
|
@@ -233,7 +239,11 @@ class Asciidoctor::AbstractNode
|
|
233
239
|
if @document.safe >= Asciidoctor::SafeMode::SAFE
|
234
240
|
relative_asset_path = Pathname.new(asset_path).relative_path_from(Pathname.new(input_path)).to_s
|
235
241
|
if relative_asset_path.start_with?('..')
|
236
|
-
|
242
|
+
if autocorrect
|
243
|
+
puts 'asciidoctor: WARNING: ' + asset_name + ' has illegal reference to ancestor of base directory'
|
244
|
+
else
|
245
|
+
raise SecurityError, "#{asset_name} has reference to path outside of base directory, disallowed in safe mode: #{asset_path}"
|
246
|
+
end
|
237
247
|
relative_asset_path.sub!(/^(?:\.\.\/)*/, '')
|
238
248
|
# just to be absolutely sure ;)
|
239
249
|
if relative_asset_path[0..0] == '.'
|
@@ -179,6 +179,12 @@ class Asciidoctor::AttributeList
|
|
179
179
|
end
|
180
180
|
|
181
181
|
def parse_attribute_value(quote)
|
182
|
+
# empty quoted value
|
183
|
+
if @scanner.peek(1) == quote
|
184
|
+
@scanner.get_byte
|
185
|
+
return ''
|
186
|
+
end
|
187
|
+
|
182
188
|
value = scan_to_quote quote
|
183
189
|
if value.nil?
|
184
190
|
quote + scan_to_delimiter
|
@@ -75,13 +75,12 @@ class Asciidoctor::BaseTemplate
|
|
75
75
|
# create template matter to insert an attribute if the variable has a value
|
76
76
|
def attribute(name, key)
|
77
77
|
type = key.is_a?(Symbol) ? :attr : :var
|
78
|
-
key = key.to_s
|
79
78
|
if type == :attr
|
80
79
|
# example: <% if attr? 'foo' %> bar="<%= attr 'foo' %>"<% end %>
|
81
|
-
|
80
|
+
%(<% if attr? '#{key}' %> #{name}="<%= attr '#{key}' %>"<% end %>)
|
82
81
|
else
|
83
82
|
# example: <% if foo %> bar="<%= foo %>"<% end %>
|
84
|
-
|
83
|
+
%(<% if #{key} %> #{name}="<%= #{key} %>"<% end %>)
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
@@ -89,7 +88,7 @@ class Asciidoctor::BaseTemplate
|
|
89
88
|
def attrvalue(key, sibling = true)
|
90
89
|
delimiter = sibling ? ' ' : ''
|
91
90
|
# example: <% if attr? 'foo' %><%= attr 'foo' %><% end %>
|
92
|
-
|
91
|
+
%(<% if attr? '#{key}' %>#{delimiter}<%= attr '#{key}' %><% end %>)
|
93
92
|
end
|
94
93
|
|
95
94
|
# create template matter to insert an id if one is specified for the block
|
@@ -16,10 +16,10 @@ class Asciidoctor::BaseTemplate
|
|
16
16
|
key = key.to_s
|
17
17
|
if type == :attr
|
18
18
|
# example: <% if attr? 'foo' %><bar><%= attr 'foo' %></bar><% end %>
|
19
|
-
|
19
|
+
%(<% if attr? '#{key}' %><#{name}><%= attr '#{key}' %></#{name}><% end %>)
|
20
20
|
else
|
21
21
|
# example: <% unless foo.to_s.empty? %><bar><%= foo %></bar><% end %>
|
22
|
-
|
22
|
+
%(<% unless #{key}.to_s.empty? %><#{name}><%= #{key} %></#{name}><% end %>)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -60,8 +60,7 @@ class DocumentTemplate < ::Asciidoctor::BaseTemplate
|
|
60
60
|
|
61
61
|
def template
|
62
62
|
@template ||= @eruby.new <<-EOF
|
63
|
-
<%#encoding:UTF-8
|
64
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
63
|
+
<%#encoding:UTF-8%><?xml version="1.0" encoding="UTF-8"?>
|
65
64
|
<!DOCTYPE <%= doctype %> PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
|
66
65
|
<% if attr? :toc %><?asciidoc-toc?><% end %>
|
67
66
|
<% if attr? :numbered %><?asciidoc-numbered?><% end %>
|
@@ -87,8 +86,7 @@ end
|
|
87
86
|
class EmbeddedTemplate < ::Asciidoctor::BaseTemplate
|
88
87
|
def template
|
89
88
|
@template ||= @eruby.new <<-EOS
|
90
|
-
<%#encoding:UTF-8%>
|
91
|
-
<%= content %>
|
89
|
+
<%#encoding:UTF-8%><%= content %>
|
92
90
|
EOS
|
93
91
|
end
|
94
92
|
end
|
@@ -96,8 +94,7 @@ end
|
|
96
94
|
class BlockPreambleTemplate < ::Asciidoctor::BaseTemplate
|
97
95
|
def template
|
98
96
|
@template ||= @eruby.new <<-EOF
|
99
|
-
<%#encoding:UTF-8%>
|
100
|
-
<% if document.doctype == 'book' %>
|
97
|
+
<%#encoding:UTF-8%><% if document.doctype == 'book' %>
|
101
98
|
<preface#{id}#{role}#{xreflabel}>
|
102
99
|
<title><%= title %></title>
|
103
100
|
<%= content %>
|
@@ -112,20 +109,27 @@ end
|
|
112
109
|
class SectionTemplate < ::Asciidoctor::BaseTemplate
|
113
110
|
def template
|
114
111
|
@template ||= @eruby.new <<-EOF
|
115
|
-
<%#encoding:UTF-8
|
116
|
-
<<%= document.doctype == 'book' && level <= 1 ? 'chapter' : 'section' %>#{id}#{role}#{xreflabel}>
|
112
|
+
<%#encoding:UTF-8%><<%= @special ? @sectname : (document.doctype == 'book' && @level <= 1 ? 'chapter' : 'section') %>#{id}#{role}#{xreflabel}>
|
117
113
|
#{title}
|
118
114
|
<%= content %>
|
119
|
-
</<%= document.doctype == 'book' && level <= 1 ? 'chapter' : 'section' %>>
|
115
|
+
</<%= @special ? @sectname : (document.doctype == 'book' && @level <= 1 ? 'chapter' : 'section') %>>
|
120
116
|
EOF
|
121
117
|
end
|
122
118
|
end
|
123
119
|
|
120
|
+
class BlockFloatingTitleTemplate < ::Asciidoctor::BaseTemplate
|
121
|
+
def template
|
122
|
+
@template ||= @eruby.new <<-EOS
|
123
|
+
<%#encoding:UTF-8%><bridgehead#{id}#{role}#{xreflabel} renderas="sect<%= @level %>"><%= title %></bridgehead>
|
124
|
+
EOS
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
|
124
129
|
class BlockParagraphTemplate < ::Asciidoctor::BaseTemplate
|
125
130
|
def template
|
126
131
|
@template ||= @eruby.new <<-EOF
|
127
|
-
<%#encoding:UTF-8%>
|
128
|
-
<% if !title? %>
|
132
|
+
<%#encoding:UTF-8%><% if !title? %>
|
129
133
|
<simpara#{id}#{role}#{xreflabel}><%= content %></simpara>
|
130
134
|
<% else %>
|
131
135
|
<formalpara#{id}#{role}#{xreflabel}>
|
@@ -140,8 +144,7 @@ end
|
|
140
144
|
class BlockAdmonitionTemplate < ::Asciidoctor::BaseTemplate
|
141
145
|
def template
|
142
146
|
@template ||= @eruby.new <<-EOF
|
143
|
-
<%#encoding:UTF-8
|
144
|
-
<<%= attr :name %>#{id}#{role}#{xreflabel}>
|
147
|
+
<%#encoding:UTF-8%><<%= attr :name %>#{id}#{role}#{xreflabel}>
|
145
148
|
#{title}
|
146
149
|
<% if blocks? %>
|
147
150
|
<%= content %>
|
@@ -156,7 +159,19 @@ end
|
|
156
159
|
class BlockUlistTemplate < ::Asciidoctor::BaseTemplate
|
157
160
|
def template
|
158
161
|
@template ||= @eruby.new <<-EOF
|
159
|
-
<%#encoding:UTF-8%>
|
162
|
+
<%#encoding:UTF-8%><% if (attr :style) == 'bibliography' %>
|
163
|
+
<bibliodiv#{id}#{role}#{xreflabel}>
|
164
|
+
#{title}
|
165
|
+
<% content.each do |li| %>
|
166
|
+
<bibliomixed>
|
167
|
+
<bibliomisc><%= li.text %></bibliomisc>
|
168
|
+
<% if li.blocks? %>
|
169
|
+
<%= li.content %>
|
170
|
+
<% end %>
|
171
|
+
</bibliomixed>
|
172
|
+
<% end %>
|
173
|
+
</bibliodiv>
|
174
|
+
<% else %>
|
160
175
|
<itemizedlist#{id}#{role}#{xreflabel}>
|
161
176
|
#{title}
|
162
177
|
<% content.each do |li| %>
|
@@ -168,6 +183,7 @@ class BlockUlistTemplate < ::Asciidoctor::BaseTemplate
|
|
168
183
|
</listitem>
|
169
184
|
<% end %>
|
170
185
|
</itemizedlist>
|
186
|
+
<% end %>
|
171
187
|
EOF
|
172
188
|
end
|
173
189
|
end
|
@@ -175,8 +191,7 @@ end
|
|
175
191
|
class BlockOlistTemplate < ::Asciidoctor::BaseTemplate
|
176
192
|
def template
|
177
193
|
@template ||= @eruby.new <<-EOF
|
178
|
-
<%#encoding:UTF-8
|
179
|
-
<orderedlist#{id}#{role}#{xreflabel}#{attribute('numeration', :style)}>
|
194
|
+
<%#encoding:UTF-8%><orderedlist#{id}#{role}#{xreflabel}#{attribute('numeration', :style)}>
|
180
195
|
#{title}
|
181
196
|
<% content.each do |li| %>
|
182
197
|
<listitem>
|
@@ -194,8 +209,7 @@ end
|
|
194
209
|
class BlockColistTemplate < ::Asciidoctor::BaseTemplate
|
195
210
|
def template
|
196
211
|
@template ||= @eruby.new <<-EOF
|
197
|
-
<%#encoding:UTF-8
|
198
|
-
<calloutlist#{id}#{role}#{xreflabel}>
|
212
|
+
<%#encoding:UTF-8%><calloutlist#{id}#{role}#{xreflabel}>
|
199
213
|
#{title}
|
200
214
|
<% content.each do |li| %>
|
201
215
|
<callout arearefs="<%= li.attr :coids %>">
|
@@ -211,29 +225,50 @@ class BlockColistTemplate < ::Asciidoctor::BaseTemplate
|
|
211
225
|
end
|
212
226
|
|
213
227
|
class BlockDlistTemplate < ::Asciidoctor::BaseTemplate
|
228
|
+
LIST_TAGS = {
|
229
|
+
'labeled' => {
|
230
|
+
:list => 'variablelist',
|
231
|
+
:entry => 'varlistentry',
|
232
|
+
:term => 'term',
|
233
|
+
:item => 'listitem'
|
234
|
+
},
|
235
|
+
'qanda' => {
|
236
|
+
:list => 'qandaset',
|
237
|
+
:entry => 'qandaentry',
|
238
|
+
:term => 'question',
|
239
|
+
:item => 'answer'
|
240
|
+
},
|
241
|
+
'glossary' => {
|
242
|
+
:list => nil,
|
243
|
+
:entry => 'glossentry',
|
244
|
+
:term => 'glossterm',
|
245
|
+
:item => 'glossdef'
|
246
|
+
}
|
247
|
+
}
|
248
|
+
|
214
249
|
def template
|
215
250
|
@template ||= @eruby.new <<-EOF
|
216
|
-
<%#encoding:UTF-8%>
|
217
|
-
|
251
|
+
<%#encoding:UTF-8%><% tags = (template.class::LIST_TAGS[attr :style] || template.class::LIST_TAGS['labeled']) %>
|
252
|
+
<% if tags[:list] %><<%= tags[:list] %>#{id}#{role}#{xreflabel}><% end %>
|
218
253
|
#{title}
|
219
254
|
<% content.each do |dt, dd| %>
|
220
|
-
|
221
|
-
|
255
|
+
<<%= tags[:entry] %>>
|
256
|
+
<<%= tags[:term] %>>
|
222
257
|
<%= dt.text %>
|
223
|
-
|
258
|
+
</<%= tags[:term] %>>
|
224
259
|
<% unless dd.nil? %>
|
225
|
-
|
260
|
+
<<%= tags[:item] %>>
|
226
261
|
<% if dd.text? %>
|
227
262
|
<simpara><%= dd.text %></simpara>
|
228
263
|
<% end %>
|
229
264
|
<% if dd.blocks? %>
|
230
265
|
<%= dd.content %>
|
231
266
|
<% end %>
|
232
|
-
|
267
|
+
</<%= tags[:item] %>>
|
233
268
|
<% end %>
|
234
|
-
|
269
|
+
</<%= tags[:entry] %>>
|
235
270
|
<% end %>
|
236
|
-
|
271
|
+
<% if tags[:list] %></<%= tags[:list] %>><% end %>
|
237
272
|
EOF
|
238
273
|
end
|
239
274
|
end
|
@@ -241,8 +276,7 @@ end
|
|
241
276
|
class BlockOpenTemplate < ::Asciidoctor::BaseTemplate
|
242
277
|
def template
|
243
278
|
@template ||= @eruby.new <<-EOS
|
244
|
-
<%#encoding:UTF-8%>
|
245
|
-
<%= content %>
|
279
|
+
<%#encoding:UTF-8%><%= content %>
|
246
280
|
EOS
|
247
281
|
end
|
248
282
|
end
|
@@ -250,8 +284,7 @@ end
|
|
250
284
|
class BlockListingTemplate < ::Asciidoctor::BaseTemplate
|
251
285
|
def template
|
252
286
|
@template ||= @eruby.new <<-EOF
|
253
|
-
<%#encoding:UTF-8%>
|
254
|
-
<% if !title? %>
|
287
|
+
<%#encoding:UTF-8%><% if !title? %>
|
255
288
|
<% if (attr :style) == 'source' %>
|
256
289
|
<programlisting#{id}#{role}#{xreflabel}#{attribute('language', :language)} linenumbering="<%= (attr? :linenums) ? 'numbered' : 'unnumbered' %>"><%= template.preserve_endlines(content, self) %></programlisting>
|
257
290
|
<% else %>
|
@@ -276,8 +309,7 @@ end
|
|
276
309
|
class BlockLiteralTemplate < ::Asciidoctor::BaseTemplate
|
277
310
|
def template
|
278
311
|
@template ||= @eruby.new <<-EOF
|
279
|
-
<%#encoding:UTF-8%>
|
280
|
-
<% if !title? %>
|
312
|
+
<%#encoding:UTF-8%><% if !title? %>
|
281
313
|
<literallayout#{id}#{role}#{xreflabel} class="monospaced"><%= template.preserve_endlines(content, self) %></literallayout>
|
282
314
|
<% else %>
|
283
315
|
<formalpara#{id}#{role}#{xreflabel}>
|
@@ -294,8 +326,7 @@ end
|
|
294
326
|
class BlockExampleTemplate < ::Asciidoctor::BaseTemplate
|
295
327
|
def template
|
296
328
|
@template ||= @eruby.new <<-EOF
|
297
|
-
<%#encoding:UTF-8
|
298
|
-
<example#{id}#{role}#{xreflabel}>
|
329
|
+
<%#encoding:UTF-8%><example#{id}#{role}#{xreflabel}>
|
299
330
|
#{title}
|
300
331
|
<%= content %>
|
301
332
|
</example>
|
@@ -306,8 +337,7 @@ end
|
|
306
337
|
class BlockSidebarTemplate < ::Asciidoctor::BaseTemplate
|
307
338
|
def template
|
308
339
|
@template ||= @eruby.new <<-EOF
|
309
|
-
<%#encoding:UTF-8
|
310
|
-
<sidebar#{id}#{role}#{xreflabel}>
|
340
|
+
<%#encoding:UTF-8%><sidebar#{id}#{role}#{xreflabel}>
|
311
341
|
#{title}
|
312
342
|
<%= content %>
|
313
343
|
</sidebar>
|
@@ -318,8 +348,7 @@ end
|
|
318
348
|
class BlockQuoteTemplate < ::Asciidoctor::BaseTemplate
|
319
349
|
def template
|
320
350
|
@template ||= @eruby.new <<-EOF
|
321
|
-
<%#encoding:UTF-8
|
322
|
-
<blockquote#{id}#{role}#{xreflabel}>
|
351
|
+
<%#encoding:UTF-8%><blockquote#{id}#{role}#{xreflabel}>
|
323
352
|
#{title}
|
324
353
|
<% if (attr? :attribution) || (attr? :citetitle) %>
|
325
354
|
<attribution>
|
@@ -342,8 +371,7 @@ end
|
|
342
371
|
class BlockVerseTemplate < ::Asciidoctor::BaseTemplate
|
343
372
|
def template
|
344
373
|
@template ||= @eruby.new <<-EOF
|
345
|
-
<%#encoding:UTF-8
|
346
|
-
<blockquote#{id}#{role}#{xreflabel}>
|
374
|
+
<%#encoding:UTF-8%><blockquote#{id}#{role}#{xreflabel}>
|
347
375
|
#{title}
|
348
376
|
<% if (attr? :attribution) || (attr? :citetitle) %>
|
349
377
|
<attribution>
|
@@ -362,8 +390,7 @@ end
|
|
362
390
|
class BlockPassTemplate < ::Asciidoctor::BaseTemplate
|
363
391
|
def template
|
364
392
|
@template ||= @eruby.new <<-EOS
|
365
|
-
<%#encoding:UTF-8%>
|
366
|
-
<%= content %>
|
393
|
+
<%#encoding:UTF-8%><%= content %>
|
367
394
|
EOS
|
368
395
|
end
|
369
396
|
end
|
@@ -371,8 +398,7 @@ end
|
|
371
398
|
class BlockTableTemplate < ::Asciidoctor::BaseTemplate
|
372
399
|
def template
|
373
400
|
@template ||= @eruby.new <<-EOS
|
374
|
-
<%#encoding:UTF-8%>
|
375
|
-
<<%= title? ? 'table' : 'informaltable'%>#{id}#{role}#{xreflabel} frame="<%= attr :frame, 'all'%>"
|
401
|
+
<%#encoding:UTF-8%><<%= title? ? 'table' : 'informaltable'%>#{id}#{role}#{xreflabel} frame="<%= attr :frame, 'all'%>"
|
376
402
|
rowsep="<%= ['none', 'cols'].include?(attr :grid) ? 0 : 1 %>" colsep="<%= ['none', 'rows'].include?(attr :grid) ? 0 : 1 %>">
|
377
403
|
#{title}
|
378
404
|
<% if attr? :width %>
|
@@ -415,8 +441,7 @@ end
|
|
415
441
|
class BlockImageTemplate < ::Asciidoctor::BaseTemplate
|
416
442
|
def template
|
417
443
|
@template ||= @eruby.new <<-EOF
|
418
|
-
<%#encoding:UTF-8
|
419
|
-
<figure#{id}#{role}#{xreflabel}>
|
444
|
+
<%#encoding:UTF-8%><%#encoding:UTF-8%><figure#{id}#{role}#{xreflabel}>
|
420
445
|
#{title}
|
421
446
|
<mediaobject>
|
422
447
|
<imageobject>
|
@@ -432,7 +457,7 @@ end
|
|
432
457
|
class BlockRulerTemplate < ::Asciidoctor::BaseTemplate
|
433
458
|
def template
|
434
459
|
@template ||= @eruby.new <<-EOF
|
435
|
-
|
460
|
+
<%#encoding:UTF-8%><simpara><?asciidoc-hr?></simpara>
|
436
461
|
EOF
|
437
462
|
end
|
438
463
|
end
|
@@ -440,7 +465,7 @@ end
|
|
440
465
|
class InlineBreakTemplate < ::Asciidoctor::BaseTemplate
|
441
466
|
def template
|
442
467
|
@template ||= @eruby.new <<-EOF
|
443
|
-
|
468
|
+
<%#encoding:UTF-8%><%= text %><?asciidoc-br?>
|
444
469
|
EOF
|
445
470
|
end
|
446
471
|
end
|
@@ -459,7 +484,7 @@ class InlineQuotedTemplate < ::Asciidoctor::BaseTemplate
|
|
459
484
|
|
460
485
|
def template
|
461
486
|
@template ||= @eruby.new <<-EOF
|
462
|
-
|
487
|
+
<%#encoding:UTF-8%><% tags = template.class::QUOTED_TAGS[@type] %><%= tags.first %><%
|
463
488
|
if attr? :role %><phrase#{role}><%
|
464
489
|
end %><%= @text %><%
|
465
490
|
if attr? :role %></phrase><%
|
@@ -471,7 +496,7 @@ end
|
|
471
496
|
class InlineAnchorTemplate < ::Asciidoctor::BaseTemplate
|
472
497
|
def template
|
473
498
|
@template ||= @eruby.new <<-EOF
|
474
|
-
|
499
|
+
<%#encoding:UTF-8%><% if @type == :xref
|
475
500
|
%><%
|
476
501
|
if @text.nil?
|
477
502
|
%><xref linkend="<%= @target %>"/><%
|
@@ -480,6 +505,8 @@ class InlineAnchorTemplate < ::Asciidoctor::BaseTemplate
|
|
480
505
|
end %><%
|
481
506
|
elsif @type == :ref
|
482
507
|
%><anchor id="<%= @target %>" xreflabel="<%= @text %>"/><%
|
508
|
+
elsif @type == :bibref
|
509
|
+
%><anchor id="<%= @target %>" xreflabel="[<%= @target %>]"/>[<%= @target %>]<%
|
483
510
|
else
|
484
511
|
%><ulink url="<%= @target %>"><%= @text %></ulink><%
|
485
512
|
end %>
|
@@ -490,7 +517,7 @@ end
|
|
490
517
|
class InlineImageTemplate < ::Asciidoctor::BaseTemplate
|
491
518
|
def template
|
492
519
|
@template ||= @eruby.new <<-EOF
|
493
|
-
|
520
|
+
<%#encoding:UTF-8%><inlinemediaobject>
|
494
521
|
<imageobject>
|
495
522
|
<imagedata fileref="<%= image_uri(@target) %>"#{attribute('width', :width)}#{attribute('depth', :height)}/>
|
496
523
|
</imageobject>
|
@@ -500,11 +527,43 @@ class InlineImageTemplate < ::Asciidoctor::BaseTemplate
|
|
500
527
|
end
|
501
528
|
end
|
502
529
|
|
530
|
+
class InlineFootnoteTemplate < ::Asciidoctor::BaseTemplate
|
531
|
+
def template
|
532
|
+
@template ||= @eruby.new <<-EOS
|
533
|
+
<%#encoding:UTF-8%><%
|
534
|
+
if type == :xref
|
535
|
+
%><footnoteref linkend="<%= @target %>"/><%
|
536
|
+
else
|
537
|
+
%><footnote#{id}><simpara><%= @text %></simpara></footnote><%
|
538
|
+
end %>
|
539
|
+
EOS
|
540
|
+
end
|
541
|
+
end
|
542
|
+
|
503
543
|
class InlineCalloutTemplate < ::Asciidoctor::BaseTemplate
|
504
544
|
def template
|
505
545
|
@template ||= @eruby.new <<-EOF
|
506
|
-
|
546
|
+
<%#encoding:UTF-8%><co#{id}/>
|
507
547
|
EOF
|
508
548
|
end
|
509
549
|
end
|
550
|
+
|
551
|
+
class InlineIndextermTemplate < ::Asciidoctor::BaseTemplate
|
552
|
+
def template
|
553
|
+
@template ||= @eruby.new <<-EOS
|
554
|
+
<%#encoding:UTF-8%><% if type == :visible %><indexterm><primary><%= @text %></primary></indexterm><%= @text %><%
|
555
|
+
else %><% terms = (attr :terms); numterms = terms.size %><%
|
556
|
+
if numterms > 2 %><indexterm>
|
557
|
+
<primary><%= terms[0] %></primary><secondary><%= terms[1] %></secondary><tertiary><%= terms[2] %></tertiary>
|
558
|
+
</indexterm>
|
559
|
+
<% end %><%
|
560
|
+
if numterms > 1 %><indexterm>
|
561
|
+
<primary><%= terms[numterms - 2] %></primary><secondary><%= terms[numterms - 1] %></secondary>
|
562
|
+
</indexterm>
|
563
|
+
<% end %><indexterm>
|
564
|
+
<primary><%= terms[numterms - 1] %></primary>
|
565
|
+
</indexterm><% end %>
|
566
|
+
EOS
|
567
|
+
end
|
568
|
+
end
|
510
569
|
end
|