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
@@ -8,7 +8,7 @@ context 'Substitutions' do
8
8
  test 'apply normal substitutions' do
9
9
  para = block_from_string("[blue]'http://asciidoc.org[AsciiDoc]' & [red]*Ruby*\n&#167; Making +++<u>documentation</u>+++ together +\nsince (C) {inception_year}.")
10
10
  para.document.attributes['inception_year'] = '2012'
11
- result = para.apply_normal_subs(para.buffer)
11
+ result = para.apply_normal_subs(para.lines)
12
12
  assert_equal %{<em class="blue"><a href="http://asciidoc.org">AsciiDoc</a></em> &amp; <strong class="red">Ruby</strong>\n&#167; Making <u>documentation</u> together<br>\nsince &#169; 2012.}, result
13
13
  end
14
14
  end
@@ -16,386 +16,525 @@ context 'Substitutions' do
16
16
  context 'Quotes' do
17
17
  test 'single-line double-quoted string' do
18
18
  para = block_from_string(%q{``a few quoted words''})
19
- assert_equal '&#8220;a few quoted words&#8221;', para.sub_quotes(para.buffer.join)
19
+ assert_equal '&#8220;a few quoted words&#8221;', para.sub_quotes(para.source)
20
20
  end
21
21
 
22
22
  test 'escaped single-line double-quoted string' do
23
23
  para = block_from_string(%q{\``a few quoted words''})
24
- assert_equal %q(&#8216;`a few quoted words&#8217;'), para.sub_quotes(para.buffer.join)
24
+ assert_equal %q(&#8216;`a few quoted words&#8217;'), para.sub_quotes(para.source)
25
25
  end
26
26
 
27
27
  test 'multi-line double-quoted string' do
28
28
  para = block_from_string(%Q{``a few\nquoted words''})
29
- assert_equal "&#8220;a few\nquoted words&#8221;", para.sub_quotes(para.buffer.join)
29
+ assert_equal "&#8220;a few\nquoted words&#8221;", para.sub_quotes(para.source)
30
30
  end
31
31
 
32
32
  test 'double-quoted string with inline single quote' do
33
33
  para = block_from_string(%q{``Here's Johnny!''})
34
- assert_equal %q{&#8220;Here's Johnny!&#8221;}, para.sub_quotes(para.buffer.join)
34
+ assert_equal %q{&#8220;Here's Johnny!&#8221;}, para.sub_quotes(para.source)
35
35
  end
36
36
 
37
37
  test 'double-quoted string with inline backquote' do
38
38
  para = block_from_string(%q{``Here`s Johnny!''})
39
- assert_equal %q{&#8220;Here`s Johnny!&#8221;}, para.sub_quotes(para.buffer.join)
39
+ assert_equal %q{&#8220;Here`s Johnny!&#8221;}, para.sub_quotes(para.source)
40
40
  end
41
41
 
42
42
  test 'single-line single-quoted string' do
43
43
  para = block_from_string(%q{`a few quoted words'})
44
- assert_equal '&#8216;a few quoted words&#8217;', para.sub_quotes(para.buffer.join)
44
+ assert_equal '&#8216;a few quoted words&#8217;', para.sub_quotes(para.source)
45
45
  end
46
46
 
47
47
  test 'escaped single-line single-quoted string' do
48
48
  para = block_from_string(%q{\`a few quoted words'})
49
- assert_equal %(`a few quoted words'), para.sub_quotes(para.buffer.join)
49
+ assert_equal %(`a few quoted words'), para.sub_quotes(para.source)
50
50
  end
51
51
 
52
52
  test 'multi-line single-quoted string' do
53
53
  para = block_from_string(%Q{`a few\nquoted words'})
54
- assert_equal "&#8216;a few\nquoted words&#8217;", para.sub_quotes(para.buffer.join)
54
+ assert_equal "&#8216;a few\nquoted words&#8217;", para.sub_quotes(para.source)
55
55
  end
56
56
 
57
57
  test 'single-quoted string with inline single quote' do
58
58
  para = block_from_string(%q{`That isn't what I did.'})
59
- assert_equal %q{&#8216;That isn't what I did.&#8217;}, para.sub_quotes(para.buffer.join)
59
+ assert_equal %q{&#8216;That isn't what I did.&#8217;}, para.sub_quotes(para.source)
60
60
  end
61
61
 
62
62
  test 'single-quoted string with inline backquote' do
63
63
  para = block_from_string(%q{`Here`s Johnny!'})
64
- assert_equal %q{&#8216;Here`s Johnny!&#8217;}, para.sub_quotes(para.buffer.join)
64
+ assert_equal %q{&#8216;Here`s Johnny!&#8217;}, para.sub_quotes(para.source)
65
65
  end
66
66
 
67
67
  test 'single-line constrained unquoted string' do
68
68
  para = block_from_string(%q{#a few words#})
69
- assert_equal 'a few words', para.sub_quotes(para.buffer.join)
69
+ assert_equal 'a few words', para.sub_quotes(para.source)
70
70
  end
71
71
 
72
72
  test 'escaped single-line constrained unquoted string' do
73
73
  para = block_from_string(%q{\#a few words#})
74
- assert_equal '#a few words#', para.sub_quotes(para.buffer.join)
74
+ assert_equal '#a few words#', para.sub_quotes(para.source)
75
75
  end
76
76
 
77
77
  test 'multi-line constrained unquoted string' do
78
78
  para = block_from_string(%Q{#a few\nwords#})
79
- assert_equal "a few\nwords", para.sub_quotes(para.buffer.join)
79
+ assert_equal "a few\nwords", para.sub_quotes(para.source)
80
80
  end
81
81
 
82
82
  test 'single-line unconstrained unquoted string' do
83
83
  para = block_from_string(%q{##--anything goes ##})
84
- assert_equal '--anything goes ', para.sub_quotes(para.buffer.join)
84
+ assert_equal '--anything goes ', para.sub_quotes(para.source)
85
85
  end
86
86
 
87
87
  test 'escaped single-line unconstrained unquoted string' do
88
88
  para = block_from_string(%q{\##--anything goes ##})
89
- assert_equal '#--anything goes #', para.sub_quotes(para.buffer.join)
89
+ assert_equal '#--anything goes #', para.sub_quotes(para.source)
90
90
  end
91
91
 
92
92
  test 'multi-line unconstrained unquoted string' do
93
93
  para = block_from_string(%Q{##--anything\ngoes ##})
94
- assert_equal "--anything\ngoes ", para.sub_quotes(para.buffer.join)
94
+ assert_equal "--anything\ngoes ", para.sub_quotes(para.source)
95
95
  end
96
96
 
97
97
  test 'single-line constrained strong string' do
98
98
  para = block_from_string(%q{*a few strong words*})
99
- assert_equal '<strong>a few strong words</strong>', para.sub_quotes(para.buffer.join)
99
+ assert_equal '<strong>a few strong words</strong>', para.sub_quotes(para.source)
100
100
  end
101
101
 
102
102
  test 'escaped single-line constrained strong string' do
103
103
  para = block_from_string(%q{\*a few strong words*})
104
- assert_equal '*a few strong words*', para.sub_quotes(para.buffer.join)
104
+ assert_equal '*a few strong words*', para.sub_quotes(para.source)
105
105
  end
106
106
 
107
107
  test 'multi-line constrained strong string' do
108
108
  para = block_from_string(%Q{*a few\nstrong words*})
109
- assert_equal "<strong>a few\nstrong words</strong>", para.sub_quotes(para.buffer.join)
109
+ assert_equal "<strong>a few\nstrong words</strong>", para.sub_quotes(para.source)
110
110
  end
111
111
 
112
112
  test 'constrained strong string containing an asterisk' do
113
113
  para = block_from_string(%q{*bl*ck*-eye})
114
- assert_equal '<strong>bl*ck</strong>-eye', para.sub_quotes(para.buffer.join)
114
+ assert_equal '<strong>bl*ck</strong>-eye', para.sub_quotes(para.source)
115
115
  end
116
116
 
117
117
  test 'single-line constrained quote variation emphasized string' do
118
118
  para = block_from_string(%q{'a few emphasized words'})
119
- assert_equal '<em>a few emphasized words</em>', para.sub_quotes(para.buffer.join)
119
+ assert_equal '<em>a few emphasized words</em>', para.sub_quotes(para.source)
120
120
  end
121
121
 
122
122
  test 'escaped single-line constrained quote variation emphasized string' do
123
123
  para = block_from_string(%q{\'a few emphasized words'})
124
- assert_equal %q('a few emphasized words'), para.sub_quotes(para.buffer.join)
124
+ assert_equal %q('a few emphasized words'), para.sub_quotes(para.source)
125
125
  end
126
126
 
127
127
  test 'multi-line constrained emphasized quote variation string' do
128
128
  para = block_from_string(%Q{'a few\nemphasized words'})
129
- assert_equal "<em>a few\nemphasized words</em>", para.sub_quotes(para.buffer.join)
129
+ assert_equal "<em>a few\nemphasized words</em>", para.sub_quotes(para.source)
130
130
  end
131
131
 
132
132
  test 'single-quoted string containing an emphasized phrase' do
133
133
  para = block_from_string(%q{`I told him, 'Just go for it!''})
134
- assert_equal '&#8216;I told him, <em>Just go for it!</em>&#8217;', para.sub_quotes(para.buffer.join)
134
+ assert_equal '&#8216;I told him, <em>Just go for it!</em>&#8217;', para.sub_quotes(para.source)
135
135
  end
136
136
 
137
137
  test 'escaped single-quotes inside emphasized words are restored' do
138
138
  para = block_from_string(%q{'Here\'s Johnny!'})
139
139
  # NOTE the \' is replaced with ' by the :replacements substitution, later in the substitution pipeline
140
- assert_equal %q{<em>Here\'s Johnny!</em>}, para.sub_quotes(para.buffer.join)
140
+ assert_equal %q{<em>Here\'s Johnny!</em>}, para.sub_quotes(para.source)
141
141
  end
142
142
 
143
143
  test 'single-line constrained emphasized underline variation string' do
144
144
  para = block_from_string(%q{_a few emphasized words_})
145
- assert_equal '<em>a few emphasized words</em>', para.sub_quotes(para.buffer.join)
145
+ assert_equal '<em>a few emphasized words</em>', para.sub_quotes(para.source)
146
146
  end
147
147
 
148
148
  test 'escaped single-line constrained emphasized underline variation string' do
149
149
  para = block_from_string(%q{\_a few emphasized words_})
150
- assert_equal '_a few emphasized words_', para.sub_quotes(para.buffer.join)
150
+ assert_equal '_a few emphasized words_', para.sub_quotes(para.source)
151
151
  end
152
152
 
153
153
  test 'multi-line constrained emphasized underline variation string' do
154
154
  para = block_from_string(%Q{_a few\nemphasized words_})
155
- assert_equal "<em>a few\nemphasized words</em>", para.sub_quotes(para.buffer.join)
155
+ assert_equal "<em>a few\nemphasized words</em>", para.sub_quotes(para.source)
156
156
  end
157
157
 
158
158
  test 'single-line constrained monospaced string' do
159
159
  para = block_from_string(%q{`a few <\{monospaced\}> words`})
160
160
  # NOTE must use apply_normal_subs because constrained monospaced is handled as a passthrough
161
- assert_equal '<code>a few &lt;{monospaced}&gt; words</code>', para.apply_normal_subs(para.buffer)
161
+ assert_equal '<code>a few &lt;{monospaced}&gt; words</code>', para.apply_normal_subs(para.lines)
162
+ end
163
+
164
+ test 'single-line constrained monospaced string with role' do
165
+ para = block_from_string(%q{[input]`a few <\{monospaced\}> words`})
166
+ # NOTE must use apply_normal_subs because constrained monospaced is handled as a passthrough
167
+ assert_equal '<code class="input">a few &lt;{monospaced}&gt; words</code>', para.apply_normal_subs(para.lines)
162
168
  end
163
169
 
164
170
  test 'escaped single-line constrained monospaced string' do
165
171
  para = block_from_string(%q{\`a few <monospaced> words`})
166
172
  # NOTE must use apply_normal_subs because constrained monospaced is handled as a passthrough
167
- assert_equal '`a few &lt;monospaced&gt; words`', para.apply_normal_subs(para.buffer)
173
+ assert_equal '`a few &lt;monospaced&gt; words`', para.apply_normal_subs(para.lines)
174
+ end
175
+
176
+ test 'escaped single-line constrained monospaced string with role' do
177
+ para = block_from_string(%q{[input]\`a few <monospaced> words`})
178
+ # NOTE must use apply_normal_subs because constrained monospaced is handled as a passthrough
179
+ assert_equal '[input]`a few &lt;monospaced&gt; words`', para.apply_normal_subs(para.lines)
180
+ end
181
+
182
+ test 'escaped role on single-line constrained monospaced string' do
183
+ para = block_from_string(%q{\[input]`a few <monospaced> words`})
184
+ # NOTE must use apply_normal_subs because constrained monospaced is handled as a passthrough
185
+ assert_equal '[input]<code>a few &lt;monospaced&gt; words</code>', para.apply_normal_subs(para.lines)
186
+ end
187
+
188
+ test 'escaped role on escaped single-line constrained monospaced string' do
189
+ para = block_from_string(%q{\[input]\`a few <monospaced> words`})
190
+ # NOTE must use apply_normal_subs because constrained monospaced is handled as a passthrough
191
+ assert_equal '\[input]`a few &lt;monospaced&gt; words`', para.apply_normal_subs(para.lines)
168
192
  end
169
193
 
170
194
  test 'multi-line constrained monospaced string' do
171
195
  para = block_from_string(%Q{`a few\n<\{monospaced\}> words`})
172
196
  # NOTE must use apply_normal_subs because constrained monospaced is handled as a passthrough
173
- assert_equal "<code>a few\n&lt;{monospaced}&gt; words</code>", para.apply_normal_subs(para.buffer)
197
+ assert_equal "<code>a few\n&lt;{monospaced}&gt; words</code>", para.apply_normal_subs(para.lines)
174
198
  end
175
199
 
176
200
  test 'single-line unconstrained strong chars' do
177
201
  para = block_from_string(%q{**Git**Hub})
178
- assert_equal '<strong>Git</strong>Hub', para.sub_quotes(para.buffer.join)
202
+ assert_equal '<strong>Git</strong>Hub', para.sub_quotes(para.source)
179
203
  end
180
204
 
181
205
  test 'escaped single-line unconstrained strong chars' do
182
206
  para = block_from_string(%q{\**Git**Hub})
183
- assert_equal '<strong>*Git</strong>*Hub', para.sub_quotes(para.buffer.join)
207
+ assert_equal '<strong>*Git</strong>*Hub', para.sub_quotes(para.source)
184
208
  end
185
209
 
186
210
  test 'multi-line unconstrained strong chars' do
187
211
  para = block_from_string(%Q{**G\ni\nt\n**Hub})
188
- assert_equal "<strong>G\ni\nt\n</strong>Hub", para.sub_quotes(para.buffer.join)
212
+ assert_equal "<strong>G\ni\nt\n</strong>Hub", para.sub_quotes(para.source)
189
213
  end
190
214
 
191
215
  test 'unconstrained strong chars with inline asterisk' do
192
216
  para = block_from_string(%q{**bl*ck**-eye})
193
- assert_equal '<strong>bl*ck</strong>-eye', para.sub_quotes(para.buffer.join)
217
+ assert_equal '<strong>bl*ck</strong>-eye', para.sub_quotes(para.source)
194
218
  end
195
219
 
196
220
  test 'unconstrained strong chars with role' do
197
221
  para = block_from_string(%q{Git[blue]**Hub**})
198
- assert_equal %q{Git<strong class="blue">Hub</strong>}, para.sub_quotes(para.buffer.join)
222
+ assert_equal %q{Git<strong class="blue">Hub</strong>}, para.sub_quotes(para.source)
199
223
  end
200
224
 
201
225
  # TODO this is not the same result as AsciiDoc, though I don't understand why AsciiDoc gets what it gets
202
226
  test 'escaped unconstrained strong chars with role' do
203
227
  para = block_from_string(%q{Git\[blue]**Hub**})
204
- assert_equal %q{Git[blue]<strong>*Hub</strong>*}, para.sub_quotes(para.buffer.join)
228
+ assert_equal %q{Git[blue]<strong>*Hub</strong>*}, para.sub_quotes(para.source)
205
229
  end
206
230
 
207
231
  test 'single-line unconstrained emphasized chars' do
208
232
  para = block_from_string(%q{__Git__Hub})
209
- assert_equal '<em>Git</em>Hub', para.sub_quotes(para.buffer.join)
233
+ assert_equal '<em>Git</em>Hub', para.sub_quotes(para.source)
210
234
  end
211
235
 
212
236
  test 'escaped single-line unconstrained emphasized chars' do
213
237
  para = block_from_string(%q{\__Git__Hub})
214
- assert_equal '__Git__Hub', para.sub_quotes(para.buffer.join)
238
+ assert_equal '__Git__Hub', para.sub_quotes(para.source)
215
239
  end
216
240
 
217
241
  test 'multi-line unconstrained emphasized chars' do
218
242
  para = block_from_string(%Q{__G\ni\nt\n__Hub})
219
- assert_equal "<em>G\ni\nt\n</em>Hub", para.sub_quotes(para.buffer.join)
243
+ assert_equal "<em>G\ni\nt\n</em>Hub", para.sub_quotes(para.source)
220
244
  end
221
245
 
222
246
  test 'unconstrained emphasis chars with role' do
223
247
  para = block_from_string(%q{[gray]__Git__Hub})
224
- assert_equal %q{<em class="gray">Git</em>Hub}, para.sub_quotes(para.buffer.join)
248
+ assert_equal %q{<em class="gray">Git</em>Hub}, para.sub_quotes(para.source)
225
249
  end
226
250
 
227
251
  test 'escaped unconstrained emphasis chars with role' do
228
252
  para = block_from_string(%q{\[gray]__Git__Hub})
229
- assert_equal %q{[gray]__Git__Hub}, para.sub_quotes(para.buffer.join)
253
+ assert_equal %q{[gray]__Git__Hub}, para.sub_quotes(para.source)
254
+ end
255
+
256
+ test 'single-line constrained monospaced chars' do
257
+ para = block_from_string(%q{call +save()+ to persist the changes})
258
+ assert_equal 'call <code>save()</code> to persist the changes', para.sub_quotes(para.source)
259
+ end
260
+
261
+ test 'single-line constrained monospaced chars with role' do
262
+ para = block_from_string(%q{call [method]+save()+ to persist the changes})
263
+ assert_equal 'call <code class="method">save()</code> to persist the changes', para.sub_quotes(para.source)
264
+ end
265
+
266
+ test 'escaped single-line constrained monospaced chars' do
267
+ para = block_from_string(%q{call \+save()+ to persist the changes})
268
+ assert_equal 'call +save()+ to persist the changes', para.sub_quotes(para.source)
269
+ end
270
+
271
+ test 'escaped single-line constrained monospaced chars with role' do
272
+ para = block_from_string(%q{call [method]\+save()+ to persist the changes})
273
+ assert_equal 'call [method]+save()+ to persist the changes', para.sub_quotes(para.source)
274
+ end
275
+
276
+ test 'escaped role on single-line constrained monospaced chars' do
277
+ para = block_from_string(%q{call \[method]+save()+ to persist the changes})
278
+ assert_equal 'call [method]<code>save()</code> to persist the changes', para.sub_quotes(para.source)
279
+ end
280
+
281
+ test 'escaped role on escaped single-line constrained monospaced chars' do
282
+ para = block_from_string(%q{call \[method]\+save()+ to persist the changes})
283
+ assert_equal 'call \[method]+save()+ to persist the changes', para.sub_quotes(para.source)
230
284
  end
231
285
 
232
286
  test 'single-line unconstrained monospaced chars' do
233
287
  para = block_from_string(%q{Git++Hub++})
234
- assert_equal 'Git<code>Hub</code>', para.sub_quotes(para.buffer.join)
288
+ assert_equal 'Git<code>Hub</code>', para.sub_quotes(para.source)
235
289
  end
236
290
 
237
291
  test 'escaped single-line unconstrained monospaced chars' do
238
292
  para = block_from_string(%q{Git\++Hub++})
239
- assert_equal 'Git+<code>Hub</code>+', para.sub_quotes(para.buffer.join)
293
+ assert_equal 'Git+<code>Hub</code>+', para.sub_quotes(para.source)
240
294
  end
241
295
 
242
296
  test 'multi-line unconstrained monospaced chars' do
243
297
  para = block_from_string(%Q{Git++\nH\nu\nb++})
244
- assert_equal "Git<code>\nH\nu\nb</code>", para.sub_quotes(para.buffer.join)
298
+ assert_equal "Git<code>\nH\nu\nb</code>", para.sub_quotes(para.source)
245
299
  end
246
300
 
247
301
  test 'single-line superscript chars' do
248
302
  para = block_from_string(%q{x^2^ = x * x, e = mc^2^, there's a 1^st^ time for everything})
249
- assert_equal 'x<sup>2</sup> = x * x, e = mc<sup>2</sup>, there\'s a 1<sup>st</sup> time for everything', para.sub_quotes(para.buffer.join)
303
+ assert_equal 'x<sup>2</sup> = x * x, e = mc<sup>2</sup>, there\'s a 1<sup>st</sup> time for everything', para.sub_quotes(para.source)
250
304
  end
251
305
 
252
306
  test 'escaped single-line superscript chars' do
253
307
  para = block_from_string(%q{x\^2^ = x * x})
254
- assert_equal 'x^2^ = x * x', para.sub_quotes(para.buffer.join)
308
+ assert_equal 'x^2^ = x * x', para.sub_quotes(para.source)
255
309
  end
256
310
 
257
311
  test 'multi-line superscript chars' do
258
312
  para = block_from_string(%Q{x^(n\n-\n1)^})
259
- assert_equal "x<sup>(n\n-\n1)</sup>", para.sub_quotes(para.buffer.join)
313
+ assert_equal "x<sup>(n\n-\n1)</sup>", para.sub_quotes(para.source)
260
314
  end
261
315
 
262
316
  test 'single-line subscript chars' do
263
317
  para = block_from_string(%q{H~2~O})
264
- assert_equal 'H<sub>2</sub>O', para.sub_quotes(para.buffer.join)
318
+ assert_equal 'H<sub>2</sub>O', para.sub_quotes(para.source)
265
319
  end
266
320
 
267
321
  test 'escaped single-line subscript chars' do
268
322
  para = block_from_string(%q{H\~2~O})
269
- assert_equal 'H~2~O', para.sub_quotes(para.buffer.join)
323
+ assert_equal 'H~2~O', para.sub_quotes(para.source)
270
324
  end
271
325
 
272
326
  test 'multi-line subscript chars' do
273
327
  para = block_from_string(%Q{project~ view\non\nGitHub~})
274
- assert_equal "project<sub> view\non\nGitHub</sub>", para.sub_quotes(para.buffer.join)
328
+ assert_equal "project<sub> view\non\nGitHub</sub>", para.sub_quotes(para.source)
329
+ end
330
+
331
+ test 'quoted text with role shorthand' do
332
+ para = block_from_string(%q{[.white.red-background]#alert#})
333
+ assert_equal '<span class="white red-background">alert</span>', para.sub_quotes(para.source)
334
+ end
335
+
336
+ test 'quoted text with id shorthand' do
337
+ para = block_from_string(%q{[#bond]#007#})
338
+ assert_equal '<a id="bond"></a>007', para.sub_quotes(para.source)
339
+ end
340
+
341
+ test 'quoted text with id and role shorthand' do
342
+ para = block_from_string(%q{[#bond.white.red-background]#007#})
343
+ assert_equal '<a id="bond"></a><span class="white red-background">007</span>', para.sub_quotes(para.source)
344
+ end
345
+
346
+ test 'quoted text with id and role shorthand using docbook backend' do
347
+ para = block_from_string(%q{[#bond.white.red-background]#007#}, :backend => 'docbook')
348
+ assert_equal '<anchor id="bond" xreflabel="007"/><phrase role="white red-background">007</phrase>', para.sub_quotes(para.source)
349
+ end
350
+
351
+ test 'should ignore attributes after comma' do
352
+ para = block_from_string(%q{[red, foobar]#alert#})
353
+ assert_equal '<span class="red">alert</span>', para.sub_quotes(para.source)
275
354
  end
276
355
  end
277
356
 
278
357
  context 'Macros' do
279
358
  test 'a single-line link macro should be interpreted as a link' do
280
359
  para = block_from_string('link:/home.html[]')
281
- assert_equal %q{<a href="/home.html">/home.html</a>}, para.sub_macros(para.buffer.join)
360
+ assert_equal %q{<a href="/home.html">/home.html</a>}, para.sub_macros(para.source)
282
361
  end
283
362
 
284
363
  test 'a single-line link macro with text should be interpreted as a link' do
285
364
  para = block_from_string('link:/home.html[Home]')
286
- assert_equal %q{<a href="/home.html">Home</a>}, para.sub_macros(para.buffer.join)
365
+ assert_equal %q{<a href="/home.html">Home</a>}, para.sub_macros(para.source)
287
366
  end
288
367
 
289
368
  test 'a mailto macro should be interpreted as a mailto link' do
290
369
  para = block_from_string('mailto:doc.writer@asciidoc.org[]')
291
- assert_equal %q{<a href="mailto:doc.writer@asciidoc.org">doc.writer@asciidoc.org</a>}, para.sub_macros(para.buffer.join)
370
+ assert_equal %q{<a href="mailto:doc.writer@asciidoc.org">doc.writer@asciidoc.org</a>}, para.sub_macros(para.source)
292
371
  end
293
372
 
294
373
  test 'a mailto macro with text should be interpreted as a mailto link' do
295
374
  para = block_from_string('mailto:doc.writer@asciidoc.org[Doc Writer]')
296
- assert_equal %q{<a href="mailto:doc.writer@asciidoc.org">Doc Writer</a>}, para.sub_macros(para.buffer.join)
375
+ assert_equal %q{<a href="mailto:doc.writer@asciidoc.org">Doc Writer</a>}, para.sub_macros(para.source)
297
376
  end
298
377
 
299
378
  test 'a mailto macro with text and subject should be interpreted as a mailto link' do
300
379
  para = block_from_string('mailto:doc.writer@asciidoc.org[Doc Writer, Pull request]', :attributes => {'linkattrs' => ''})
301
- assert_equal %q{<a href="mailto:doc.writer@asciidoc.org?subject=Pull%20request">Doc Writer</a>}, para.sub_macros(para.buffer.join)
380
+ assert_equal %q{<a href="mailto:doc.writer@asciidoc.org?subject=Pull%20request">Doc Writer</a>}, para.sub_macros(para.source)
302
381
  end
303
382
 
304
383
  test 'a mailto macro with text, subject and body should be interpreted as a mailto link' do
305
384
  para = block_from_string('mailto:doc.writer@asciidoc.org[Doc Writer, Pull request, Please accept my pull request]', :attributes => {'linkattrs' => ''})
306
- assert_equal %q{<a href="mailto:doc.writer@asciidoc.org?subject=Pull%20request&amp;body=Please%20accept%20my%20pull%20request">Doc Writer</a>}, para.sub_macros(para.buffer.join)
385
+ assert_equal %q{<a href="mailto:doc.writer@asciidoc.org?subject=Pull%20request&amp;body=Please%20accept%20my%20pull%20request">Doc Writer</a>}, para.sub_macros(para.source)
307
386
  end
308
387
 
309
388
  test 'should recognize inline email addresses' do
310
389
  para = block_from_string('doc.writer@asciidoc.org')
311
- assert_equal %q{<a href="mailto:doc.writer@asciidoc.org">doc.writer@asciidoc.org</a>}, para.sub_macros(para.buffer.join)
390
+ assert_equal %q{<a href="mailto:doc.writer@asciidoc.org">doc.writer@asciidoc.org</a>}, para.sub_macros(para.source)
312
391
  para = block_from_string('<doc.writer@asciidoc.org>')
313
- assert_equal %q{&lt;<a href="mailto:doc.writer@asciidoc.org">doc.writer@asciidoc.org</a>&gt;}, para.apply_normal_subs(para.buffer)
392
+ assert_equal %q{&lt;<a href="mailto:doc.writer@asciidoc.org">doc.writer@asciidoc.org</a>&gt;}, para.apply_normal_subs(para.lines)
314
393
  para = block_from_string('author+website@4fs.no')
315
- assert_equal %q{<a href="mailto:author+website@4fs.no">author+website@4fs.no</a>}, para.sub_macros(para.buffer.join)
394
+ assert_equal %q{<a href="mailto:author+website@4fs.no">author+website@4fs.no</a>}, para.sub_macros(para.source)
316
395
  para = block_from_string('john@domain.uk.co')
317
- assert_equal %q{<a href="mailto:john@domain.uk.co">john@domain.uk.co</a>}, para.sub_macros(para.buffer.join)
396
+ assert_equal %q{<a href="mailto:john@domain.uk.co">john@domain.uk.co</a>}, para.sub_macros(para.source)
318
397
  end
319
398
 
320
399
  test 'should ignore escaped inline email address' do
321
400
  para = block_from_string('\doc.writer@asciidoc.org')
322
- assert_equal %q{doc.writer@asciidoc.org}, para.sub_macros(para.buffer.join)
401
+ assert_equal %q{doc.writer@asciidoc.org}, para.sub_macros(para.source)
323
402
  end
324
403
 
325
404
  test 'a single-line raw url should be interpreted as a link' do
326
405
  para = block_from_string('http://google.com')
327
- assert_equal %q{<a href="http://google.com">http://google.com</a>}, para.sub_macros(para.buffer.join)
406
+ assert_equal %q{<a href="http://google.com">http://google.com</a>}, para.sub_macros(para.source)
328
407
  end
329
408
 
330
409
  test 'a single-line raw url with text should be interpreted as a link' do
331
410
  para = block_from_string('http://google.com[Google]')
332
- assert_equal %q{<a href="http://google.com">Google</a>}, para.sub_macros(para.buffer.join)
411
+ assert_equal %q{<a href="http://google.com">Google</a>}, para.sub_macros(para.source)
333
412
  end
334
413
 
335
414
  test 'a multi-line raw url with text should be interpreted as a link' do
336
415
  para = block_from_string("http://google.com[Google\nHomepage]")
337
- assert_equal %{<a href="http://google.com">Google\nHomepage</a>}, para.sub_macros(para.buffer.join)
416
+ assert_equal %{<a href="http://google.com">Google\nHomepage</a>}, para.sub_macros(para.source)
338
417
  end
339
418
 
340
419
  test 'a multi-line raw url with attribute as text should be interpreted as a link with resolved attribute' do
341
420
  para = block_from_string("http://google.com[{google_homepage}]")
342
421
  para.document.attributes['google_homepage'] = 'Google Homepage'
343
- assert_equal %q{<a href="http://google.com">Google Homepage</a>}, para.sub_macros(para.buffer.join)
422
+ assert_equal %q{<a href="http://google.com">Google Homepage</a>}, para.sub_macros(para.source)
344
423
  end
345
424
 
346
425
  test 'a single-line escaped raw url should not be interpreted as a link' do
347
426
  para = block_from_string('\http://google.com')
348
- assert_equal %q{http://google.com}, para.sub_macros(para.buffer.join)
427
+ assert_equal %q{http://google.com}, para.sub_macros(para.source)
349
428
  end
350
429
 
351
430
  test 'a comma separated list of links should not include commas in links' do
352
431
  para = block_from_string('http://foo.com, http://bar.com, http://example.org')
353
- assert_equal %q{<a href="http://foo.com">http://foo.com</a>, <a href="http://bar.com">http://bar.com</a>, <a href="http://example.org">http://example.org</a>}, para.sub_macros(para.buffer.join)
432
+ assert_equal %q{<a href="http://foo.com">http://foo.com</a>, <a href="http://bar.com">http://bar.com</a>, <a href="http://example.org">http://example.org</a>}, para.sub_macros(para.source)
354
433
  end
355
434
 
356
435
  test 'a single-line image macro should be interpreted as an image' do
357
436
  para = block_from_string('image:tiger.png[]')
358
- assert_equal %{<span class="image"><img src="tiger.png" alt="tiger"></span>}, para.sub_macros(para.buffer.join).gsub(/>\s+</, '><')
437
+ assert_equal %{<span class="image"><img src="tiger.png" alt="tiger"></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
359
438
  end
360
439
 
361
440
  test 'a single-line image macro with text should be interpreted as an image with alt text' do
362
441
  para = block_from_string('image:tiger.png[Tiger]')
363
- assert_equal %{<span class="image"><img src="tiger.png" alt="Tiger"></span>}, para.sub_macros(para.buffer.join).gsub(/>\s+</, '><')
442
+ assert_equal %{<span class="image"><img src="tiger.png" alt="Tiger"></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
364
443
  end
365
444
 
366
445
  test 'a single-line image macro with text containing escaped square bracket should be interpreted as an image with alt text' do
367
446
  para = block_from_string('image:tiger.png[[Another\] Tiger]')
368
- assert_equal %{<span class="image"><img src="tiger.png" alt="[Another] Tiger"></span>}, para.sub_macros(para.buffer.join).gsub(/>\s+</, '><')
447
+ assert_equal %{<span class="image"><img src="tiger.png" alt="[Another] Tiger"></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
369
448
  end
370
449
 
371
450
  test 'a single-line image macro with text and dimensions should be interpreted as an image with alt text and dimensions' do
372
451
  para = block_from_string('image:tiger.png[Tiger, 200, 100]')
373
452
  assert_equal %{<span class="image"><img src="tiger.png" alt="Tiger" width="200" height="100"></span>},
374
- para.sub_macros(para.buffer.join).gsub(/>\s+</, '><')
453
+ para.sub_macros(para.source).gsub(/>\s+</, '><')
375
454
  end
376
455
 
377
456
  test 'a single-line image macro with text and link should be interpreted as a linked image with alt text' do
378
457
  para = block_from_string('image:tiger.png[Tiger, link="http://en.wikipedia.org/wiki/Tiger"]')
379
458
  assert_equal %{<span class="image"><a class="image" href="http://en.wikipedia.org/wiki/Tiger"><img src="tiger.png" alt="Tiger"></a></span>},
380
- para.sub_macros(para.buffer.join).gsub(/>\s+</, '><')
459
+ para.sub_macros(para.source).gsub(/>\s+</, '><')
381
460
  end
382
461
 
383
462
  test 'a multi-line image macro with text and dimensions should be interpreted as an image with alt text and dimensions' do
384
463
  para = block_from_string(%(image:tiger.png[Another\nAwesome\nTiger, 200,\n100]))
385
464
  assert_equal %{<span class="image"><img src="tiger.png" alt="Another Awesome Tiger" width="200" height="100"></span>},
386
- para.sub_macros(para.buffer.join).gsub(/>\s+</, '><')
465
+ para.sub_macros(para.source).gsub(/>\s+</, '><')
466
+ end
467
+
468
+ test 'an inline image macro with a url target should be interpreted as an image' do
469
+ para = block_from_string %(Beware of the image:http://example.com/images/tiger.png[tiger].)
470
+ assert_equal %{Beware of the <span class="image"><img src="http://example.com/images/tiger.png" alt="tiger"></span>.},
471
+ para.sub_macros(para.source).gsub(/>\s+</, '><')
472
+ end
473
+
474
+ test 'wip an inline image macro with a float attribute should be interpreted as a floating image' do
475
+ para = block_from_string %(image:http://example.com/images/tiger.png[tiger, float="right"] Beware of the tigers!)
476
+ assert_equal %{<span class="image" style="float: right"><img src="http://example.com/images/tiger.png" alt="tiger"></span> Beware of the tigers!},
477
+ para.sub_macros(para.source).gsub(/>\s+</, '><')
478
+ end
479
+
480
+ test 'should prepend value of imagesdir attribute to inline image target if target is relative path' do
481
+ para = block_from_string %(Beware of the image:tiger.png[tiger].), :attributes => {'imagesdir' => './images'}
482
+ assert_equal %{Beware of the <span class="image"><img src="./images/tiger.png" alt="tiger"></span>.},
483
+ para.sub_macros(para.source).gsub(/>\s+</, '><')
484
+ end
485
+
486
+ test 'should not prepend value of imagesdir attribute to inline image target if target is absolute path' do
487
+ para = block_from_string %(Beware of the image:/tiger.png[tiger].), :attributes => {'imagesdir' => './images'}
488
+ assert_equal %{Beware of the <span class="image"><img src="/tiger.png" alt="tiger"></span>.},
489
+ para.sub_macros(para.source).gsub(/>\s+</, '><')
490
+ end
491
+
492
+ test 'should not prepend value of imagesdir attribute to inline image target if target is url' do
493
+ para = block_from_string %(Beware of the image:http://example.com/images/tiger.png[tiger].), :attributes => {'imagesdir' => './images'}
494
+ assert_equal %{Beware of the <span class="image"><img src="http://example.com/images/tiger.png" alt="tiger"></span>.},
495
+ para.sub_macros(para.source).gsub(/>\s+</, '><')
387
496
  end
388
497
 
389
498
  test 'a block image macro should not be detected within paragraph text' do
390
499
  para = block_from_string(%(Not an inline image macro image::tiger.png[].))
391
- result = para.sub_macros(para.buffer.join)
500
+ result = para.sub_macros(para.source)
392
501
  assert !result.include?('<img ')
393
502
  assert result.include?('image::tiger.png[]')
394
503
  end
395
504
 
505
+ test 'an icon macro should be interpreted as an icon if icons are enabled' do
506
+ para = block_from_string 'icon:github[]', :attributes => {'icons' => ''}
507
+ assert_equal %{<span class="icon"><img src="./images/icons/github.png" alt="github"></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
508
+ end
509
+
510
+ test 'an icon macro should be interpreted as alt text if icons are disabled' do
511
+ para = block_from_string 'icon:github[]'
512
+ assert_equal %{<span class="icon">[github]</span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
513
+ end
514
+
515
+ test 'an icon macro should render alt text if icons are disabled and alt is given' do
516
+ para = block_from_string 'icon:github[alt="GitHub"]'
517
+ assert_equal %{<span class="icon">[GitHub]</span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
518
+ end
519
+
520
+ test 'an icon macro should be interpreted as a font-based icon when icons=font' do
521
+ para = block_from_string 'icon:github[]', :attributes => {'icons' => 'font'}
522
+ assert_equal %{<span class="icon"><i class="icon-github"></i></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
523
+ end
524
+
525
+ test 'an icon macro with a size should be interpreted as a font-based icon with a size when icons=font' do
526
+ para = block_from_string 'icon:github[4x]', :attributes => {'icons' => 'font'}
527
+ assert_equal %{<span class="icon"><i class="icon-github icon-4x"></i></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
528
+ end
529
+
530
+ test 'an icon macro with a role and title should be interpreted as a font-based icon with a class and title when icons=font' do
531
+ para = block_from_string 'icon:heart[role="red", title="Heart me"]', :attributes => {'icons' => 'font'}
532
+ assert_equal %{<span class="icon red"><i class="icon-heart" title="Heart me"></i></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
533
+ end
534
+
396
535
  test 'a single-line footnote macro should be registered and rendered as a footnote' do
397
536
  para = block_from_string('Sentence text footnote:[An example footnote.].')
398
- assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
537
+ assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.source)
399
538
  assert_equal 1, para.document.references[:footnotes].size
400
539
  footnote = para.document.references[:footnotes].first
401
540
  assert_equal 1, footnote.index
@@ -405,7 +544,7 @@ context 'Substitutions' do
405
544
 
406
545
  test 'a multi-line footnote macro should be registered and rendered as a footnote' do
407
546
  para = block_from_string("Sentence text footnote:[An example footnote\nwith wrapped text.].")
408
- assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
547
+ assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.source)
409
548
  assert_equal 1, para.document.references[:footnotes].size
410
549
  footnote = para.document.references[:footnotes].first
411
550
  assert_equal 1, footnote.index
@@ -415,20 +554,38 @@ context 'Substitutions' do
415
554
 
416
555
  test 'a footnote macro can be directly adjacent to preceding word' do
417
556
  para = block_from_string('Sentence textfootnote:[An example footnote.].')
418
- assert_equal %(Sentence text<span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
557
+ assert_equal %(Sentence text<span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.source)
419
558
  end
420
559
 
421
560
  test 'a footnote macro may contain a macro' do
422
561
  para = block_from_string('Share your code. footnote:[http://github.com[GitHub]]')
423
- assert_equal %(Share your code. <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>), para.sub_macros(para.buffer.join)
562
+ assert_equal %(Share your code. <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>), para.sub_macros(para.source)
424
563
  assert_equal 1, para.document.references[:footnotes].size
425
564
  footnote1 = para.document.references[:footnotes][0]
426
565
  assert_equal '<a href="http://github.com">GitHub</a>', footnote1.text
427
566
  end
428
567
 
568
+ test 'a footnote macro may contain a plain URL' do
569
+ para = block_from_string %(the JLine footnote:[https://github.com/jline/jline2]\nlibrary.)
570
+ result = para.sub_macros para.source
571
+ assert_equal %(the JLine <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>\nlibrary.), result
572
+ assert_equal 1, para.document.references[:footnotes].size
573
+ fn1 = para.document.references[:footnotes].first
574
+ assert_equal '<a href="https://github.com/jline/jline2">https://github.com/jline/jline2</a>', fn1.text
575
+ end
576
+
577
+ test 'a footnote macro followed by a semi-colon may contain a plain URL' do
578
+ para = block_from_string %(the JLine footnote:[https://github.com/jline/jline2];\nlibrary.)
579
+ result = para.sub_macros para.source
580
+ assert_equal %(the JLine <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>;\nlibrary.), result
581
+ assert_equal 1, para.document.references[:footnotes].size
582
+ fn1 = para.document.references[:footnotes].first
583
+ assert_equal '<a href="https://github.com/jline/jline2">https://github.com/jline/jline2</a>', fn1.text
584
+ end
585
+
429
586
  test 'should increment index of subsequent footnote macros' do
430
587
  para = block_from_string("Sentence text footnote:[An example footnote.]. Sentence text footnote:[Another footnote.].")
431
- assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>. Sentence text <span class="footnote">[<a id="_footnoteref_2" class="footnote" href="#_footnote_2" title="View footnote.">2</a>]</span>.), para.sub_macros(para.buffer.join)
588
+ assert_equal %(Sentence text <span class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>. Sentence text <span class="footnote">[<a id="_footnoteref_2" class="footnote" href="#_footnote_2" title="View footnote.">2</a>]</span>.), para.sub_macros(para.source)
432
589
  assert_equal 2, para.document.references[:footnotes].size
433
590
  footnote1 = para.document.references[:footnotes][0]
434
591
  assert_equal 1, footnote1.index
@@ -442,7 +599,7 @@ context 'Substitutions' do
442
599
 
443
600
  test 'a footnoteref macro with id and single-line text should be registered and rendered as a footnote' do
444
601
  para = block_from_string('Sentence text footnoteref:[ex1, An example footnote.].')
445
- assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
602
+ assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.source)
446
603
  assert_equal 1, para.document.references[:footnotes].size
447
604
  footnote = para.document.references[:footnotes].first
448
605
  assert_equal 1, footnote.index
@@ -452,7 +609,7 @@ context 'Substitutions' do
452
609
 
453
610
  test 'a footnoteref macro with id and multi-line text should be registered and rendered as a footnote' do
454
611
  para = block_from_string("Sentence text footnoteref:[ex1, An example footnote\nwith wrapped text.].")
455
- assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
612
+ assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.source)
456
613
  assert_equal 1, para.document.references[:footnotes].size
457
614
  footnote = para.document.references[:footnotes].first
458
615
  assert_equal 1, footnote.index
@@ -462,7 +619,7 @@ context 'Substitutions' do
462
619
 
463
620
  test 'a footnoteref macro with id should refer to footnoteref with same id' do
464
621
  para = block_from_string('Sentence text footnoteref:[ex1, An example footnote.]. Sentence text footnoteref:[ex1].')
465
- assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>. Sentence text <span class="footnoteref">[<a class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.buffer.join)
622
+ assert_equal %(Sentence text <span class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>. Sentence text <span class="footnoteref">[<a class="footnote" href="#_footnote_1" title="View footnote.">1</a>]</span>.), para.sub_macros(para.source)
466
623
  assert_equal 1, para.document.references[:footnotes].size
467
624
  footnote = para.document.references[:footnotes].first
468
625
  assert_equal 1, footnote.index
@@ -475,7 +632,7 @@ context 'Substitutions' do
475
632
  macros = ['indexterm:[Tigers]', '(((Tigers)))']
476
633
  macros.each do |macro|
477
634
  para = block_from_string("#{sentence}#{macro}")
478
- output = para.sub_macros(para.buffer.join)
635
+ output = para.sub_macros(para.source)
479
636
  assert_equal sentence, output
480
637
  assert_equal 1, para.document.references[:indexterms].size
481
638
  assert_equal ['Tigers'], para.document.references[:indexterms].first
@@ -487,7 +644,7 @@ context 'Substitutions' do
487
644
  macros = ['indexterm:[Big cats, Tigers]', '(((Big cats, Tigers)))']
488
645
  macros.each do |macro|
489
646
  para = block_from_string("#{sentence}#{macro}")
490
- output = para.sub_macros(para.buffer.join)
647
+ output = para.sub_macros(para.source)
491
648
  assert_equal sentence, output
492
649
  assert_equal 1, para.document.references[:indexterms].size
493
650
  assert_equal ['Big cats', 'Tigers'], para.document.references[:indexterms].first
@@ -499,7 +656,7 @@ context 'Substitutions' do
499
656
  macros = ['indexterm:[Big cats,Tigers , Panthera tigris]', '(((Big cats,Tigers , Panthera tigris)))']
500
657
  macros.each do |macro|
501
658
  para = block_from_string("#{sentence}#{macro}")
502
- output = para.sub_macros(para.buffer.join)
659
+ output = para.sub_macros(para.source)
503
660
  assert_equal sentence, output
504
661
  assert_equal 1, para.document.references[:indexterms].size
505
662
  assert_equal ['Big cats', 'Tigers', 'Panthera tigris'], para.document.references[:indexterms].first
@@ -511,7 +668,7 @@ context 'Substitutions' do
511
668
  macros = ["indexterm:[Panthera\ntigris]", "(((Panthera\ntigris)))"]
512
669
  macros.each do |macro|
513
670
  para = block_from_string("#{sentence}#{macro}")
514
- output = para.sub_macros(para.buffer.join)
671
+ output = para.sub_macros(para.source)
515
672
  assert_equal sentence, output
516
673
  assert_equal 1, para.document.references[:indexterms].size
517
674
  assert_equal ['Panthera tigris'], para.document.references[:indexterms].first
@@ -523,7 +680,7 @@ context 'Substitutions' do
523
680
  macros = ['indexterm:[*Tigers*]', '(((*Tigers*)))']
524
681
  macros.each do |macro|
525
682
  para = block_from_string("#{sentence}#{macro}")
526
- output = para.apply_normal_subs(para.buffer)
683
+ output = para.apply_normal_subs(para.lines)
527
684
  assert_equal sentence, output
528
685
  assert_equal 1, para.document.references[:indexterms].size
529
686
  assert_equal ['<strong>Tigers</strong>'], para.document.references[:indexterms].first
@@ -534,7 +691,7 @@ context 'Substitutions' do
534
691
  sentence = "The tiger (Panthera tigris) is the largest cat species."
535
692
  macros = "(((Tigers)))\n(((Animals,Cats)))"
536
693
  para = block_from_string("#{sentence}\n#{macros}")
537
- output = para.sub_macros(para.buffer.join)
694
+ output = para.sub_macros(para.source)
538
695
  assert_equal sentence, output.rstrip
539
696
  assert_equal 2, para.document.references[:indexterms].size
540
697
  assert_equal ['Tigers'], para.document.references[:indexterms][0]
@@ -545,7 +702,7 @@ context 'Substitutions' do
545
702
  sentence = "The tiger (Panthera tigris) is the largest cat species.\n"
546
703
  macro = '(((Tiger (Panthera tigris))))'
547
704
  para = block_from_string("#{sentence}#{macro}")
548
- output = para.sub_macros(para.buffer.join)
705
+ output = para.sub_macros(para.source)
549
706
  assert_equal sentence, output
550
707
  assert_equal 1, para.document.references[:indexterms].size
551
708
  assert_equal ['Tiger (Panthera tigris)'], para.document.references[:indexterms].first
@@ -555,7 +712,7 @@ context 'Substitutions' do
555
712
  sentence = "The tiger (Panthera tigris) is the largest cat species.\n"
556
713
  macro = 'indexterm:[Tiger [Panthera tigris\\]]'
557
714
  para = block_from_string("#{sentence}#{macro}")
558
- output = para.sub_macros(para.buffer.join)
715
+ output = para.sub_macros(para.source)
559
716
  assert_equal sentence, output
560
717
  assert_equal 1, para.document.references[:indexterms].size
561
718
  assert_equal ['Tiger [Panthera tigris]'], para.document.references[:indexterms].first
@@ -566,7 +723,7 @@ context 'Substitutions' do
566
723
  macros = ['The indexterm2:[tiger] (Panthera tigris) is the largest cat species.', 'The ((tiger)) (Panthera tigris) is the largest cat species.']
567
724
  macros.each do |macro|
568
725
  para = block_from_string(macro)
569
- output = para.sub_macros(para.buffer.join)
726
+ output = para.sub_macros(para.source)
570
727
  assert_equal sentence, output
571
728
  assert_equal 1, para.document.references[:indexterms].size
572
729
  assert_equal ['tiger'], para.document.references[:indexterms].first
@@ -578,7 +735,7 @@ context 'Substitutions' do
578
735
  macros = ["The indexterm2:[ panthera\ntigris ] is the largest cat species.", "The (( panthera\ntigris )) is the largest cat species."]
579
736
  macros.each do |macro|
580
737
  para = block_from_string(macro)
581
- output = para.sub_macros(para.buffer.join)
738
+ output = para.sub_macros(para.source)
582
739
  assert_equal sentence, output
583
740
  assert_equal 1, para.document.references[:indexterms].size
584
741
  assert_equal ['panthera tigris'], para.document.references[:indexterms].first
@@ -588,7 +745,7 @@ context 'Substitutions' do
588
745
  test 'registers multiple index term 2 macros' do
589
746
  sentence = "The ((tiger)) (Panthera tigris) is the largest ((cat)) species."
590
747
  para = block_from_string(sentence)
591
- output = para.sub_macros(para.buffer.join)
748
+ output = para.sub_macros(para.source)
592
749
  assert_equal 'The tiger (Panthera tigris) is the largest cat species.', output
593
750
  assert_equal 2, para.document.references[:indexterms].size
594
751
  assert_equal ['tiger'], para.document.references[:indexterms][0]
@@ -598,7 +755,7 @@ context 'Substitutions' do
598
755
  test 'normal substitutions are performed on an index term 2 macro' do
599
756
  sentence = 'The ((*tiger*)) (Panthera tigris) is the largest cat species.'
600
757
  para = block_from_string sentence
601
- output = para.apply_normal_subs(para.buffer)
758
+ output = para.apply_normal_subs(para.lines)
602
759
  assert_equal 'The <strong>tiger</strong> (Panthera tigris) is the largest cat species.', output
603
760
  assert_equal 1, para.document.references[:indexterms].size
604
761
  assert_equal ['<strong>tiger</strong>'], para.document.references[:indexterms].first
@@ -607,7 +764,7 @@ context 'Substitutions' do
607
764
  test 'index term 2 macro with round bracket syntex should not interfer with index term macro with round bracket syntax' do
608
765
  sentence = "The ((panthera tigris)) is the largest cat species.\n(((Big cats,Tigers)))"
609
766
  para = block_from_string sentence
610
- output = para.sub_macros(para.buffer.join)
767
+ output = para.sub_macros(para.source)
611
768
  assert_equal "The panthera tigris is the largest cat species.\n", output
612
769
  terms = para.document.references[:indexterms]
613
770
  assert_equal 2, terms.size
@@ -618,116 +775,116 @@ context 'Substitutions' do
618
775
  context 'Button macro' do
619
776
  test 'btn macro' do
620
777
  para = block_from_string('btn:[Save]', :attributes => {'experimental' => ''})
621
- assert_equal %q{<b class="button">Save</b>}, para.sub_macros(para.buffer.join)
778
+ assert_equal %q{<b class="button">Save</b>}, para.sub_macros(para.source)
622
779
  end
623
780
 
624
781
  test 'btn macro for docbook backend' do
625
782
  para = block_from_string('btn:[Save]', :backend => 'docbook', :attributes => {'experimental' => ''})
626
- assert_equal %q{<guibutton>Save</guibutton>}, para.sub_macros(para.buffer.join)
783
+ assert_equal %q{<guibutton>Save</guibutton>}, para.sub_macros(para.source)
627
784
  end
628
785
  end
629
786
 
630
787
  context 'Keyboard macro' do
631
788
  test 'kbd macro with single key' do
632
789
  para = block_from_string('kbd:[F3]', :attributes => {'experimental' => ''})
633
- assert_equal %q{<kbd>F3</kbd>}, para.sub_macros(para.buffer.join)
790
+ assert_equal %q{<kbd>F3</kbd>}, para.sub_macros(para.source)
634
791
  end
635
792
 
636
793
  test 'kbd macro with single key, docbook backend' do
637
794
  para = block_from_string('kbd:[F3]', :backend => 'docbook', :attributes => {'experimental' => ''})
638
- assert_equal %q{<keycap>F3</keycap>}, para.sub_macros(para.buffer.join)
795
+ assert_equal %q{<keycap>F3</keycap>}, para.sub_macros(para.source)
639
796
  end
640
797
 
641
798
  test 'kbd macro with key combination' do
642
799
  para = block_from_string('kbd:[Ctrl+Shift+T]', :attributes => {'experimental' => ''})
643
- assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></kbd>}, para.sub_macros(para.buffer.join)
800
+ assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></kbd>}, para.sub_macros(para.source)
644
801
  end
645
802
 
646
803
  test 'kbd macro with key combination with spaces' do
647
804
  para = block_from_string('kbd:[Ctrl + Shift + T]', :attributes => {'experimental' => ''})
648
- assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></kbd>}, para.sub_macros(para.buffer.join)
805
+ assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></kbd>}, para.sub_macros(para.source)
649
806
  end
650
807
 
651
808
  test 'kbd macro with key combination delimited by commas' do
652
809
  para = block_from_string('kbd:[Ctrl,Shift,T]', :attributes => {'experimental' => ''})
653
- assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></kbd>}, para.sub_macros(para.buffer.join)
810
+ assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></kbd>}, para.sub_macros(para.source)
654
811
  end
655
812
 
656
813
  test 'kbd macro with key combination containing a plus key no spaces' do
657
814
  para = block_from_string('kbd:[Ctrl++]', :attributes => {'experimental' => ''})
658
- assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>+</kbd></kbd>}, para.sub_macros(para.buffer.join)
815
+ assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>+</kbd></kbd>}, para.sub_macros(para.source)
659
816
  end
660
817
 
661
818
  test 'kbd macro with key combination delimited by commands containing a comma key' do
662
819
  para = block_from_string('kbd:[Ctrl,,]', :attributes => {'experimental' => ''})
663
- assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>,</kbd></kbd>}, para.sub_macros(para.buffer.join)
820
+ assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>,</kbd></kbd>}, para.sub_macros(para.source)
664
821
  end
665
822
 
666
823
  test 'kbd macro with key combination containing a plus key with spaces' do
667
824
  para = block_from_string('kbd:[Ctrl + +]', :attributes => {'experimental' => ''})
668
- assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>+</kbd></kbd>}, para.sub_macros(para.buffer.join)
825
+ assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>+</kbd></kbd>}, para.sub_macros(para.source)
669
826
  end
670
827
 
671
828
  test 'kbd macro with key combination containing escaped bracket' do
672
829
  para = block_from_string('kbd:[Ctrl + \]]', :attributes => {'experimental' => ''})
673
- assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>]</kbd></kbd>}, para.sub_macros(para.buffer.join)
830
+ assert_equal %q{<kbd class="keyseq"><kbd>Ctrl</kbd>+<kbd>]</kbd></kbd>}, para.sub_macros(para.source)
674
831
  end
675
832
 
676
833
  test 'kbd macro with key combination, docbook backend' do
677
834
  para = block_from_string('kbd:[Ctrl+Shift+T]', :backend => 'docbook', :attributes => {'experimental' => ''})
678
- assert_equal %q{<keycombo><keycap>Ctrl</keycap><keycap>Shift</keycap><keycap>T</keycap></keycombo>}, para.sub_macros(para.buffer.join)
835
+ assert_equal %q{<keycombo><keycap>Ctrl</keycap><keycap>Shift</keycap><keycap>T</keycap></keycombo>}, para.sub_macros(para.source)
679
836
  end
680
837
  end
681
838
 
682
839
  context 'Menu macro' do
683
840
  test 'should process menu using macro sytnax' do
684
841
  para = block_from_string('menu:File[]', :attributes => {'experimental' => ''})
685
- assert_equal %q{<span class="menu">File</span>}, para.sub_macros(para.buffer.join)
842
+ assert_equal %q{<span class="menu">File</span>}, para.sub_macros(para.source)
686
843
  end
687
844
 
688
845
  test 'should process menu for docbook backend' do
689
846
  para = block_from_string('menu:File[]', :backend => 'docbook', :attributes => {'experimental' => ''})
690
- assert_equal %q{<guimenu>File</guimenu>}, para.sub_macros(para.buffer.join)
847
+ assert_equal %q{<guimenu>File</guimenu>}, para.sub_macros(para.source)
691
848
  end
692
849
 
693
850
  test 'should process menu with menu item using macro syntax' do
694
851
  para = block_from_string('menu:File[Save As&#8230;]', :attributes => {'experimental' => ''})
695
- assert_equal %q{<span class="menuseq"><span class="menu">File</span>&#160;&#9656; <span class="menuitem">Save As&#8230;</span></span>}, para.sub_macros(para.buffer.join)
852
+ assert_equal %q{<span class="menuseq"><span class="menu">File</span>&#160;&#9656; <span class="menuitem">Save As&#8230;</span></span>}, para.sub_macros(para.source)
696
853
  end
697
854
 
698
855
  test 'should process menu with menu item for docbook backend' do
699
856
  para = block_from_string('menu:File[Save As&#8230;]', :backend => 'docbook', :attributes => {'experimental' => ''})
700
- assert_equal %q{<menuchoice><guimenu>File</guimenu> <guimenuitem>Save As&#8230;</guimenuitem></menuchoice>}, para.sub_macros(para.buffer.join)
857
+ assert_equal %q{<menuchoice><guimenu>File</guimenu> <guimenuitem>Save As&#8230;</guimenuitem></menuchoice>}, para.sub_macros(para.source)
701
858
  end
702
859
 
703
860
  test 'should process menu with menu item in submenu using macro syntax' do
704
861
  para = block_from_string('menu:Tools[Project &gt; Build]', :attributes => {'experimental' => ''})
705
- assert_equal %q{<span class="menuseq"><span class="menu">Tools</span>&#160;&#9656; <span class="submenu">Project</span>&#160;&#9656; <span class="menuitem">Build</span></span>}, para.sub_macros(para.buffer.join)
862
+ assert_equal %q{<span class="menuseq"><span class="menu">Tools</span>&#160;&#9656; <span class="submenu">Project</span>&#160;&#9656; <span class="menuitem">Build</span></span>}, para.sub_macros(para.source)
706
863
  end
707
864
 
708
865
  test 'should process menu with menu item in submenu for docbook backend' do
709
866
  para = block_from_string('menu:Tools[Project &gt; Build]', :backend => 'docbook', :attributes => {'experimental' => ''})
710
- assert_equal %q{<menuchoice><guimenu>Tools</guimenu> <guisubmenu>Project</guisubmenu> <guimenuitem>Build</guimenuitem></menuchoice>}, para.sub_macros(para.buffer.join)
867
+ assert_equal %q{<menuchoice><guimenu>Tools</guimenu> <guisubmenu>Project</guisubmenu> <guimenuitem>Build</guimenuitem></menuchoice>}, para.sub_macros(para.source)
711
868
  end
712
869
 
713
870
  test 'should process menu with menu item in submenu using macro syntax and comma delimiter' do
714
871
  para = block_from_string('menu:Tools[Project, Build]', :attributes => {'experimental' => ''})
715
- assert_equal %q{<span class="menuseq"><span class="menu">Tools</span>&#160;&#9656; <span class="submenu">Project</span>&#160;&#9656; <span class="menuitem">Build</span></span>}, para.sub_macros(para.buffer.join)
872
+ assert_equal %q{<span class="menuseq"><span class="menu">Tools</span>&#160;&#9656; <span class="submenu">Project</span>&#160;&#9656; <span class="menuitem">Build</span></span>}, para.sub_macros(para.source)
716
873
  end
717
874
 
718
875
  test 'should process menu with menu item using inline syntax' do
719
876
  para = block_from_string('"File &gt; Save As&#8230;"', :attributes => {'experimental' => ''})
720
- assert_equal %q{<span class="menuseq"><span class="menu">File</span>&#160;&#9656; <span class="menuitem">Save As&#8230;</span></span>}, para.sub_macros(para.buffer.join)
877
+ assert_equal %q{<span class="menuseq"><span class="menu">File</span>&#160;&#9656; <span class="menuitem">Save As&#8230;</span></span>}, para.sub_macros(para.source)
721
878
  end
722
879
 
723
880
  test 'should process menu with menu item in submenu using inline syntax' do
724
881
  para = block_from_string('"Tools &gt; Project &gt; Build"', :attributes => {'experimental' => ''})
725
- assert_equal %q{<span class="menuseq"><span class="menu">Tools</span>&#160;&#9656; <span class="submenu">Project</span>&#160;&#9656; <span class="menuitem">Build</span></span>}, para.sub_macros(para.buffer.join)
882
+ assert_equal %q{<span class="menuseq"><span class="menu">Tools</span>&#160;&#9656; <span class="submenu">Project</span>&#160;&#9656; <span class="menuitem">Build</span></span>}, para.sub_macros(para.source)
726
883
  end
727
884
 
728
885
  test 'inline syntax should not closing quote of XML attribute' do
729
886
  para = block_from_string('<span class="xmltag">&lt;node&gt;</span><span class="classname">r</span>', :attributes => {'experimental' => ''})
730
- assert_equal %q{<span class="xmltag">&lt;node&gt;</span><span class="classname">r</span>}, para.sub_macros(para.buffer.join)
887
+ assert_equal %q{<span class="xmltag">&lt;node&gt;</span><span class="classname">r</span>}, para.sub_macros(para.source)
731
888
  end
732
889
  end
733
890
  end
@@ -735,7 +892,7 @@ context 'Substitutions' do
735
892
  context 'Passthroughs' do
736
893
  test 'collect inline triple plus passthroughs' do
737
894
  para = block_from_string('+++<code>inline code</code>+++')
738
- result = para.extract_passthroughs(para.buffer.join)
895
+ result = para.extract_passthroughs(para.source)
739
896
  assert_equal "\e" + '0' + "\e", result
740
897
  assert_equal 1, para.passthroughs.size
741
898
  assert_equal '<code>inline code</code>', para.passthroughs.first[:text]
@@ -744,7 +901,7 @@ context 'Substitutions' do
744
901
 
745
902
  test 'collect multi-line inline triple plus passthroughs' do
746
903
  para = block_from_string("+++<code>inline\ncode</code>+++")
747
- result = para.extract_passthroughs(para.buffer.join)
904
+ result = para.extract_passthroughs(para.source)
748
905
  assert_equal "\e" + '0' + "\e", result
749
906
  assert_equal 1, para.passthroughs.size
750
907
  assert_equal "<code>inline\ncode</code>", para.passthroughs.first[:text]
@@ -753,7 +910,7 @@ context 'Substitutions' do
753
910
 
754
911
  test 'collect inline double dollar passthroughs' do
755
912
  para = block_from_string('$$<code>{code}</code>$$')
756
- result = para.extract_passthroughs(para.buffer.join)
913
+ result = para.extract_passthroughs(para.source)
757
914
  assert_equal "\e" + '0' + "\e", result
758
915
  assert_equal 1, para.passthroughs.size
759
916
  assert_equal '<code>{code}</code>', para.passthroughs.first[:text]
@@ -762,7 +919,7 @@ context 'Substitutions' do
762
919
 
763
920
  test 'collect multi-line inline double dollar passthroughs' do
764
921
  para = block_from_string("$$<code>\n{code}\n</code>$$")
765
- result = para.extract_passthroughs(para.buffer.join)
922
+ result = para.extract_passthroughs(para.source)
766
923
  assert_equal "\e" + '0' + "\e", result
767
924
  assert_equal 1, para.passthroughs.size
768
925
  assert_equal "<code>\n{code}\n</code>", para.passthroughs.first[:text]
@@ -771,7 +928,7 @@ context 'Substitutions' do
771
928
 
772
929
  test 'collect passthroughs from inline pass macro' do
773
930
  para = block_from_string(%Q{pass:specialcharacters,quotes[<code>['code'\\]</code>]})
774
- result = para.extract_passthroughs(para.buffer.join)
931
+ result = para.extract_passthroughs(para.source)
775
932
  assert_equal "\e" + '0' + "\e", result
776
933
  assert_equal 1, para.passthroughs.size
777
934
  assert_equal %q{<code>['code']</code>}, para.passthroughs.first[:text]
@@ -780,7 +937,7 @@ context 'Substitutions' do
780
937
 
781
938
  test 'collect multi-line passthroughs from inline pass macro' do
782
939
  para = block_from_string(%Q{pass:specialcharacters,quotes[<code>['more\ncode'\\]</code>]})
783
- result = para.extract_passthroughs(para.buffer.join)
940
+ result = para.extract_passthroughs(para.source)
784
941
  assert_equal "\e" + '0' + "\e", result
785
942
  assert_equal 1, para.passthroughs.size
786
943
  assert_equal %Q{<code>['more\ncode']</code>}, para.passthroughs.first[:text]
@@ -791,7 +948,7 @@ context 'Substitutions' do
791
948
  test 'restore inline passthroughs without subs' do
792
949
  para = block_from_string("some \e" + '0' + "\e to study")
793
950
  para.passthroughs << {:text => '<code>inline code</code>', :subs => []}
794
- result = para.restore_passthroughs(para.buffer.join)
951
+ result = para.restore_passthroughs(para.source)
795
952
  assert_equal "some <code>inline code</code> to study", result
796
953
  end
797
954
 
@@ -800,34 +957,39 @@ context 'Substitutions' do
800
957
  para = block_from_string("some \e" + '0' + "\e to study in the \e" + '1' + "\e programming language")
801
958
  para.passthroughs << {:text => '<code>{code}</code>', :subs => [:specialcharacters]}
802
959
  para.passthroughs << {:text => '{language}', :subs => [:specialcharacters]}
803
- result = para.restore_passthroughs(para.buffer.join)
960
+ result = para.restore_passthroughs(para.source)
804
961
  assert_equal 'some &lt;code&gt;{code}&lt;/code&gt; to study in the {language} programming language', result
805
962
  end
806
963
 
807
964
  test 'complex inline passthrough macro' do
808
965
  text_to_escape = %q{[(] <'basic form'> <'logical operator'> <'basic form'> [)]}
809
966
  para = block_from_string %($$#{text_to_escape}$$)
810
- result = para.extract_passthroughs(para.buffer.join)
967
+ result = para.extract_passthroughs(para.source)
811
968
  assert_equal 1, para.passthroughs.size
812
969
  assert_equal text_to_escape, para.passthroughs[0][:text]
813
970
 
814
971
  text_to_escape_escaped = %q{[(\] <'basic form'> <'logical operator'> <'basic form'> [)\]}
815
972
  para = block_from_string %(pass:specialcharacters[#{text_to_escape_escaped}])
816
- result = para.extract_passthroughs(para.buffer.join)
973
+ result = para.extract_passthroughs(para.source)
817
974
  assert_equal 1, para.passthroughs.size
818
975
  assert_equal text_to_escape, para.passthroughs[0][:text]
819
976
  end
977
+
978
+ test 'inline pass macro with a composite sub' do
979
+ para = block_from_string %(pass:verbatim[<{backend}>])
980
+ assert_equal '&lt;{backend}&gt;', para.content
981
+ end
820
982
  end
821
983
 
822
984
  context 'Replacements' do
823
985
  test 'unescapes XML entities' do
824
986
  para = block_from_string '< &quot; &#34; &#x22; >'
825
- assert_equal '&lt; &quot; &#34; &#x22; &gt;', para.apply_normal_subs(para.buffer)
987
+ assert_equal '&lt; &quot; &#34; &#x22; &gt;', para.apply_normal_subs(para.lines)
826
988
  end
827
989
 
828
990
  test 'replaces arrows' do
829
991
  para = block_from_string '<- -> <= => \<- \-> \<= \=>'
830
- assert_equal '&#8592; &#8594; &#8656; &#8658; &lt;- -&gt; &lt;= =&gt;', para.apply_normal_subs(para.buffer.join)
992
+ assert_equal '&#8592; &#8594; &#8656; &#8658; &lt;- -&gt; &lt;= =&gt;', para.apply_normal_subs(para.source)
831
993
  end
832
994
 
833
995
  test 'replaces dashes' do
@@ -843,43 +1005,82 @@ stuff in between&#8201;&#8212;&#8201;foo
843
1005
  stuff in between
844
1006
  foo&#8201;&#8212;&#8201;stuff in between
845
1007
  foo&#8201;&#8212;&#8201;)
846
- assert_equal expected, para.sub_replacements(para.buffer.join)
1008
+ assert_equal expected, para.sub_replacements(para.source)
847
1009
  end
848
1010
 
849
1011
  test 'replaces marks' do
850
1012
  para = block_from_string '(C) (R) (TM) \(C) \(R) \(TM)'
851
- assert_equal '&#169; &#174; &#8482; (C) (R) (TM)', para.sub_replacements(para.buffer.join)
1013
+ assert_equal '&#169; &#174; &#8482; (C) (R) (TM)', para.sub_replacements(para.source)
852
1014
  end
853
1015
 
854
1016
  test 'replaces punctuation' do
855
1017
  para = block_from_string %(John's Hideout... foo\\'bar)
856
- assert_equal "John&#8217;s Hideout&#8230; foo'bar", para.sub_replacements(para.buffer.join)
1018
+ assert_equal "John&#8217;s Hideout&#8230; foo'bar", para.sub_replacements(para.source)
857
1019
  end
858
1020
  end
859
1021
 
860
1022
  context 'Post replacements' do
861
1023
  test 'line break inserted after line with line break character' do
862
1024
  para = block_from_string("First line +\nSecond line")
863
- result = para.apply_subs(para.buffer, :post_replacements)
1025
+ result = para.apply_subs(para.lines, :post_replacements, true)
864
1026
  assert_equal "First line<br>\n", result.first
865
1027
  end
866
1028
 
867
1029
  test 'line break inserted after line wrap with hardbreaks enabled' do
868
1030
  para = block_from_string("First line\nSecond line", :attributes => {'hardbreaks' => ''})
869
- result = para.apply_subs(para.buffer, :post_replacements)
1031
+ result = para.apply_subs(para.lines, :post_replacements, true)
870
1032
  assert_equal "First line<br>\n", result.first
871
1033
  end
872
1034
 
873
1035
  test 'line break character stripped from end of line with hardbreaks enabled' do
874
1036
  para = block_from_string("First line +\nSecond line", :attributes => {'hardbreaks' => ''})
875
- result = para.apply_subs(para.buffer, :post_replacements)
1037
+ result = para.apply_subs(para.lines, :post_replacements, true)
876
1038
  assert_equal "First line<br>\n", result.first
877
1039
  end
878
1040
 
879
1041
  test 'line break not inserted for single line with hardbreaks enabled' do
880
1042
  para = block_from_string("First line", :attributes => {'hardbreaks' => ''})
881
- result = para.apply_subs(para.buffer, :post_replacements)
1043
+ result = para.apply_subs(para.lines, :post_replacements, true)
882
1044
  assert_equal "First line", result.first
883
1045
  end
884
1046
  end
1047
+
1048
+ context 'Resolve subs' do
1049
+ test 'should resolve subs for block' do
1050
+ block = Asciidoctor::Block.new(empty_document, :paragraph)
1051
+ block.attributes['subs'] = 'quotes,normal'
1052
+ block.lock_in_subs
1053
+ assert_equal [:quotes, :specialcharacters, :attributes, :replacements, :macros, :post_replacements], block.subs
1054
+ end
1055
+
1056
+ test 'should resolve specialcharacters sub as highlight for source block when source highlighter is coderay' do
1057
+ doc = empty_document :attributes => {'source-highlighter' => 'coderay'}
1058
+ block = Asciidoctor::Block.new(doc, :listing, :content_model => :verbatim)
1059
+ block.style = 'source'
1060
+ block.attributes['subs'] = 'specialcharacters'
1061
+ block.attributes['language'] = 'ruby'
1062
+ block.lock_in_subs
1063
+ assert_equal [:highlight], block.subs
1064
+ end
1065
+
1066
+ test 'should resolve specialcharacters sub as highlight for source block when source highlighter is pygments' do
1067
+ doc = empty_document :attributes => {'source-highlighter' => 'pygments'}
1068
+ block = Asciidoctor::Block.new(doc, :listing, :content_model => :verbatim)
1069
+ block.style = 'source'
1070
+ block.attributes['subs'] = 'specialcharacters'
1071
+ block.attributes['language'] = 'ruby'
1072
+ block.lock_in_subs
1073
+ assert_equal [:highlight], block.subs
1074
+ end
1075
+
1076
+ test 'should not resolve specialcharacters sub as highlight for source block when source highlighter is not set' do
1077
+ doc = empty_document
1078
+ block = Asciidoctor::Block.new(doc, :listing, :content_model => :verbatim)
1079
+ block.style = 'source'
1080
+ block.attributes['subs'] = 'specialcharacters'
1081
+ block.attributes['language'] = 'ruby'
1082
+ block.lock_in_subs
1083
+ assert_equal [:specialcharacters], block.subs
1084
+ end
1085
+ end
885
1086
  end