asciidoctor 0.1.3 → 0.1.4
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 +4 -4
- data/CHANGELOG.adoc +387 -0
- data/README.adoc +358 -348
- data/asciidoctor.gemspec +30 -9
- data/bin/asciidoctor +3 -0
- data/bin/asciidoctor-safe +3 -0
- data/compat/asciidoc.conf +76 -4
- data/lib/asciidoctor.rb +174 -79
- data/lib/asciidoctor/abstract_block.rb +131 -101
- data/lib/asciidoctor/abstract_node.rb +108 -26
- data/lib/asciidoctor/attribute_list.rb +1 -1
- data/lib/asciidoctor/backends/_stylesheets.rb +204 -62
- data/lib/asciidoctor/backends/base_template.rb +11 -22
- data/lib/asciidoctor/backends/docbook45.rb +158 -163
- data/lib/asciidoctor/backends/docbook5.rb +103 -0
- data/lib/asciidoctor/backends/html5.rb +662 -445
- data/lib/asciidoctor/block.rb +54 -44
- data/lib/asciidoctor/cli/invoker.rb +41 -20
- data/lib/asciidoctor/cli/options.rb +66 -20
- data/lib/asciidoctor/debug.rb +1 -1
- data/lib/asciidoctor/document.rb +265 -100
- data/lib/asciidoctor/extensions.rb +443 -0
- data/lib/asciidoctor/helpers.rb +38 -6
- data/lib/asciidoctor/inline.rb +5 -5
- data/lib/asciidoctor/lexer.rb +532 -250
- data/lib/asciidoctor/{list_item.rb → list.rb} +33 -13
- data/lib/asciidoctor/path_resolver.rb +28 -2
- data/lib/asciidoctor/reader.rb +814 -455
- data/lib/asciidoctor/renderer.rb +128 -42
- data/lib/asciidoctor/section.rb +55 -41
- data/lib/asciidoctor/substituters.rb +380 -107
- data/lib/asciidoctor/table.rb +40 -30
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +32 -96
- data/man/{asciidoctor.ad → asciidoctor.adoc} +57 -48
- data/test/attributes_test.rb +200 -27
- data/test/blocks_test.rb +361 -22
- data/test/document_test.rb +496 -81
- data/test/extensions_test.rb +448 -0
- data/test/fixtures/basic-docinfo-footer.html +6 -0
- data/test/fixtures/basic-docinfo-footer.xml +8 -0
- data/test/fixtures/basic-docinfo.xml +3 -3
- data/test/fixtures/basic.asciidoc +1 -0
- data/test/fixtures/child-include.adoc +5 -0
- data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +6 -0
- data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +1 -0
- data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +3 -0
- data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +5 -0
- data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +6 -0
- data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +3 -0
- data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +5 -0
- data/test/fixtures/docinfo-footer.html +1 -0
- data/test/fixtures/docinfo-footer.xml +9 -0
- data/test/fixtures/docinfo.xml +1 -0
- data/test/fixtures/grandchild-include.adoc +3 -0
- data/test/fixtures/parent-include-restricted.adoc +5 -0
- data/test/fixtures/parent-include.adoc +5 -0
- data/test/invoker_test.rb +82 -8
- data/test/lexer_test.rb +21 -3
- data/test/links_test.rb +34 -2
- data/test/lists_test.rb +304 -7
- data/test/options_test.rb +19 -3
- data/test/paragraphs_test.rb +13 -0
- data/test/paths_test.rb +22 -0
- data/test/preamble_test.rb +20 -0
- data/test/reader_test.rb +1096 -644
- data/test/renderer_test.rb +152 -12
- data/test/sections_test.rb +417 -76
- data/test/substitutions_test.rb +339 -138
- data/test/tables_test.rb +109 -4
- data/test/test_helper.rb +79 -13
- data/test/text_test.rb +111 -11
- metadata +54 -18
@@ -22,19 +22,19 @@ module Asciidoctor
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def common_attrs(id, role, reftext)
|
25
|
-
%(#{id && " id=\"#{id}\""}#{role && " role=\"#{role}\""}#{reftext && " xreflabel=\"#{reftext}\""})
|
25
|
+
%(#{id && " #{@backend == 'docbook5' ? 'xml:id' : 'id'}=\"#{id}\""}#{role && " role=\"#{role}\""}#{reftext && " xreflabel=\"#{reftext}\""})
|
26
26
|
end
|
27
27
|
|
28
28
|
def common_attrs_erb
|
29
|
-
%q(<%= template.common_attrs(@id,
|
29
|
+
%q(<%= template.common_attrs(@id, role, reftext) %>)
|
30
30
|
end
|
31
31
|
|
32
32
|
def content(node)
|
33
|
-
node.blocks? ? node.content
|
33
|
+
node.blocks? ? node.content : "<simpara>#{node.content}</simpara>"
|
34
34
|
end
|
35
35
|
|
36
36
|
def content_erb
|
37
|
-
%q(<%= blocks? ? content
|
37
|
+
%q(<%= blocks? ? content : "<simpara>#{content}</simpara>" %>)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -44,7 +44,7 @@ class DocumentTemplate < BaseTemplate
|
|
44
44
|
if str.include?(': ')
|
45
45
|
title, _, subtitle = str.rpartition(': ')
|
46
46
|
%(<title>#{title}</title>
|
47
|
-
|
47
|
+
<subtitle>#{subtitle}</subtitle>)
|
48
48
|
else
|
49
49
|
%(<title>#{str}</title>)
|
50
50
|
end
|
@@ -52,74 +52,79 @@ class DocumentTemplate < BaseTemplate
|
|
52
52
|
|
53
53
|
def docinfo
|
54
54
|
<<-EOF
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
<% end %>
|
85
|
-
<% end %>
|
86
|
-
<% if (attr? :revnumber) || (attr? :revremark) %>
|
87
|
-
<revhistory>
|
88
|
-
<revision>
|
89
|
-
#{tag 'revnumber', :revnumber}
|
90
|
-
#{tag 'date', :revdate}
|
91
|
-
#{tag 'authorinitials', :authorinitials}
|
92
|
-
#{tag 'revremark', :revremark}
|
93
|
-
</revision>
|
94
|
-
</revhistory>
|
95
|
-
<% end %>
|
55
|
+
<% unless notitle %><%= has_header? ? template.title_tags(@header.title) : %(<title>\#{attr 'untitled-label'}</title>) %><% end
|
56
|
+
if attr? :revdate %>
|
57
|
+
<date><%= attr :revdate %></date><%
|
58
|
+
else %>
|
59
|
+
<date><%= attr :docdate %></date><%
|
60
|
+
end
|
61
|
+
if has_header?
|
62
|
+
if attr? :author
|
63
|
+
if (attr :authorcount).to_i < 2 %>
|
64
|
+
#{author}
|
65
|
+
#{tag 'authorinitials', :authorinitials}<%
|
66
|
+
else %>
|
67
|
+
<authorgroup><%
|
68
|
+
(1..((attr :authorcount).to_i)).each do |idx| %>
|
69
|
+
#{author true}<%
|
70
|
+
end %>
|
71
|
+
</authorgroup><%
|
72
|
+
end
|
73
|
+
end
|
74
|
+
if (attr? :revnumber) || (attr? :revremark) %>
|
75
|
+
<revhistory>
|
76
|
+
<revision>
|
77
|
+
#{tag 'revnumber', :revnumber}
|
78
|
+
#{tag 'date', :revdate}
|
79
|
+
#{tag 'authorinitials', :authorinitials}
|
80
|
+
#{tag 'revremark', :revremark}
|
81
|
+
</revision>
|
82
|
+
</revhistory><%
|
83
|
+
end %>
|
96
84
|
<%= docinfo %>
|
97
|
-
|
98
|
-
|
85
|
+
#{tag 'orgname', :orgname}<%
|
86
|
+
end %>
|
87
|
+
EOF
|
88
|
+
end
|
89
|
+
|
90
|
+
def author indexed = false
|
91
|
+
<<-EOF
|
92
|
+
<author>
|
93
|
+
#{tag 'firstname', indexed ? :"firstname_\#{idx}" : :firstname, indexed}
|
94
|
+
#{tag 'othername', indexed ? :"middlename_\#{idx}" : :middlename, indexed}
|
95
|
+
#{tag 'surname', indexed ? :"lastname_\#{idx}" : :lastname, indexed}
|
96
|
+
#{tag 'email', indexed ? :"email_\#{idx}" : :email, indexed}
|
97
|
+
</author>
|
99
98
|
EOF
|
100
99
|
end
|
101
100
|
|
102
101
|
def template
|
103
102
|
@template ||= @eruby.new <<-EOF
|
104
103
|
<%#encoding:UTF-8%><?xml version="1.0" encoding="UTF-8"?>
|
105
|
-
<!DOCTYPE <%= doctype %> PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
104
|
+
<!DOCTYPE <%= doctype %> PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"><%
|
105
|
+
if attr? :toc %>
|
106
|
+
<?asciidoc-toc?><%
|
107
|
+
end
|
108
|
+
if attr? :numbered %>
|
109
|
+
<?asciidoc-numbered?><%
|
110
|
+
end
|
111
|
+
if doctype == 'book' %>
|
112
|
+
<book<% unless attr? :noxmlns %> xmlns="http://docbook.org/ns/docbook"<% end %><% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>>
|
113
|
+
<bookinfo>
|
111
114
|
#{docinfo}
|
112
|
-
|
113
|
-
<%= content.
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
115
|
+
</bookinfo>
|
116
|
+
<%= content %><%= (docinfo_content = docinfo :footer).empty? ? nil : %(
|
117
|
+
\#{docinfo_content}) %>
|
118
|
+
</book><%
|
119
|
+
else %>
|
120
|
+
<article<% unless attr? :noxmlns %> xmlns="http://docbook.org/ns/docbook"<% end %><% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>>
|
121
|
+
<articleinfo>
|
118
122
|
#{docinfo}
|
119
|
-
|
120
|
-
<%= content.
|
121
|
-
|
122
|
-
|
123
|
+
</articleinfo>
|
124
|
+
<%= content %><%= (docinfo_content = docinfo :footer).empty? ? nil : %(
|
125
|
+
\#{docinfo_content}) %>
|
126
|
+
</article><%
|
127
|
+
end %>
|
123
128
|
EOF
|
124
129
|
end
|
125
130
|
end
|
@@ -145,10 +150,10 @@ class BlockPreambleTemplate < BaseTemplate
|
|
145
150
|
@template ||= @eruby.new <<-EOF
|
146
151
|
<%#encoding:UTF-8%><%
|
147
152
|
if @document.doctype == 'book' %><preface#{common_attrs_erb}>#{title_tag false}
|
148
|
-
<%= content
|
153
|
+
<%= content %>
|
149
154
|
</preface><%
|
150
155
|
else %>
|
151
|
-
<%= content
|
156
|
+
<%= content %><%
|
152
157
|
end %>
|
153
158
|
EOF
|
154
159
|
end
|
@@ -161,10 +166,10 @@ class SectionTemplate < BaseTemplate
|
|
161
166
|
else
|
162
167
|
tag = sec.document.doctype == 'book' && sec.level <= 1 ? (sec.level == 0 ? 'part' : 'chapter') : 'section'
|
163
168
|
end
|
164
|
-
%(<#{tag}#{common_attrs(sec.id,
|
169
|
+
%(<#{tag}#{common_attrs(sec.id, sec.role, sec.reftext)}>
|
165
170
|
#{sec.title? ? "<title>#{sec.title}</title>" : nil}
|
166
|
-
#{sec.content
|
167
|
-
</#{tag}
|
171
|
+
#{sec.content}
|
172
|
+
</#{tag}>)
|
168
173
|
end
|
169
174
|
|
170
175
|
def template
|
@@ -186,14 +191,14 @@ class BlockParagraphTemplate < BaseTemplate
|
|
186
191
|
%(<formalpara#{common_attrs(id, role, reftext)}>
|
187
192
|
<title>#{title}</title>
|
188
193
|
<para>#{content}</para>
|
189
|
-
</formalpara
|
194
|
+
</formalpara>)
|
190
195
|
else
|
191
|
-
%(<simpara#{common_attrs(id, role, reftext)}>#{content}</simpara
|
196
|
+
%(<simpara#{common_attrs(id, role, reftext)}>#{content}</simpara>)
|
192
197
|
end
|
193
198
|
end
|
194
199
|
|
195
200
|
def result(node)
|
196
|
-
paragraph(node.id,
|
201
|
+
paragraph(node.id, node.style, node.role, node.reftext, (node.title? ? node.title : nil), node.content)
|
197
202
|
end
|
198
203
|
|
199
204
|
def template
|
@@ -214,29 +219,32 @@ end
|
|
214
219
|
class BlockUlistTemplate < BaseTemplate
|
215
220
|
def template
|
216
221
|
@template ||= @eruby.new <<-EOF
|
217
|
-
<%#encoding:UTF-8%><%
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
222
|
+
<%#encoding:UTF-8%><%
|
223
|
+
if @style == 'bibliography'
|
224
|
+
%><bibliodiv#{common_attrs_erb}>#{title_tag}<%
|
225
|
+
items.each do |li| %>
|
226
|
+
<bibliomixed>
|
227
|
+
<bibliomisc><%= li.text %></bibliomisc><%
|
228
|
+
if li.blocks? %>
|
229
|
+
<%= li.content %><%
|
230
|
+
end %>
|
231
|
+
</bibliomixed><%
|
232
|
+
end %>
|
233
|
+
</bibliodiv><%
|
234
|
+
else
|
235
|
+
checklist = (option? 'checklist')
|
236
|
+
mark = checklist ? 'none' : @style
|
237
|
+
%><itemizedlist#{common_attrs_erb}<%= mark ? %( mark="\#{mark}") : nil %>>#{title_tag}<%
|
238
|
+
items.each do |li| %>
|
239
|
+
<listitem>
|
240
|
+
<simpara><%= checklist && (li.attr? 'checkbox') ? ((li.attr? 'checked') ? '■ ' : '□ ') : nil %><%= li.text %></simpara><%
|
241
|
+
if li.blocks? %>
|
242
|
+
<%= li.content %><%
|
243
|
+
end %>
|
244
|
+
</listitem><%
|
245
|
+
end %>
|
246
|
+
</itemizedlist><%
|
247
|
+
end %>
|
240
248
|
EOF
|
241
249
|
end
|
242
250
|
end
|
@@ -244,15 +252,15 @@ end
|
|
244
252
|
class BlockOlistTemplate < BaseTemplate
|
245
253
|
def template
|
246
254
|
@template ||= @eruby.new <<-EOF
|
247
|
-
<%#encoding:UTF-8%><orderedlist#{common_attrs_erb}#{attribute('numeration',
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
<%= li.content
|
253
|
-
|
254
|
-
|
255
|
-
|
255
|
+
<%#encoding:UTF-8%><orderedlist#{common_attrs_erb}#{attribute('numeration', '@style')}>#{title_tag}<%
|
256
|
+
items.each do |li| %>
|
257
|
+
<listitem>
|
258
|
+
<simpara><%= li.text %></simpara><%
|
259
|
+
if li.blocks? %>
|
260
|
+
<%= li.content %><%
|
261
|
+
end %>
|
262
|
+
</listitem><%
|
263
|
+
end %>
|
256
264
|
</orderedlist>
|
257
265
|
EOF
|
258
266
|
end
|
@@ -262,7 +270,7 @@ class BlockColistTemplate < BaseTemplate
|
|
262
270
|
def template
|
263
271
|
@template ||= @eruby.new <<-EOF
|
264
272
|
<%#encoding:UTF-8%><calloutlist#{common_attrs_erb}>#{title_tag}
|
265
|
-
<%
|
273
|
+
<% items.each do |li| %>
|
266
274
|
<callout arearefs="<%= li.attr :coids %>">
|
267
275
|
<para><%= li.text %></para>
|
268
276
|
<% if li.blocks? %>
|
@@ -303,27 +311,17 @@ class BlockDlistTemplate < BaseTemplate
|
|
303
311
|
# that change would drastically simplify this template
|
304
312
|
@template ||= @eruby.new <<-EOF
|
305
313
|
<%#encoding:UTF-8%><%
|
306
|
-
|
307
|
-
entries = content
|
308
|
-
last_index = entries.length - 1
|
309
|
-
if attr? :style, 'horizontal'
|
314
|
+
if @style == 'horizontal'
|
310
315
|
%><<%= (tag = title? ? 'table' : 'informaltable') %>#{common_attrs_erb} tabstyle="horizontal" frame="none" colsep="0" rowsep="0">#{title_tag}
|
311
316
|
<tgroup cols="2">
|
312
317
|
<colspec colwidth="<%= attr :labelwidth, 15 %>*"/>
|
313
318
|
<colspec colwidth="<%= attr :labelwidth, 85 %>*"/>
|
314
319
|
<tbody valign="top"><%
|
315
|
-
|
316
|
-
last = (index == last_index)
|
317
|
-
unless continuing %>
|
320
|
+
items.each do |terms, dd| %>
|
318
321
|
<row>
|
319
322
|
<entry><%
|
320
|
-
|
323
|
+
[*terms].each do |dt| %>
|
321
324
|
<simpara><%= dt.text %></simpara><%
|
322
|
-
if !last && dd.nil?
|
323
|
-
continuing = true
|
324
|
-
next
|
325
|
-
else
|
326
|
-
continuing = false
|
327
325
|
end %>
|
328
326
|
</entry>
|
329
327
|
<entry><%
|
@@ -332,43 +330,30 @@ if attr? :style, 'horizontal'
|
|
332
330
|
<simpara><%= dd.text %></simpara><%
|
333
331
|
end
|
334
332
|
if dd.blocks? %>
|
335
|
-
<%= dd.content
|
333
|
+
<%= dd.content %><%
|
336
334
|
end
|
337
335
|
end %>
|
338
|
-
</entry
|
339
|
-
if last || !dd.nil? %>
|
336
|
+
</entry>
|
340
337
|
</row><%
|
341
|
-
end %><%
|
342
338
|
end %>
|
343
339
|
</tbody>
|
344
340
|
</tgroup>
|
345
341
|
</<%= tag %>><%
|
346
342
|
else
|
347
|
-
tags = (template.class::LIST_TAGS[
|
343
|
+
tags = (template.class::LIST_TAGS[@style] || template.class::LIST_TAGS['labeled'])
|
348
344
|
if tags[:list]
|
349
345
|
%><<%= tags[:list] %>#{common_attrs_erb}>#{title_tag}<%
|
350
346
|
end
|
351
|
-
|
352
|
-
last = (index == last_index)
|
353
|
-
unless continuing %>
|
347
|
+
items.each do |terms, dd| %>
|
354
348
|
<<%= tags[:entry] %>><%
|
355
|
-
|
356
|
-
if tags.has_key?(:label)
|
357
|
-
unless continuing %>
|
349
|
+
if tags.has_key? :label %>
|
358
350
|
<<%= tags[:label] %>><%
|
359
|
-
|
360
|
-
|
361
|
-
if last || !dd.nil? %>
|
362
|
-
</<%= tags[:label] %>><%
|
363
|
-
end
|
364
|
-
else %>
|
351
|
+
end
|
352
|
+
[*terms].each do |dt| %>
|
365
353
|
<<%= tags[:term] %>><%= dt.text %></<%= tags[:term] %>><%
|
366
354
|
end
|
367
|
-
if
|
368
|
-
|
369
|
-
next
|
370
|
-
else
|
371
|
-
continuing = false
|
355
|
+
if tags.has_key? :label %>
|
356
|
+
</<%= tags[:label] %>><%
|
372
357
|
end %>
|
373
358
|
<<%= tags[:item] %>><%
|
374
359
|
unless dd.nil?
|
@@ -392,29 +377,28 @@ end
|
|
392
377
|
|
393
378
|
class BlockOpenTemplate < BaseTemplate
|
394
379
|
def result(node)
|
395
|
-
open_block(node, node.id,
|
396
|
-
(node.attr 'role'), (node.attr 'reftext'), node.title? ? node.title : nil)
|
380
|
+
open_block(node, node.id, node.style, node.role, node.reftext, node.title? ? node.title : nil)
|
397
381
|
end
|
398
382
|
|
399
383
|
def open_block(node, id, style, role, reftext, title)
|
400
384
|
case style
|
401
385
|
when 'abstract'
|
402
386
|
if node.parent == node.document && node.document.attr?('doctype', 'book')
|
403
|
-
|
387
|
+
warn 'asciidoctor: WARNING: abstract block cannot be used in a document without a title when doctype is book. Excluding block content.'
|
404
388
|
''
|
405
389
|
else
|
406
390
|
%(<abstract>#{title && "\n<title>#{title}</title>"}
|
407
391
|
#{content node}
|
408
|
-
</abstract
|
392
|
+
</abstract>)
|
409
393
|
end
|
410
394
|
when 'partintro'
|
411
395
|
unless node.document.attr?('doctype', 'book') && node.parent.is_a?(Asciidoctor::Section) && node.level == 0
|
412
|
-
|
396
|
+
warn 'asciidoctor: ERROR: partintro block can only be used when doctype is book and it\'s a child of a part section. Excluding block content.'
|
413
397
|
''
|
414
398
|
else
|
415
399
|
%(<partintro#{common_attrs id, role, reftext}>#{title && "\n<title>#{title}</title>"}
|
416
400
|
#{content node}
|
417
|
-
</partintro
|
401
|
+
</partintro>)
|
418
402
|
end
|
419
403
|
else
|
420
404
|
node.content
|
@@ -431,7 +415,7 @@ class BlockListingTemplate < BaseTemplate
|
|
431
415
|
@template ||= @eruby.new <<-EOF
|
432
416
|
<%#encoding:UTF-8%><%
|
433
417
|
if !title?
|
434
|
-
if
|
418
|
+
if @style == 'source' && (attr? 'language')
|
435
419
|
%><programlisting#{common_attrs_erb}#{attribute('language', :language)} linenumbering="<%= (attr? :linenums) ? 'numbered' : 'unnumbered' %>"><%= template.preserve_endlines(content, self) %></programlisting><%
|
436
420
|
else
|
437
421
|
%><screen#{common_attrs_erb}><%= template.preserve_endlines(content, self) %></screen><%
|
@@ -439,7 +423,7 @@ if !title?
|
|
439
423
|
else
|
440
424
|
%><formalpara#{common_attrs_erb}>#{title_tag false}
|
441
425
|
<para><%
|
442
|
-
if
|
426
|
+
if @style == 'source' && (attr? 'language') %>
|
443
427
|
<programlisting language="<%= attr 'language' %>" linenumbering="<%= (attr? :linenums) ? 'numbered' : 'unnumbered' %>"><%= template.preserve_endlines(content, self) %></programlisting><%
|
444
428
|
else %>
|
445
429
|
<screen><%= template.preserve_endlines(content, self) %></screen><%
|
@@ -541,7 +525,7 @@ class BlockTableTemplate < BaseTemplate
|
|
541
525
|
<% end %>
|
542
526
|
<tgroup cols="<%= attr :colcount %>">
|
543
527
|
<% @columns.each do |col| %>
|
544
|
-
<colspec colname="col_<%= col.attr :colnumber %>" colwidth="<%=
|
528
|
+
<colspec colname="col_<%= col.attr :colnumber %>" colwidth="<%= col.attr((attr? :width) ? :colabswidth : :colpcwidth) %>*"/>
|
545
529
|
<% end %>
|
546
530
|
<% [:head, :foot, :body].select {|tblsec| !rows[tblsec].empty? }.each do |tblsec| %>
|
547
531
|
<t<%= tblsec %>>
|
@@ -554,7 +538,7 @@ class BlockTableTemplate < BaseTemplate
|
|
554
538
|
cell_content = ''
|
555
539
|
if tblsec == :head %><% cell_content = cell.text %><%
|
556
540
|
else %><%
|
557
|
-
case
|
541
|
+
case cell.style
|
558
542
|
when :asciidoc %><% cell_content = cell.content %><%
|
559
543
|
when :verse %><% cell_content = %(<literallayout>\#{template.preserve_endlines(cell.text, self)}</literallayout>) %><%
|
560
544
|
when :literal %><% cell_content = %(<literallayout class="monospaced">\#{template.preserve_endlines(cell.text, self)}</literallayout>) %><%
|
@@ -620,7 +604,7 @@ class InlineBreakTemplate < BaseTemplate
|
|
620
604
|
end
|
621
605
|
|
622
606
|
class InlineQuotedTemplate < BaseTemplate
|
623
|
-
NO_TAGS = [
|
607
|
+
NO_TAGS = [nil, nil]
|
624
608
|
|
625
609
|
QUOTED_TAGS = {
|
626
610
|
:emphasis => ['<emphasis>', '</emphasis>'],
|
@@ -632,17 +616,22 @@ class InlineQuotedTemplate < BaseTemplate
|
|
632
616
|
:single => ['‘', '’']
|
633
617
|
}
|
634
618
|
|
635
|
-
def quote_text(text, type, role)
|
619
|
+
def quote_text(text, type, id, role)
|
636
620
|
start_tag, end_tag = QUOTED_TAGS[type] || NO_TAGS
|
621
|
+
anchor = id.nil? ? nil : %(<anchor#{common_attrs id, nil, text}/>)
|
637
622
|
if role
|
638
|
-
"#{start_tag}<phrase role=\"#{role}\">#{text}</phrase>#{end_tag}"
|
623
|
+
quoted_text = "#{start_tag}<phrase role=\"#{role}\">#{text}</phrase>#{end_tag}"
|
624
|
+
elsif start_tag.nil?
|
625
|
+
quoted_text = text
|
639
626
|
else
|
640
|
-
"#{start_tag}#{text}#{end_tag}"
|
627
|
+
quoted_text = "#{start_tag}#{text}#{end_tag}"
|
641
628
|
end
|
629
|
+
|
630
|
+
anchor.nil? ? quoted_text : %(#{anchor}#{quoted_text})
|
642
631
|
end
|
643
632
|
|
644
633
|
def result(node)
|
645
|
-
quote_text(node.text, node.type,
|
634
|
+
quote_text(node.text, node.type, node.id, node.role)
|
646
635
|
end
|
647
636
|
|
648
637
|
def template
|
@@ -698,21 +687,27 @@ class InlineMenuTemplate < BaseTemplate
|
|
698
687
|
end
|
699
688
|
|
700
689
|
class InlineAnchorTemplate < BaseTemplate
|
701
|
-
def anchor(target, text, type)
|
690
|
+
def anchor(target, text, type, node)
|
702
691
|
case type
|
703
692
|
when :ref
|
704
|
-
%(<anchor
|
693
|
+
%(<anchor#{common_attrs target, nil, text}/>)
|
705
694
|
when :xref
|
706
|
-
|
695
|
+
if node.attr? 'path', nil
|
696
|
+
linkend = (node.attr 'fragment') || target
|
697
|
+
text.nil? ? %(<xref linkend="#{linkend}"/>) : %(<link linkend="#{linkend}">#{text}</link>)
|
698
|
+
else
|
699
|
+
text = text || (node.attr 'path')
|
700
|
+
%(<ulink url="#{target}">#{text}</ulink>)
|
701
|
+
end
|
707
702
|
when :link
|
708
703
|
%(<ulink url="#{target}">#{text}</ulink>)
|
709
704
|
when :bibref
|
710
|
-
%(<anchor
|
705
|
+
%(<anchor#{common_attrs target, nil, "[#{target}]"}/>[#{target}])
|
711
706
|
end
|
712
707
|
end
|
713
708
|
|
714
709
|
def result(node)
|
715
|
-
anchor(node.target, node.text, node.type)
|
710
|
+
anchor(node.target, node.text, node.type, node)
|
716
711
|
end
|
717
712
|
|
718
713
|
def template
|
@@ -725,7 +720,7 @@ class InlineImageTemplate < BaseTemplate
|
|
725
720
|
@template ||= @eruby.new <<-EOF
|
726
721
|
<%#encoding:UTF-8%><inlinemediaobject>
|
727
722
|
<imageobject>
|
728
|
-
<imagedata fileref="<%= image_uri(@target) %>"#{attribute('width', :width)}#{attribute('depth', :height)}/>
|
723
|
+
<imagedata fileref="<%= @type == 'icon' ? icon_uri(@target) : image_uri(@target) %>"#{attribute('width', :width)}#{attribute('depth', :height)}/>
|
729
724
|
</imageobject>
|
730
725
|
<textobject><phrase><%= attr :alt %></phrase></textobject>
|
731
726
|
</inlinemediaobject>
|
@@ -740,7 +735,7 @@ class InlineFootnoteTemplate < BaseTemplate
|
|
740
735
|
if @type == :xref
|
741
736
|
%><footnoteref linkend="<%= @target %>"/><%
|
742
737
|
else
|
743
|
-
%><footnote
|
738
|
+
%><footnote<%= template.common_attrs(@id, nil, nil) %>><simpara><%= @text %></simpara></footnote><%
|
744
739
|
end %>
|
745
740
|
EOS
|
746
741
|
end
|
@@ -748,7 +743,7 @@ end
|
|
748
743
|
|
749
744
|
class InlineCalloutTemplate < BaseTemplate
|
750
745
|
def result(node)
|
751
|
-
%(<co
|
746
|
+
%(<co#{common_attrs node.id, nil, nil}/>)
|
752
747
|
end
|
753
748
|
|
754
749
|
def template
|