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.

Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +387 -0
  3. data/README.adoc +358 -348
  4. data/asciidoctor.gemspec +30 -9
  5. data/bin/asciidoctor +3 -0
  6. data/bin/asciidoctor-safe +3 -0
  7. data/compat/asciidoc.conf +76 -4
  8. data/lib/asciidoctor.rb +174 -79
  9. data/lib/asciidoctor/abstract_block.rb +131 -101
  10. data/lib/asciidoctor/abstract_node.rb +108 -26
  11. data/lib/asciidoctor/attribute_list.rb +1 -1
  12. data/lib/asciidoctor/backends/_stylesheets.rb +204 -62
  13. data/lib/asciidoctor/backends/base_template.rb +11 -22
  14. data/lib/asciidoctor/backends/docbook45.rb +158 -163
  15. data/lib/asciidoctor/backends/docbook5.rb +103 -0
  16. data/lib/asciidoctor/backends/html5.rb +662 -445
  17. data/lib/asciidoctor/block.rb +54 -44
  18. data/lib/asciidoctor/cli/invoker.rb +41 -20
  19. data/lib/asciidoctor/cli/options.rb +66 -20
  20. data/lib/asciidoctor/debug.rb +1 -1
  21. data/lib/asciidoctor/document.rb +265 -100
  22. data/lib/asciidoctor/extensions.rb +443 -0
  23. data/lib/asciidoctor/helpers.rb +38 -6
  24. data/lib/asciidoctor/inline.rb +5 -5
  25. data/lib/asciidoctor/lexer.rb +532 -250
  26. data/lib/asciidoctor/{list_item.rb → list.rb} +33 -13
  27. data/lib/asciidoctor/path_resolver.rb +28 -2
  28. data/lib/asciidoctor/reader.rb +814 -455
  29. data/lib/asciidoctor/renderer.rb +128 -42
  30. data/lib/asciidoctor/section.rb +55 -41
  31. data/lib/asciidoctor/substituters.rb +380 -107
  32. data/lib/asciidoctor/table.rb +40 -30
  33. data/lib/asciidoctor/version.rb +1 -1
  34. data/man/asciidoctor.1 +32 -96
  35. data/man/{asciidoctor.ad → asciidoctor.adoc} +57 -48
  36. data/test/attributes_test.rb +200 -27
  37. data/test/blocks_test.rb +361 -22
  38. data/test/document_test.rb +496 -81
  39. data/test/extensions_test.rb +448 -0
  40. data/test/fixtures/basic-docinfo-footer.html +6 -0
  41. data/test/fixtures/basic-docinfo-footer.xml +8 -0
  42. data/test/fixtures/basic-docinfo.xml +3 -3
  43. data/test/fixtures/basic.asciidoc +1 -0
  44. data/test/fixtures/child-include.adoc +5 -0
  45. data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +6 -0
  46. data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +1 -0
  47. data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +3 -0
  48. data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +5 -0
  49. data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +6 -0
  50. data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +3 -0
  51. data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +5 -0
  52. data/test/fixtures/docinfo-footer.html +1 -0
  53. data/test/fixtures/docinfo-footer.xml +9 -0
  54. data/test/fixtures/docinfo.xml +1 -0
  55. data/test/fixtures/grandchild-include.adoc +3 -0
  56. data/test/fixtures/parent-include-restricted.adoc +5 -0
  57. data/test/fixtures/parent-include.adoc +5 -0
  58. data/test/invoker_test.rb +82 -8
  59. data/test/lexer_test.rb +21 -3
  60. data/test/links_test.rb +34 -2
  61. data/test/lists_test.rb +304 -7
  62. data/test/options_test.rb +19 -3
  63. data/test/paragraphs_test.rb +13 -0
  64. data/test/paths_test.rb +22 -0
  65. data/test/preamble_test.rb +20 -0
  66. data/test/reader_test.rb +1096 -644
  67. data/test/renderer_test.rb +152 -12
  68. data/test/sections_test.rb +417 -76
  69. data/test/substitutions_test.rb +339 -138
  70. data/test/tables_test.rb +109 -4
  71. data/test/test_helper.rb +79 -13
  72. data/test/text_test.rb +111 -11
  73. 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, (attr 'role'), (attr 'reftext')) %>)
29
+ %q(<%= template.common_attrs(@id, role, reftext) %>)
30
30
  end
31
31
 
32
32
  def content(node)
33
- node.blocks? ? node.content.chomp : "<simpara>#{node.content.chomp}</simpara>"
33
+ node.blocks? ? node.content : "<simpara>#{node.content}</simpara>"
34
34
  end
35
35
 
36
36
  def content_erb
37
- %q(<%= blocks? ? content.chomp : "<simpara>#{content.chomp}</simpara>" %>)
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
- <subtitle>#{subtitle}</subtitle>)
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
- <% if has_header? && !notitle %>
56
- <%= template.title_tags(@header.title) %>
57
- <% end %>
58
- <% if attr? :revdate %>
59
- <date><%= attr :revdate %></date>
60
- <% else %>
61
- <date><%= attr :docdate %></date>
62
- <% end %>
63
- <% if has_header? %>
64
- <% if attr? :author %>
65
- <% if (attr :authorcount).to_i < 2 %>
66
- <author>
67
- #{tag 'firstname', :firstname}
68
- #{tag 'othername', :middlename}
69
- #{tag 'surname', :lastname}
70
- #{tag 'email', :email}
71
- </author>
72
- #{tag 'authorinitials', :authorinitials}
73
- <% else %>
74
- <authorgroup>
75
- <% (1..((attr :authorcount).to_i)).each do |idx| %>
76
- <author>
77
- #{tag 'firstname', :"firstname_\#{idx}", true}
78
- #{tag 'othername', :"middlename_\#{idx}", true}
79
- #{tag 'surname', :"lastname_\#{idx}", true}
80
- #{tag 'email', :"email_\#{idx}", true}
81
- </author>
82
- <% end %>
83
- </authorgroup>
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
- #{tag 'orgname', :orgname}
98
- <% end %>
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
- <% if attr? :toc %><?asciidoc-toc?><% end %>
107
- <% if attr? :numbered %><?asciidoc-numbered?><% end %>
108
- <% if doctype == 'book' %>
109
- <book<% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>>
110
- <bookinfo>
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
- </bookinfo>
113
- <%= content.chomp %>
114
- </book>
115
- <% else %>
116
- <article<% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>>
117
- <articleinfo>
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
- </articleinfo>
120
- <%= content.chomp %>
121
- </article>
122
- <% end %>
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.chomp %>
153
+ <%= content %>
149
154
  </preface><%
150
155
  else %>
151
- <%= content.chomp %><%
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, (sec.attr 'role'), (sec.attr 'reftext'))}>
169
+ %(<#{tag}#{common_attrs(sec.id, sec.role, sec.reftext)}>
165
170
  #{sec.title? ? "<title>#{sec.title}</title>" : nil}
166
- #{sec.content.chomp}
167
- </#{tag}>\n)
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>\n)
194
+ </formalpara>)
190
195
  else
191
- %(<simpara#{common_attrs(id, role, reftext)}>#{content}</simpara>\n)
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, (node.attr 'style', nil, false), (node.attr 'role'), (node.attr 'reftext'), (node.title? ? node.title : nil), node.content)
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%><% if attr? :style, 'bibliography' %>
218
- <bibliodiv#{common_attrs_erb}>#{title_tag}
219
- <% content.each do |li| %>
220
- <bibliomixed>
221
- <bibliomisc><%= li.text %></bibliomisc>
222
- <% if li.blocks? %>
223
- <%= li.content %>
224
- <% end %>
225
- </bibliomixed>
226
- <% end %>
227
- </bibliodiv>
228
- <% else %>
229
- <itemizedlist#{common_attrs_erb}>#{title_tag}
230
- <% content.each do |li| %>
231
- <listitem>
232
- <simpara><%= li.text %></simpara>
233
- <% if li.blocks? %>
234
- <%= li.content %>
235
- <% end %>
236
- </listitem>
237
- <% end %>
238
- </itemizedlist>
239
- <% end %>
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') ? '&#x25A0; ' : '&#x25A1; ') : 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', :style)}>#{title_tag}
248
- <% content.each do |li| %>
249
- <listitem>
250
- <simpara><%= li.text %></simpara>
251
- <% if li.blocks? %>
252
- <%= li.content %>
253
- <% end %>
254
- </listitem>
255
- <% end %>
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
- <% content.each do |li| %>
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
- continuing = false;
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
- entries.each_with_index do |(dt, dd), index|
316
- last = (index == last_index)
317
- unless continuing %>
320
+ items.each do |terms, dd| %>
318
321
  <row>
319
322
  <entry><%
320
- end %>
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.chomp %><%
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[attr :style] || template.class::LIST_TAGS['labeled'])
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
- entries.each_with_index do |(dt, dd), index|
352
- last = (index == last_index)
353
- unless continuing %>
347
+ items.each do |terms, dd| %>
354
348
  <<%= tags[:entry] %>><%
355
- end
356
- if tags.has_key?(:label)
357
- unless continuing %>
349
+ if tags.has_key? :label %>
358
350
  <<%= tags[:label] %>><%
359
- end %>
360
- <<%= tags[:term] %>><%= dt.text %></<%= tags[:term] %>><%
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 !last && dd.nil?
368
- continuing = true
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, (node.attr 'style', nil, false),
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
- puts 'asciidoctor: WARNING: abstract block cannot be used in a document without a title when doctype is book. Excluding block content.'
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>\n)
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
- puts 'asciidoctor: ERROR: partintro block can only be used when doctype is book and it\'s a child of a part section. Excluding block content.'
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>\n)
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 (attr? 'style', 'source') && (attr? 'language')
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 (attr? 'style', 'source') && (attr? 'language') %>
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="<%= (col.attr (attr? :width) ? :colabswidth : :colpcwidth) %>*"/>
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 (cell.attr :style)
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 => ['&#8216;', '&#8217;']
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, (node.attr 'role'))
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 id="#{target}" xreflabel="#{text}"/>)
693
+ %(<anchor#{common_attrs target, nil, text}/>)
705
694
  when :xref
706
- text.nil? ? %(<xref linkend="#{target}"/>) : %(<link linkend="#{target}">#{text}</link>)
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 id="#{target}" xreflabel="[#{target}]"/>[#{target}])
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#{id}><simpara><%= @text %></simpara></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 id="#{node.id}"/>)
746
+ %(<co#{common_attrs node.id, nil, nil}/>)
752
747
  end
753
748
 
754
749
  def template