asciidoctor 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of asciidoctor might be problematic. Click here for more details.
- data/Gemfile +2 -0
- data/README.asciidoc +35 -26
- data/Rakefile +9 -6
- data/asciidoctor.gemspec +27 -8
- data/bin/asciidoctor +1 -1
- data/lib/asciidoctor.rb +351 -63
- data/lib/asciidoctor/abstract_block.rb +218 -0
- data/lib/asciidoctor/abstract_node.rb +249 -0
- data/lib/asciidoctor/attribute_list.rb +211 -0
- data/lib/asciidoctor/backends/base_template.rb +99 -0
- data/lib/asciidoctor/backends/docbook45.rb +510 -0
- data/lib/asciidoctor/backends/html5.rb +585 -0
- data/lib/asciidoctor/block.rb +27 -254
- data/lib/asciidoctor/callouts.rb +117 -0
- data/lib/asciidoctor/debug.rb +7 -4
- data/lib/asciidoctor/document.rb +229 -77
- data/lib/asciidoctor/inline.rb +29 -0
- data/lib/asciidoctor/lexer.rb +1330 -502
- data/lib/asciidoctor/list_item.rb +33 -34
- data/lib/asciidoctor/reader.rb +305 -142
- data/lib/asciidoctor/renderer.rb +115 -19
- data/lib/asciidoctor/section.rb +100 -189
- data/lib/asciidoctor/substituters.rb +468 -0
- data/lib/asciidoctor/table.rb +499 -0
- data/lib/asciidoctor/version.rb +1 -1
- data/test/attributes_test.rb +301 -87
- data/test/blocks_test.rb +568 -0
- data/test/document_test.rb +221 -24
- data/test/fixtures/dot.gif +0 -0
- data/test/fixtures/encoding.asciidoc +1 -0
- data/test/fixtures/include-file.asciidoc +1 -0
- data/test/fixtures/tip.gif +0 -0
- data/test/headers_test.rb +411 -43
- data/test/lexer_test.rb +265 -45
- data/test/links_test.rb +144 -3
- data/test/lists_test.rb +2252 -74
- data/test/paragraphs_test.rb +21 -30
- data/test/preamble_test.rb +24 -0
- data/test/reader_test.rb +248 -12
- data/test/renderer_test.rb +22 -0
- data/test/substitutions_test.rb +414 -0
- data/test/tables_test.rb +484 -0
- data/test/test_helper.rb +70 -6
- data/test/text_test.rb +30 -6
- metadata +64 -10
- data/lib/asciidoctor/render_templates.rb +0 -317
- data/lib/asciidoctor/string.rb +0 -12
data/test/lists_test.rb
CHANGED
@@ -3,40 +3,333 @@ require 'test_helper'
|
|
3
3
|
context "Bulleted lists (:ulist)" do
|
4
4
|
context "Simple lists" do
|
5
5
|
test "dash elements with no blank lines" do
|
6
|
-
|
6
|
+
input = <<-EOS
|
7
|
+
List
|
8
|
+
====
|
9
|
+
|
10
|
+
- Foo
|
11
|
+
- Boo
|
12
|
+
- Blech
|
13
|
+
EOS
|
14
|
+
output = render_string input
|
15
|
+
assert_xpath '//ul', output, 1
|
16
|
+
assert_xpath '//ul/li', output, 3
|
17
|
+
end
|
18
|
+
|
19
|
+
test "dash elements separated by blank lines should merge lists" do
|
20
|
+
input = <<-EOS
|
21
|
+
List
|
22
|
+
====
|
23
|
+
|
24
|
+
- Foo
|
25
|
+
|
26
|
+
- Boo
|
27
|
+
|
28
|
+
|
29
|
+
- Blech
|
30
|
+
EOS
|
31
|
+
output = render_string input
|
32
|
+
assert_xpath '//ul', output, 1
|
33
|
+
assert_xpath '//ul/li', output, 3
|
34
|
+
end
|
35
|
+
|
36
|
+
test "dash elements separated by a line comment offset by blank lines should not merge lists" do
|
37
|
+
input = <<-EOS
|
38
|
+
List
|
39
|
+
====
|
40
|
+
|
41
|
+
- Foo
|
42
|
+
- Boo
|
43
|
+
|
44
|
+
//
|
45
|
+
|
46
|
+
- Blech
|
47
|
+
EOS
|
48
|
+
output = render_string input
|
49
|
+
assert_xpath '//ul', output, 2
|
50
|
+
assert_xpath '(//ul)[1]/li', output, 2
|
51
|
+
assert_xpath '(//ul)[2]/li', output, 1
|
52
|
+
end
|
53
|
+
|
54
|
+
test "dash elements separated by a block title offset by a blank line should not merge lists" do
|
55
|
+
input = <<-EOS
|
56
|
+
List
|
57
|
+
====
|
58
|
+
|
59
|
+
- Foo
|
60
|
+
- Boo
|
61
|
+
|
62
|
+
.Also
|
63
|
+
- Blech
|
64
|
+
EOS
|
65
|
+
output = render_string input
|
66
|
+
assert_xpath '//ul', output, 2
|
67
|
+
assert_xpath '(//ul)[1]/li', output, 2
|
68
|
+
assert_xpath '(//ul)[2]/li', output, 1
|
69
|
+
assert_xpath '(//ul)[2]/preceding-sibling::*[@class = "title"][text() = "Also"]', output, 1
|
70
|
+
end
|
71
|
+
|
72
|
+
test 'a non-indented wrapped line is folded into text of list item' do
|
73
|
+
input = <<-EOS
|
74
|
+
List
|
75
|
+
====
|
76
|
+
|
77
|
+
- Foo
|
78
|
+
wrapped content
|
79
|
+
- Boo
|
80
|
+
- Blech
|
81
|
+
EOS
|
82
|
+
output = render_string input
|
83
|
+
assert_xpath '//ul', output, 1
|
84
|
+
assert_xpath '//ul/li[1]/*', output, 1
|
85
|
+
assert_xpath "//ul/li[1]/p[text() = 'Foo\nwrapped content']", output, 1
|
86
|
+
end
|
87
|
+
|
88
|
+
test 'an indented wrapped line is unindented and folded into text of list item' do
|
89
|
+
input = <<-EOS
|
90
|
+
List
|
91
|
+
====
|
92
|
+
|
93
|
+
- Foo
|
94
|
+
wrapped content
|
95
|
+
- Boo
|
96
|
+
- Blech
|
97
|
+
EOS
|
98
|
+
output = render_string input
|
99
|
+
assert_xpath '//ul', output, 1
|
100
|
+
assert_xpath '//ul/li[1]/*', output, 1
|
101
|
+
assert_xpath "//ul/li[1]/p[text() = 'Foo\nwrapped content']", output, 1
|
102
|
+
end
|
103
|
+
|
104
|
+
test "a literal paragraph offset by blank lines in list content is appended as a literal block" do
|
105
|
+
input = <<-EOS
|
106
|
+
List
|
107
|
+
====
|
108
|
+
|
109
|
+
- Foo
|
110
|
+
|
111
|
+
literal
|
112
|
+
|
113
|
+
- Boo
|
114
|
+
- Blech
|
115
|
+
EOS
|
116
|
+
output = render_string input
|
117
|
+
assert_xpath '//ul', output, 1
|
118
|
+
assert_xpath '//ul/li', output, 3
|
119
|
+
assert_xpath '(//ul/li)[1]/p[text() = "Foo"]', output, 1
|
120
|
+
assert_xpath '(//ul/li)[1]/*[@class="literalblock"]', output, 1
|
121
|
+
assert_xpath '(//ul/li)[1]/p/following-sibling::*[@class="literalblock"]', output, 1
|
122
|
+
assert_xpath '((//ul/li)[1]/*[@class="literalblock"])[1]//pre[text() = "literal"]', output, 1
|
123
|
+
end
|
124
|
+
|
125
|
+
test "a literal paragraph offset by a blank line in list content followed by line with continuation is appended as two blocks" do
|
126
|
+
input = <<-EOS
|
127
|
+
List
|
128
|
+
====
|
129
|
+
|
130
|
+
- Foo
|
131
|
+
|
132
|
+
literal
|
133
|
+
+
|
134
|
+
para
|
135
|
+
|
136
|
+
- Boo
|
137
|
+
- Blech
|
138
|
+
EOS
|
139
|
+
output = render_string input
|
7
140
|
assert_xpath '//ul', output, 1
|
8
141
|
assert_xpath '//ul/li', output, 3
|
142
|
+
assert_xpath '(//ul/li)[1]/p[text() = "Foo"]', output, 1
|
143
|
+
assert_xpath '(//ul/li)[1]/*[@class="literalblock"]', output, 1
|
144
|
+
assert_xpath '(//ul/li)[1]/p/following-sibling::*[@class="literalblock"]', output, 1
|
145
|
+
assert_xpath '((//ul/li)[1]/*[@class="literalblock"])[1]//pre[text() = "literal"]', output, 1
|
146
|
+
assert_xpath '(//ul/li)[1]/*[@class="literalblock"]/following-sibling::*[@class="paragraph"]', output, 1
|
147
|
+
assert_xpath '(//ul/li)[1]/*[@class="literalblock"]/following-sibling::*[@class="paragraph"]/p[text()="para"]', output, 1
|
148
|
+
end
|
149
|
+
|
150
|
+
test "a literal paragraph with a line that appears as a list item that is followed by a continuation should create two blocks" do
|
151
|
+
input = <<-EOS
|
152
|
+
* Foo
|
153
|
+
+
|
154
|
+
literal
|
155
|
+
. still literal
|
156
|
+
+
|
157
|
+
para
|
158
|
+
|
159
|
+
* Bar
|
160
|
+
EOS
|
161
|
+
output = render_string input
|
162
|
+
assert_xpath '//ul', output, 1
|
163
|
+
assert_xpath '//ul/li', output, 2
|
164
|
+
assert_xpath '(//ul/li)[1]/p[text() = "Foo"]', output, 1
|
165
|
+
assert_xpath '(//ul/li)[1]/*[@class="literalblock"]', output, 1
|
166
|
+
assert_xpath '(//ul/li)[1]/p/following-sibling::*[@class="literalblock"]', output, 1
|
167
|
+
assert_xpath %(((//ul/li)[1]/*[@class="literalblock"])[1]//pre[text() = " literal\n. still literal"]), output, 1
|
168
|
+
assert_xpath '(//ul/li)[1]/*[@class="literalblock"]/following-sibling::*[@class="paragraph"]', output, 1
|
169
|
+
assert_xpath '(//ul/li)[1]/*[@class="literalblock"]/following-sibling::*[@class="paragraph"]/p[text()="para"]', output, 1
|
9
170
|
end
|
10
171
|
|
11
|
-
test "
|
12
|
-
|
172
|
+
test "consecutive literal paragraph offset by blank lines in list content are appended as a literal blocks" do
|
173
|
+
input = <<-EOS
|
174
|
+
List
|
175
|
+
====
|
176
|
+
|
177
|
+
- Foo
|
178
|
+
|
179
|
+
literal
|
180
|
+
|
181
|
+
more
|
182
|
+
literal
|
183
|
+
|
184
|
+
- Boo
|
185
|
+
- Blech
|
186
|
+
EOS
|
187
|
+
output = render_string input
|
13
188
|
assert_xpath '//ul', output, 1
|
14
189
|
assert_xpath '//ul/li', output, 3
|
190
|
+
assert_xpath '(//ul/li)[1]/p[text() = "Foo"]', output, 1
|
191
|
+
assert_xpath '(//ul/li)[1]/*[@class="literalblock"]', output, 2
|
192
|
+
assert_xpath '(//ul/li)[1]/p/following-sibling::*[@class="literalblock"]', output, 2
|
193
|
+
assert_xpath '((//ul/li)[1]/*[@class="literalblock"])[1]//pre[text() = "literal"]', output, 1
|
194
|
+
assert_xpath "((//ul/li)[1]/*[@class='literalblock'])[2]//pre[text() = 'more\nliteral']", output, 1
|
195
|
+
end
|
196
|
+
|
197
|
+
test "a literal paragraph without a trailing blank line consumes following list items" do
|
198
|
+
input = <<-EOS
|
199
|
+
List
|
200
|
+
====
|
201
|
+
|
202
|
+
- Foo
|
203
|
+
|
204
|
+
literal
|
205
|
+
- Boo
|
206
|
+
- Blech
|
207
|
+
EOS
|
208
|
+
output = render_string input
|
209
|
+
assert_xpath '//ul', output, 1
|
210
|
+
assert_xpath '//ul/li', output, 1
|
211
|
+
assert_xpath '(//ul/li)[1]/p[text() = "Foo"]', output, 1
|
212
|
+
assert_xpath '(//ul/li)[1]/*[@class="literalblock"]', output, 1
|
213
|
+
assert_xpath '(//ul/li)[1]/p/following-sibling::*[@class="literalblock"]', output, 1
|
214
|
+
assert_xpath "((//ul/li)[1]/*[@class='literalblock'])[1]//pre[text() = ' literal\n- Boo\n- Blech']", output, 1
|
15
215
|
end
|
16
216
|
|
17
217
|
test "asterisk elements with no blank lines" do
|
18
|
-
|
218
|
+
input = <<-EOS
|
219
|
+
List
|
220
|
+
====
|
221
|
+
|
222
|
+
* Foo
|
223
|
+
* Boo
|
224
|
+
* Blech
|
225
|
+
EOS
|
226
|
+
output = render_string input
|
19
227
|
assert_xpath '//ul', output, 1
|
20
228
|
assert_xpath '//ul/li', output, 3
|
21
229
|
end
|
22
230
|
|
23
|
-
test "asterisk elements
|
24
|
-
|
231
|
+
test "asterisk elements separated by blank lines should merge lists" do
|
232
|
+
input = <<-EOS
|
233
|
+
List
|
234
|
+
====
|
235
|
+
|
236
|
+
* Foo
|
237
|
+
|
238
|
+
* Boo
|
239
|
+
|
240
|
+
|
241
|
+
* Blech
|
242
|
+
EOS
|
243
|
+
output = render_string input
|
25
244
|
assert_xpath '//ul', output, 1
|
26
245
|
assert_xpath '//ul/li', output, 3
|
27
246
|
end
|
28
247
|
|
29
|
-
test "asterisk elements
|
30
|
-
|
248
|
+
test "asterisk elements separated by a line comment offset by blank lines should not merge lists" do
|
249
|
+
input = <<-EOS
|
250
|
+
List
|
251
|
+
====
|
252
|
+
|
253
|
+
* Foo
|
254
|
+
* Boo
|
255
|
+
|
256
|
+
//
|
257
|
+
|
258
|
+
* Blech
|
259
|
+
EOS
|
260
|
+
output = render_string input
|
261
|
+
assert_xpath '//ul', output, 2
|
262
|
+
assert_xpath '(//ul)[1]/li', output, 2
|
263
|
+
assert_xpath '(//ul)[2]/li', output, 1
|
264
|
+
end
|
265
|
+
|
266
|
+
test "asterisk elements separated by a block title offset by a blank line should not merge lists" do
|
267
|
+
input = <<-EOS
|
268
|
+
List
|
269
|
+
====
|
270
|
+
|
271
|
+
* Foo
|
272
|
+
* Boo
|
273
|
+
|
274
|
+
.Also
|
275
|
+
* Blech
|
276
|
+
EOS
|
277
|
+
output = render_string input
|
31
278
|
assert_xpath '//ul', output, 2
|
32
279
|
assert_xpath '(//ul)[1]/li', output, 2
|
33
280
|
assert_xpath '(//ul)[2]/li', output, 1
|
281
|
+
assert_xpath '(//ul)[2]/preceding-sibling::*[@class = "title"][text() = "Also"]', output, 1
|
282
|
+
end
|
283
|
+
|
284
|
+
test "list should terminate before next lower section heading" do
|
285
|
+
input = <<-EOS
|
286
|
+
List
|
287
|
+
====
|
288
|
+
|
289
|
+
* first
|
290
|
+
item
|
291
|
+
* second
|
292
|
+
item
|
293
|
+
|
294
|
+
== Section
|
295
|
+
EOS
|
296
|
+
output = render_string input
|
297
|
+
assert_xpath '//ul', output, 1
|
298
|
+
assert_xpath '//ul/li', output, 2
|
299
|
+
assert_xpath '//h2[text() = "Section"]', output, 1
|
300
|
+
end
|
301
|
+
|
302
|
+
test "list should terminate before next lower section heading with implicit id" do
|
303
|
+
input = <<-EOS
|
304
|
+
List
|
305
|
+
====
|
306
|
+
|
307
|
+
* first
|
308
|
+
item
|
309
|
+
* second
|
310
|
+
item
|
311
|
+
|
312
|
+
[[sec]]
|
313
|
+
== Section
|
314
|
+
EOS
|
315
|
+
output = render_string input
|
316
|
+
assert_xpath '//ul', output, 1
|
317
|
+
assert_xpath '//ul/li', output, 2
|
318
|
+
assert_xpath '//h2[@id = "sec"][text() = "Section"]', output, 1
|
34
319
|
end
|
35
320
|
end
|
36
321
|
|
37
322
|
context "Lists with inline markup" do
|
38
|
-
test "
|
39
|
-
|
323
|
+
test "quoted text" do
|
324
|
+
input = <<-EOS
|
325
|
+
List
|
326
|
+
====
|
327
|
+
|
328
|
+
- I am *strong*.
|
329
|
+
- I am 'stressed'.
|
330
|
+
- I am `flexible`.
|
331
|
+
EOS
|
332
|
+
output = render_string input
|
40
333
|
assert_xpath '//ul', output, 1
|
41
334
|
assert_xpath '//ul/li', output, 3
|
42
335
|
assert_xpath '(//ul/li)[1]//strong', output, 1
|
@@ -44,31 +337,127 @@ context "Bulleted lists (:ulist)" do
|
|
44
337
|
assert_xpath '(//ul/li)[3]//tt', output, 1
|
45
338
|
end
|
46
339
|
|
47
|
-
test "
|
48
|
-
|
340
|
+
test "attribute substitutions" do
|
341
|
+
input = <<-EOS
|
342
|
+
List
|
343
|
+
====
|
344
|
+
:foo: bar
|
345
|
+
|
346
|
+
- side a {brvbar} side b
|
347
|
+
- Take me to a {foo}.
|
348
|
+
EOS
|
349
|
+
output = render_string input
|
49
350
|
assert_xpath '//ul', output, 1
|
50
351
|
assert_xpath '//ul/li', output, 2
|
51
352
|
assert_xpath '(//ul/li)[1]//p[text() = "side a | side b"]', output, 1
|
52
353
|
assert_xpath '(//ul/li)[2]//p[text() = "Take me to a bar."]', output, 1
|
53
354
|
end
|
355
|
+
|
356
|
+
test "leading dot is treated as text not block title" do
|
357
|
+
input = <<-EOS
|
358
|
+
* .first
|
359
|
+
* .second
|
360
|
+
* .third
|
361
|
+
EOS
|
362
|
+
output = render_string input
|
363
|
+
assert_xpath '//ul', output, 1
|
364
|
+
assert_xpath '//ul/li', output, 3
|
365
|
+
%w(.first .second .third).each_with_index do |text, index|
|
366
|
+
assert_xpath "(//ul/li)[#{index + 1}]//p[text() = '#{text}']", output, 1
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
test "word ending sentence on continuing line not treated as a list item" do
|
371
|
+
input = <<-EOS
|
372
|
+
A. This is the story about
|
373
|
+
AsciiDoc. It begins here.
|
374
|
+
B. And it ends here.
|
375
|
+
EOS
|
376
|
+
output = render_string input
|
377
|
+
assert_xpath '//ol', output, 1
|
378
|
+
assert_xpath '//ol/li', output, 2
|
379
|
+
end
|
54
380
|
end
|
55
381
|
|
56
382
|
context "Nested lists" do
|
57
|
-
test "
|
58
|
-
|
59
|
-
|
383
|
+
test "asterisk element mixed with dash elements should be nested" do
|
384
|
+
input = <<-EOS
|
385
|
+
List
|
386
|
+
====
|
387
|
+
|
388
|
+
- Foo
|
389
|
+
* Boo
|
390
|
+
- Blech
|
391
|
+
EOS
|
392
|
+
output = render_string input
|
393
|
+
assert_xpath '//ul', output, 2
|
394
|
+
assert_xpath '//ul/li', output, 3
|
395
|
+
assert_xpath '(//ul)[1]/li', output, 2
|
396
|
+
assert_xpath '(//ul)[1]/li//ul/li', output, 1
|
397
|
+
end
|
398
|
+
|
399
|
+
test "dash element mixed with asterisks elements should be nested" do
|
400
|
+
input = <<-EOS
|
401
|
+
List
|
402
|
+
====
|
403
|
+
|
404
|
+
* Foo
|
405
|
+
- Boo
|
406
|
+
* Blech
|
407
|
+
EOS
|
408
|
+
output = render_string input
|
409
|
+
assert_xpath '//ul', output, 2
|
410
|
+
assert_xpath '//ul/li', output, 3
|
411
|
+
assert_xpath '(//ul)[1]/li', output, 2
|
412
|
+
assert_xpath '(//ul)[1]/li//ul/li', output, 1
|
413
|
+
end
|
414
|
+
|
415
|
+
test "lines prefixed with alternating list markers separated by blank lines should be nested" do
|
416
|
+
input = <<-EOS
|
417
|
+
List
|
418
|
+
====
|
419
|
+
|
420
|
+
- Foo
|
421
|
+
|
422
|
+
* Boo
|
423
|
+
|
424
|
+
|
425
|
+
- Blech
|
426
|
+
EOS
|
427
|
+
output = render_string input
|
428
|
+
assert_xpath '//ul', output, 2
|
60
429
|
assert_xpath '//ul/li', output, 3
|
430
|
+
assert_xpath '(//ul)[1]/li', output, 2
|
431
|
+
assert_xpath '(//ul)[1]/li//ul/li', output, 1
|
61
432
|
end
|
62
433
|
|
63
434
|
test "nested elements (2) with asterisks" do
|
64
|
-
|
435
|
+
input = <<-EOS
|
436
|
+
List
|
437
|
+
====
|
438
|
+
|
439
|
+
* Foo
|
440
|
+
** Boo
|
441
|
+
* Blech
|
442
|
+
EOS
|
443
|
+
output = render_string input
|
65
444
|
assert_xpath '//ul', output, 2
|
445
|
+
assert_xpath '//ul/li', output, 3
|
66
446
|
assert_xpath '(//ul)[1]/li', output, 2
|
67
447
|
assert_xpath '(//ul)[1]/li//ul/li', output, 1
|
68
448
|
end
|
69
449
|
|
70
450
|
test "nested elements (3) with asterisks" do
|
71
|
-
|
451
|
+
input = <<-EOS
|
452
|
+
List
|
453
|
+
====
|
454
|
+
|
455
|
+
* Foo
|
456
|
+
** Boo
|
457
|
+
*** Snoo
|
458
|
+
* Blech
|
459
|
+
EOS
|
460
|
+
output = render_string input
|
72
461
|
assert_xpath '//ul', output, 3
|
73
462
|
assert_xpath '(//ul)[1]/li', output, 2
|
74
463
|
assert_xpath '((//ul)[1]/li//ul)[1]/li', output, 1
|
@@ -76,7 +465,17 @@ context "Bulleted lists (:ulist)" do
|
|
76
465
|
end
|
77
466
|
|
78
467
|
test "nested elements (4) with asterisks" do
|
79
|
-
|
468
|
+
input = <<-EOS
|
469
|
+
List
|
470
|
+
====
|
471
|
+
|
472
|
+
* Foo
|
473
|
+
** Boo
|
474
|
+
*** Snoo
|
475
|
+
**** Froo
|
476
|
+
* Blech
|
477
|
+
EOS
|
478
|
+
output = render_string input
|
80
479
|
assert_xpath '//ul', output, 4
|
81
480
|
assert_xpath '(//ul)[1]/li', output, 2
|
82
481
|
assert_xpath '((//ul)[1]/li//ul)[1]/li', output, 1
|
@@ -85,7 +484,18 @@ context "Bulleted lists (:ulist)" do
|
|
85
484
|
end
|
86
485
|
|
87
486
|
test "nested elements (5) with asterisks" do
|
88
|
-
|
487
|
+
input = <<-EOS
|
488
|
+
List
|
489
|
+
====
|
490
|
+
|
491
|
+
* Foo
|
492
|
+
** Boo
|
493
|
+
*** Snoo
|
494
|
+
**** Froo
|
495
|
+
***** Groo
|
496
|
+
* Blech
|
497
|
+
EOS
|
498
|
+
output = render_string input
|
89
499
|
assert_xpath '//ul', output, 5
|
90
500
|
assert_xpath '(//ul)[1]/li', output, 2
|
91
501
|
assert_xpath '((//ul)[1]/li//ul)[1]/li', output, 1
|
@@ -93,10 +503,175 @@ context "Bulleted lists (:ulist)" do
|
|
93
503
|
assert_xpath '((((//ul)[1]/li//ul)[1]/li//ul)[1]/li//ul)[1]/li', output, 1
|
94
504
|
assert_xpath '(((((//ul)[1]/li//ul)[1]/li//ul)[1]/li//ul)[1]/li//ul)[1]/li', output, 1
|
95
505
|
end
|
506
|
+
|
507
|
+
test "nested ordered elements (2)" do
|
508
|
+
input = <<-EOS
|
509
|
+
List
|
510
|
+
====
|
511
|
+
|
512
|
+
. Foo
|
513
|
+
.. Boo
|
514
|
+
. Blech
|
515
|
+
EOS
|
516
|
+
output = render_string input
|
517
|
+
assert_xpath '//ol', output, 2
|
518
|
+
assert_xpath '//ol/li', output, 3
|
519
|
+
assert_xpath '(//ol)[1]/li', output, 2
|
520
|
+
assert_xpath '(//ol)[1]/li//ol/li', output, 1
|
521
|
+
end
|
522
|
+
|
523
|
+
test "nested ordered elements (3)" do
|
524
|
+
input = <<-EOS
|
525
|
+
List
|
526
|
+
====
|
527
|
+
|
528
|
+
. Foo
|
529
|
+
.. Boo
|
530
|
+
... Snoo
|
531
|
+
. Blech
|
532
|
+
EOS
|
533
|
+
output = render_string input
|
534
|
+
assert_xpath '//ol', output, 3
|
535
|
+
assert_xpath '(//ol)[1]/li', output, 2
|
536
|
+
assert_xpath '((//ol)[1]/li//ol)[1]/li', output, 1
|
537
|
+
assert_xpath '(((//ol)[1]/li//ol)[1]/li//ol)[1]/li', output, 1
|
538
|
+
end
|
539
|
+
|
540
|
+
test "nested unordered inside ordered elements" do
|
541
|
+
input = <<-EOS
|
542
|
+
List
|
543
|
+
====
|
544
|
+
|
545
|
+
. Foo
|
546
|
+
* Boo
|
547
|
+
. Blech
|
548
|
+
EOS
|
549
|
+
output = render_string input
|
550
|
+
assert_xpath '//ol', output, 1
|
551
|
+
assert_xpath '//ul', output, 1
|
552
|
+
assert_xpath '(//ol)[1]/li', output, 2
|
553
|
+
assert_xpath '((//ol)[1]/li//ul)[1]/li', output, 1
|
554
|
+
end
|
555
|
+
|
556
|
+
test "nested ordered inside unordered elements" do
|
557
|
+
input = <<-EOS
|
558
|
+
List
|
559
|
+
====
|
560
|
+
|
561
|
+
* Foo
|
562
|
+
. Boo
|
563
|
+
* Blech
|
564
|
+
EOS
|
565
|
+
output = render_string input
|
566
|
+
assert_xpath '//ul', output, 1
|
567
|
+
assert_xpath '//ol', output, 1
|
568
|
+
assert_xpath '(//ul)[1]/li', output, 2
|
569
|
+
assert_xpath '((//ul)[1]/li//ol)[1]/li', output, 1
|
570
|
+
end
|
571
|
+
|
572
|
+
test "lines with alternating markers of unordered and ordered list types separated by blank lines should be nested" do
|
573
|
+
input = <<-EOS
|
574
|
+
List
|
575
|
+
====
|
576
|
+
|
577
|
+
* Foo
|
578
|
+
|
579
|
+
. Boo
|
580
|
+
|
581
|
+
|
582
|
+
* Blech
|
583
|
+
EOS
|
584
|
+
output = render_string input
|
585
|
+
assert_xpath '//ul', output, 1
|
586
|
+
assert_xpath '//ol', output, 1
|
587
|
+
assert_xpath '(//ul)[1]/li', output, 2
|
588
|
+
assert_xpath '((//ul)[1]/li//ol)[1]/li', output, 1
|
589
|
+
end
|
590
|
+
|
591
|
+
test 'list item with literal content should not consume nested list of different type' do
|
592
|
+
input = <<-EOS
|
593
|
+
List
|
594
|
+
====
|
595
|
+
|
596
|
+
- bullet
|
597
|
+
|
598
|
+
literal
|
599
|
+
but not
|
600
|
+
hungry
|
601
|
+
|
602
|
+
. numbered
|
603
|
+
EOS
|
604
|
+
output = render_string input
|
605
|
+
assert_xpath '//ul', output, 1
|
606
|
+
assert_xpath '//li', output, 2
|
607
|
+
assert_xpath '//ul//ol', output, 1
|
608
|
+
assert_xpath '//ul/li/p', output, 1
|
609
|
+
assert_xpath '//ul/li/p[text()="bullet"]', output, 1
|
610
|
+
assert_xpath '//ul/li/p/following-sibling::*[@class="literalblock"]', output, 1
|
611
|
+
assert_xpath %(//ul/li/p/following-sibling::*[@class="literalblock"]//pre[text()="literal\nbut not\nhungry"]), output, 1
|
612
|
+
assert_xpath '//*[@class="literalblock"]/following-sibling::*[@class="olist arabic"]', output, 1
|
613
|
+
assert_xpath '//*[@class="literalblock"]/following-sibling::*[@class="olist arabic"]//p[text()="numbered"]', output, 1
|
614
|
+
end
|
615
|
+
|
616
|
+
test 'nested list item does not eat the title of the following detached block' do
|
617
|
+
input = <<-EOS
|
618
|
+
List
|
619
|
+
====
|
620
|
+
|
621
|
+
- bullet
|
622
|
+
* nested bullet 1
|
623
|
+
* nested bullet 2
|
624
|
+
|
625
|
+
.Title
|
626
|
+
....
|
627
|
+
literal
|
628
|
+
....
|
629
|
+
EOS
|
630
|
+
output = render_embedded_string input
|
631
|
+
assert_xpath '//*[@class="ulist"]/ul', output, 2
|
632
|
+
assert_xpath '(//*[@class="ulist"])[1]/following-sibling::*[@class="literalblock"]', output, 1
|
633
|
+
assert_xpath '(//*[@class="ulist"])[1]/following-sibling::*[@class="literalblock"]/*[@class="title"]', output, 1
|
634
|
+
end
|
635
|
+
|
636
|
+
test "lines with alternating markers of bulleted and labeled list types separated by blank lines should be nested" do
|
637
|
+
input = <<-EOS
|
638
|
+
List
|
639
|
+
====
|
640
|
+
|
641
|
+
* Foo
|
642
|
+
|
643
|
+
term1:: def1
|
644
|
+
|
645
|
+
* Blech
|
646
|
+
EOS
|
647
|
+
output = render_string input
|
648
|
+
assert_xpath '//ul', output, 1
|
649
|
+
assert_xpath '//dl', output, 1
|
650
|
+
assert_xpath '//ul[1]/li', output, 2
|
651
|
+
assert_xpath '//ul[1]/li//dl[1]/dt', output, 1
|
652
|
+
assert_xpath '//ul[1]/li//dl[1]/dd', output, 1
|
653
|
+
end
|
654
|
+
|
655
|
+
test "nested ordered with attribute inside unordered elements" do
|
656
|
+
input = <<-EOS
|
657
|
+
Blah
|
658
|
+
====
|
659
|
+
|
660
|
+
* Foo
|
661
|
+
[start=2]
|
662
|
+
. Boo
|
663
|
+
* Blech
|
664
|
+
EOS
|
665
|
+
output = render_string input
|
666
|
+
assert_xpath '//ul', output, 1
|
667
|
+
assert_xpath '//ol', output, 1
|
668
|
+
assert_xpath '(//ul)[1]/li', output, 2
|
669
|
+
assert_xpath '((//ul)[1]/li//ol)[1][@start = 2]/li', output, 1
|
670
|
+
end
|
96
671
|
end
|
97
672
|
|
98
673
|
context "List continuations" do
|
99
|
-
test "
|
674
|
+
test "adjacent list continuation line attaches following paragraph" do
|
100
675
|
input = <<-EOS
|
101
676
|
Lists
|
102
677
|
=====
|
@@ -107,16 +682,16 @@ Item one, paragraph two
|
|
107
682
|
+
|
108
683
|
* Item two
|
109
684
|
EOS
|
110
|
-
output = render_string
|
685
|
+
output = render_string input
|
111
686
|
assert_xpath '//ul', output, 1
|
112
687
|
assert_xpath '//ul/li', output, 2
|
113
688
|
assert_xpath '//ul/li[1]/p', output, 1
|
114
689
|
assert_xpath '//ul/li[1]//p', output, 2
|
115
|
-
assert_xpath '//ul/li[1]
|
116
|
-
assert_xpath '//ul/li[1]
|
690
|
+
assert_xpath '//ul/li[1]/p[text() = "Item one, paragraph one"]', output, 1
|
691
|
+
assert_xpath '//ul/li[1]/*[@class = "paragraph"]/p[text() = "Item one, paragraph two"]', output, 1
|
117
692
|
end
|
118
693
|
|
119
|
-
test "
|
694
|
+
test "adjacent list continuation line attaches following block" do
|
120
695
|
input = <<-EOS
|
121
696
|
Lists
|
122
697
|
=====
|
@@ -129,14 +704,14 @@ Item one, literal block
|
|
129
704
|
+
|
130
705
|
* Item two
|
131
706
|
EOS
|
132
|
-
output = render_string
|
707
|
+
output = render_string input
|
133
708
|
assert_xpath '//ul', output, 1
|
134
709
|
assert_xpath '//ul/li', output, 2
|
135
710
|
assert_xpath '//ul/li[1]/p', output, 1
|
136
711
|
assert_xpath '(//ul/li[1]/p/following-sibling::*)[1][@class = "literalblock"]', output, 1
|
137
712
|
end
|
138
713
|
|
139
|
-
test "
|
714
|
+
test "consecutive blocks in list continuation attach to list item" do
|
140
715
|
input = <<-EOS
|
141
716
|
Lists
|
142
717
|
=====
|
@@ -153,7 +728,7 @@ ____
|
|
153
728
|
+
|
154
729
|
* Item two
|
155
730
|
EOS
|
156
|
-
output = render_string
|
731
|
+
output = render_string input
|
157
732
|
assert_xpath '//ul', output, 1
|
158
733
|
assert_xpath '//ul/li', output, 2
|
159
734
|
assert_xpath '//ul/li[1]/p', output, 1
|
@@ -161,8 +736,9 @@ ____
|
|
161
736
|
assert_xpath '(//ul/li[1]/p/following-sibling::*)[2][@class = "quoteblock"]', output, 1
|
162
737
|
end
|
163
738
|
|
164
|
-
# NOTE this
|
165
|
-
|
739
|
+
# NOTE this is not consistent w/ AsciiDoc output, but this is some screwy input anyway
|
740
|
+
=begin
|
741
|
+
test "consecutive list continuation lines are folded" do
|
166
742
|
input = <<-EOS
|
167
743
|
Lists
|
168
744
|
=====
|
@@ -177,7 +753,7 @@ Item one, paragraph two
|
|
177
753
|
+
|
178
754
|
+
|
179
755
|
EOS
|
180
|
-
output = render_string
|
756
|
+
output = render_string input
|
181
757
|
assert_xpath '//ul', output, 1
|
182
758
|
assert_xpath '//ul/li', output, 2
|
183
759
|
assert_xpath '//ul/li[1]/p', output, 1
|
@@ -185,23 +761,90 @@ Item one, paragraph two
|
|
185
761
|
assert_xpath '//ul/li[1]//p[text() = "Item one, paragraph one"]', output, 1
|
186
762
|
assert_xpath '//ul/li[1]//p[text() = "Item one, paragraph two"]', output, 1
|
187
763
|
end
|
764
|
+
=end
|
765
|
+
|
188
766
|
end
|
189
767
|
end
|
190
768
|
|
191
769
|
context "Ordered lists (:olist)" do
|
192
770
|
context "Simple lists" do
|
193
771
|
test "dot elements with no blank lines" do
|
194
|
-
|
195
|
-
|
772
|
+
input = <<-EOS
|
773
|
+
List
|
774
|
+
====
|
775
|
+
|
776
|
+
. Foo
|
777
|
+
. Boo
|
778
|
+
. Blech
|
779
|
+
EOS
|
780
|
+
output = render_string input
|
781
|
+
assert_xpath '//ol', output, 1
|
782
|
+
assert_xpath '//ol/li', output, 3
|
783
|
+
end
|
784
|
+
|
785
|
+
test "dot elements separated by blank lines should merge lists" do
|
786
|
+
input = <<-EOS
|
787
|
+
List
|
788
|
+
====
|
789
|
+
|
790
|
+
. Foo
|
791
|
+
|
792
|
+
. Boo
|
793
|
+
|
794
|
+
|
795
|
+
. Blech
|
796
|
+
EOS
|
797
|
+
output = render_string input
|
798
|
+
assert_xpath '//ol', output, 1
|
196
799
|
assert_xpath '//ol/li', output, 3
|
197
800
|
end
|
801
|
+
|
802
|
+
test "dot elements separated by line comment offset by blank lines should not merge lists" do
|
803
|
+
input = <<-EOS
|
804
|
+
List
|
805
|
+
====
|
806
|
+
|
807
|
+
. Foo
|
808
|
+
. Boo
|
809
|
+
|
810
|
+
//
|
811
|
+
|
812
|
+
. Blech
|
813
|
+
EOS
|
814
|
+
output = render_string input
|
815
|
+
assert_xpath '//ol', output, 2
|
816
|
+
assert_xpath '(//ol)[1]/li', output, 2
|
817
|
+
assert_xpath '(//ol)[2]/li', output, 1
|
818
|
+
end
|
819
|
+
|
820
|
+
test "dot elements separated by a block title offset by a blank line should not merge lists" do
|
821
|
+
input = <<-EOS
|
822
|
+
List
|
823
|
+
====
|
824
|
+
|
825
|
+
. Foo
|
826
|
+
. Boo
|
827
|
+
|
828
|
+
.Also
|
829
|
+
. Blech
|
830
|
+
EOS
|
831
|
+
output = render_string input
|
832
|
+
assert_xpath '//ol', output, 2
|
833
|
+
assert_xpath '(//ol)[1]/li', output, 2
|
834
|
+
assert_xpath '(//ol)[2]/li', output, 1
|
835
|
+
assert_xpath '(//ol)[2]/preceding-sibling::*[@class = "title"][text() = "Also"]', output, 1
|
836
|
+
end
|
198
837
|
end
|
199
838
|
end
|
200
839
|
|
201
840
|
context "Labeled lists (:dlist)" do
|
202
841
|
context "Simple lists" do
|
203
842
|
test "single-line adjacent elements" do
|
204
|
-
|
843
|
+
input = <<-EOS
|
844
|
+
term1:: def1
|
845
|
+
term2:: def2
|
846
|
+
EOS
|
847
|
+
output = render_string input
|
205
848
|
assert_xpath '//dl', output, 1
|
206
849
|
assert_xpath '//dl/dt', output, 2
|
207
850
|
assert_xpath '//dl/dt/following-sibling::dd', output, 2
|
@@ -212,7 +855,11 @@ context "Labeled lists (:dlist)" do
|
|
212
855
|
end
|
213
856
|
|
214
857
|
test "single-line indented adjacent elements" do
|
215
|
-
|
858
|
+
input = <<-EOS
|
859
|
+
term1:: def1
|
860
|
+
term2:: def2
|
861
|
+
EOS
|
862
|
+
output = render_string input
|
216
863
|
assert_xpath '//dl', output, 1
|
217
864
|
assert_xpath '//dl/dt', output, 2
|
218
865
|
assert_xpath '//dl/dt/following-sibling::dd', output, 2
|
@@ -222,15 +869,72 @@ context "Labeled lists (:dlist)" do
|
|
222
869
|
assert_xpath '(//dl/dt)[2]/following-sibling::dd/p[text() = "def2"]', output, 1
|
223
870
|
end
|
224
871
|
|
225
|
-
test "single-line elements separated by blank line" do
|
226
|
-
|
872
|
+
test "single-line elements separated by blank line should create a single list" do
|
873
|
+
input = <<-EOS
|
874
|
+
term1:: def1
|
875
|
+
|
876
|
+
term2:: def2
|
877
|
+
EOS
|
878
|
+
output = render_string input
|
227
879
|
assert_xpath '//dl', output, 1
|
228
880
|
assert_xpath '//dl/dt', output, 2
|
229
881
|
assert_xpath '//dl/dt/following-sibling::dd', output, 2
|
230
882
|
end
|
231
883
|
|
884
|
+
test "a line comment between elements should divide them into separate lists" do
|
885
|
+
input = <<-EOS
|
886
|
+
term1:: def1
|
887
|
+
|
888
|
+
//
|
889
|
+
|
890
|
+
term2:: def2
|
891
|
+
EOS
|
892
|
+
output = render_string input
|
893
|
+
assert_xpath '//dl', output, 2
|
894
|
+
assert_xpath '//dl/dt', output, 2
|
895
|
+
assert_xpath '(//dl)[1]/dt', output, 1
|
896
|
+
assert_xpath '(//dl)[2]/dt', output, 1
|
897
|
+
end
|
898
|
+
|
899
|
+
test "a ruler between elements should divide them into separate lists" do
|
900
|
+
input = <<-EOS
|
901
|
+
term1:: def1
|
902
|
+
|
903
|
+
'''
|
904
|
+
|
905
|
+
term2:: def2
|
906
|
+
EOS
|
907
|
+
output = render_string input
|
908
|
+
assert_xpath '//dl', output, 2
|
909
|
+
assert_xpath '//dl/dt', output, 2
|
910
|
+
assert_xpath '//dl//hr', output, 0
|
911
|
+
assert_xpath '(//dl)[1]/dt', output, 1
|
912
|
+
assert_xpath '(//dl)[2]/dt', output, 1
|
913
|
+
end
|
914
|
+
|
915
|
+
test "a block title between elements should divide them into separate lists" do
|
916
|
+
input = <<-EOS
|
917
|
+
term1:: def1
|
918
|
+
|
919
|
+
.Some more
|
920
|
+
term2:: def2
|
921
|
+
EOS
|
922
|
+
output = render_string input
|
923
|
+
assert_xpath '//dl', output, 2
|
924
|
+
assert_xpath '//dl/dt', output, 2
|
925
|
+
assert_xpath '(//dl)[1]/dt', output, 1
|
926
|
+
assert_xpath '(//dl)[2]/dt', output, 1
|
927
|
+
assert_xpath '(//dl)[2]/preceding-sibling::*[@class="title"][text() = "Some more"]', output, 1
|
928
|
+
end
|
929
|
+
|
232
930
|
test "multi-line elements with paragraph content" do
|
233
|
-
|
931
|
+
input = <<-EOS
|
932
|
+
term1::
|
933
|
+
def1
|
934
|
+
term2::
|
935
|
+
def2
|
936
|
+
EOS
|
937
|
+
output = render_string input
|
234
938
|
assert_xpath '//dl', output, 1
|
235
939
|
assert_xpath '//dl/dt', output, 2
|
236
940
|
assert_xpath '//dl/dt/following-sibling::dd', output, 2
|
@@ -241,7 +945,13 @@ context "Labeled lists (:dlist)" do
|
|
241
945
|
end
|
242
946
|
|
243
947
|
test "multi-line elements with indented paragraph content" do
|
244
|
-
|
948
|
+
input = <<-EOS
|
949
|
+
term1::
|
950
|
+
def1
|
951
|
+
term2::
|
952
|
+
def2
|
953
|
+
EOS
|
954
|
+
output = render_string input
|
245
955
|
assert_xpath '//dl', output, 1
|
246
956
|
assert_xpath '//dl/dt', output, 2
|
247
957
|
assert_xpath '//dl/dt/following-sibling::dd', output, 2
|
@@ -251,8 +961,32 @@ context "Labeled lists (:dlist)" do
|
|
251
961
|
assert_xpath '(//dl/dt)[2]/following-sibling::dd/p[text() = "def2"]', output, 1
|
252
962
|
end
|
253
963
|
|
964
|
+
test "multi-line element with multiple terms" do
|
965
|
+
input = <<-EOS
|
966
|
+
term1::
|
967
|
+
term2::
|
968
|
+
def2
|
969
|
+
EOS
|
970
|
+
output = render_string input
|
971
|
+
assert_xpath '//dl', output, 1
|
972
|
+
assert_xpath '//dl/dt', output, 2
|
973
|
+
assert_xpath '//dl/dd', output, 1
|
974
|
+
assert_xpath '(//dl/dt)[1]/following-sibling::dt', output, 1
|
975
|
+
assert_xpath '(//dl/dt)[1][normalize-space(text()) = "term1"]', output, 1
|
976
|
+
assert_xpath '(//dl/dt)[2]/following-sibling::dd', output, 1
|
977
|
+
assert_xpath '(//dl/dt)[2]/following-sibling::dd/p[text() = "def2"]', output, 1
|
978
|
+
end
|
979
|
+
|
254
980
|
test "multi-line elements with blank line before paragraph content" do
|
255
|
-
|
981
|
+
input = <<-EOS
|
982
|
+
term1::
|
983
|
+
|
984
|
+
def1
|
985
|
+
term2::
|
986
|
+
|
987
|
+
def2
|
988
|
+
EOS
|
989
|
+
output = render_string input
|
256
990
|
assert_xpath '//dl', output, 1
|
257
991
|
assert_xpath '//dl/dt', output, 2
|
258
992
|
assert_xpath '//dl/dt/following-sibling::dd', output, 2
|
@@ -263,7 +997,17 @@ context "Labeled lists (:dlist)" do
|
|
263
997
|
end
|
264
998
|
|
265
999
|
test "multi-line elements with paragraph and literal content" do
|
266
|
-
|
1000
|
+
# blank line following literal paragraph is required or else it will gobble up the second term
|
1001
|
+
input = <<-EOS
|
1002
|
+
term1::
|
1003
|
+
def1
|
1004
|
+
|
1005
|
+
literal
|
1006
|
+
|
1007
|
+
term2::
|
1008
|
+
def2
|
1009
|
+
EOS
|
1010
|
+
output = render_string input
|
267
1011
|
assert_xpath '//dl', output, 1
|
268
1012
|
assert_xpath '//dl/dt', output, 2
|
269
1013
|
assert_xpath '//dl/dt/following-sibling::dd', output, 2
|
@@ -275,7 +1019,12 @@ context "Labeled lists (:dlist)" do
|
|
275
1019
|
end
|
276
1020
|
|
277
1021
|
test "mixed single and multi-line adjacent elements" do
|
278
|
-
|
1022
|
+
input = <<-EOS
|
1023
|
+
term1:: def1
|
1024
|
+
term2::
|
1025
|
+
def2
|
1026
|
+
EOS
|
1027
|
+
output = render_string input
|
279
1028
|
assert_xpath '//dl', output, 1
|
280
1029
|
assert_xpath '//dl/dt', output, 2
|
281
1030
|
assert_xpath '//dl/dt/following-sibling::dd', output, 2
|
@@ -286,7 +1035,11 @@ context "Labeled lists (:dlist)" do
|
|
286
1035
|
end
|
287
1036
|
|
288
1037
|
test "element with anchor" do
|
289
|
-
|
1038
|
+
input = <<-EOS
|
1039
|
+
[[term1]]term1:: def1
|
1040
|
+
[[term2]]term2:: def2
|
1041
|
+
EOS
|
1042
|
+
output = render_string input
|
290
1043
|
assert_xpath '//dl', output, 1
|
291
1044
|
assert_xpath '//dl/dt', output, 2
|
292
1045
|
assert_xpath '(//dl/dt)[1]/a[@id = "term1"]', output, 1
|
@@ -294,14 +1047,249 @@ context "Labeled lists (:dlist)" do
|
|
294
1047
|
end
|
295
1048
|
|
296
1049
|
test "missing space before term does not produce labeled list" do
|
297
|
-
|
1050
|
+
input = <<-EOS
|
1051
|
+
term1::def1
|
1052
|
+
term2::def2
|
1053
|
+
EOS
|
1054
|
+
output = render_string input
|
298
1055
|
assert_xpath '//dl', output, 0
|
299
1056
|
end
|
1057
|
+
|
1058
|
+
test "literal block inside labeled list" do
|
1059
|
+
input = <<-EOS
|
1060
|
+
term::
|
1061
|
+
+
|
1062
|
+
....
|
1063
|
+
literal, line 1
|
1064
|
+
|
1065
|
+
literal, line 2
|
1066
|
+
....
|
1067
|
+
anotherterm:: def
|
1068
|
+
EOS
|
1069
|
+
output = render_string input
|
1070
|
+
assert_xpath '//dl/dt', output, 2
|
1071
|
+
assert_xpath '//dl/dd', output, 2
|
1072
|
+
assert_xpath '//dl/dd//pre', output, 1
|
1073
|
+
assert_xpath '(//dl/dd)[1]/*[@class="literalblock"]//pre', output, 1
|
1074
|
+
assert_xpath '(//dl/dd)[2]/p[text() = "def"]', output, 1
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
test "literal block inside labeled list with trailing line continuation" do
|
1078
|
+
input = <<-EOS
|
1079
|
+
term::
|
1080
|
+
+
|
1081
|
+
....
|
1082
|
+
literal, line 1
|
1083
|
+
|
1084
|
+
literal, line 2
|
1085
|
+
....
|
1086
|
+
+
|
1087
|
+
anotherterm:: def
|
1088
|
+
EOS
|
1089
|
+
output = render_string input
|
1090
|
+
assert_xpath '//dl/dt', output, 2
|
1091
|
+
assert_xpath '//dl/dd', output, 2
|
1092
|
+
assert_xpath '//dl/dd//pre', output, 1
|
1093
|
+
assert_xpath '(//dl/dd)[1]/*[@class="literalblock"]//pre', output, 1
|
1094
|
+
assert_xpath '(//dl/dd)[2]/p[text() = "def"]', output, 1
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
test "multiple listing blocks inside labeled list" do
|
1098
|
+
input = <<-EOS
|
1099
|
+
term::
|
1100
|
+
+
|
1101
|
+
----
|
1102
|
+
listing, line 1
|
1103
|
+
|
1104
|
+
listing, line 2
|
1105
|
+
----
|
1106
|
+
+
|
1107
|
+
----
|
1108
|
+
listing, line 1
|
1109
|
+
|
1110
|
+
listing, line 2
|
1111
|
+
----
|
1112
|
+
anotherterm:: def
|
1113
|
+
EOS
|
1114
|
+
output = render_string input
|
1115
|
+
assert_xpath '//dl/dt', output, 2
|
1116
|
+
assert_xpath '//dl/dd', output, 2
|
1117
|
+
assert_xpath '//dl/dd//pre', output, 2
|
1118
|
+
assert_xpath '(//dl/dd)[1]/*[@class="listingblock"]//pre', output, 2
|
1119
|
+
assert_xpath '(//dl/dd)[2]/p[text() = "def"]', output, 1
|
1120
|
+
end
|
1121
|
+
|
1122
|
+
test "open block inside labeled list" do
|
1123
|
+
input = <<-EOS
|
1124
|
+
term::
|
1125
|
+
+
|
1126
|
+
--
|
1127
|
+
Open block as definition of term.
|
1128
|
+
|
1129
|
+
And some more detail...
|
1130
|
+
--
|
1131
|
+
anotherterm:: def
|
1132
|
+
EOS
|
1133
|
+
output = render_string input
|
1134
|
+
assert_xpath '//dl/dd//p', output, 3
|
1135
|
+
assert_xpath '(//dl/dd)[1]//*[@class="openblock"]//p', output, 2
|
1136
|
+
end
|
1137
|
+
|
1138
|
+
test "paragraph attached by a list continuation in a labeled list" do
|
1139
|
+
input = <<-EOS
|
1140
|
+
term1:: def
|
1141
|
+
+
|
1142
|
+
more detail
|
1143
|
+
+
|
1144
|
+
term2:: def
|
1145
|
+
EOS
|
1146
|
+
output = render_string input
|
1147
|
+
assert_xpath '(//dl/dd)[1]//p', output, 2
|
1148
|
+
assert_xpath '(//dl/dd)[1]/p/following-sibling::*[@class="paragraph"]/p[text() = "more detail"]', output, 1
|
1149
|
+
end
|
1150
|
+
|
1151
|
+
test "paragraph attached by a list continuation to a multi-line element in a labeled list" do
|
1152
|
+
input = <<-EOS
|
1153
|
+
term1::
|
1154
|
+
def
|
1155
|
+
+
|
1156
|
+
more detail
|
1157
|
+
+
|
1158
|
+
term2:: def
|
1159
|
+
EOS
|
1160
|
+
output = render_string input
|
1161
|
+
assert_xpath '(//dl/dd)[1]//p', output, 2
|
1162
|
+
assert_xpath '(//dl/dd)[1]/p/following-sibling::*[@class="paragraph"]/p[text() = "more detail"]', output, 1
|
1163
|
+
end
|
1164
|
+
|
1165
|
+
test "verse paragraph inside a labeled list" do
|
1166
|
+
input = <<-EOS
|
1167
|
+
term1:: def
|
1168
|
+
+
|
1169
|
+
[verse]
|
1170
|
+
la la la
|
1171
|
+
|
1172
|
+
term2:: def
|
1173
|
+
EOS
|
1174
|
+
output = render_string input
|
1175
|
+
assert_xpath '//dl/dd//p', output, 2
|
1176
|
+
assert_xpath '(//dl/dd)[1]/*[@class="verseblock"]/pre[text() = "la la la"]', output, 1
|
1177
|
+
end
|
1178
|
+
|
1179
|
+
test "list inside a labeled list" do
|
1180
|
+
input = <<-EOS
|
1181
|
+
term1::
|
1182
|
+
* level 1
|
1183
|
+
** level 2
|
1184
|
+
* level 1
|
1185
|
+
term2:: def
|
1186
|
+
EOS
|
1187
|
+
output = render_string input
|
1188
|
+
assert_xpath '//dl/dd', output, 2
|
1189
|
+
assert_xpath '//dl/dd/p', output, 1
|
1190
|
+
assert_xpath '(//dl/dd)[1]//ul', output, 2
|
1191
|
+
assert_xpath '((//dl/dd)[1]//ul)[1]//ul', output, 1
|
1192
|
+
end
|
1193
|
+
|
1194
|
+
test "list inside a labeled list offset by blank lines" do
|
1195
|
+
input = <<-EOS
|
1196
|
+
term1::
|
1197
|
+
|
1198
|
+
* level 1
|
1199
|
+
** level 2
|
1200
|
+
* level 1
|
1201
|
+
|
1202
|
+
term2:: def
|
1203
|
+
EOS
|
1204
|
+
output = render_string input
|
1205
|
+
assert_xpath '//dl/dd', output, 2
|
1206
|
+
assert_xpath '//dl/dd/p', output, 1
|
1207
|
+
assert_xpath '(//dl/dd)[1]//ul', output, 2
|
1208
|
+
assert_xpath '((//dl/dd)[1]//ul)[1]//ul', output, 1
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
test "should only grab one line following last item if item has no inline definition" do
|
1212
|
+
input = <<-EOS
|
1213
|
+
term1::
|
1214
|
+
|
1215
|
+
def1
|
1216
|
+
|
1217
|
+
term2::
|
1218
|
+
|
1219
|
+
def2
|
1220
|
+
|
1221
|
+
A new paragraph
|
1222
|
+
|
1223
|
+
Another new paragraph
|
1224
|
+
EOS
|
1225
|
+
output = render_string input
|
1226
|
+
assert_xpath '//dl', output, 1
|
1227
|
+
assert_xpath '//dl/dd', output, 2
|
1228
|
+
assert_xpath '(//dl/dd)[1]/p[text() = "def1"]', output, 1
|
1229
|
+
assert_xpath '(//dl/dd)[2]/p[text() = "def2"]', output, 1
|
1230
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="paragraph"]', output, 2
|
1231
|
+
assert_xpath '(//*[@class="dlist"]/following-sibling::*[@class="paragraph"])[1]/p[text() = "A new paragraph"]', output, 1
|
1232
|
+
assert_xpath '(//*[@class="dlist"]/following-sibling::*[@class="paragraph"])[2]/p[text() = "Another new paragraph"]', output, 1
|
1233
|
+
end
|
1234
|
+
|
1235
|
+
test "should only grab one literal line following last item if item has no inline definition" do
|
1236
|
+
input = <<-EOS
|
1237
|
+
term1::
|
1238
|
+
|
1239
|
+
def1
|
1240
|
+
|
1241
|
+
term2::
|
1242
|
+
|
1243
|
+
def2
|
1244
|
+
|
1245
|
+
A new paragraph
|
1246
|
+
|
1247
|
+
Another new paragraph
|
1248
|
+
EOS
|
1249
|
+
output = render_string input
|
1250
|
+
assert_xpath '//dl', output, 1
|
1251
|
+
assert_xpath '//dl/dd', output, 2
|
1252
|
+
assert_xpath '(//dl/dd)[1]/p[text() = "def1"]', output, 1
|
1253
|
+
assert_xpath '(//dl/dd)[2]/p[text() = "def2"]', output, 1
|
1254
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="paragraph"]', output, 2
|
1255
|
+
assert_xpath '(//*[@class="dlist"]/following-sibling::*[@class="paragraph"])[1]/p[text() = "A new paragraph"]', output, 1
|
1256
|
+
assert_xpath '(//*[@class="dlist"]/following-sibling::*[@class="paragraph"])[2]/p[text() = "Another new paragraph"]', output, 1
|
1257
|
+
end
|
1258
|
+
|
1259
|
+
test "should append subsequent paragraph literals to list item as block content" do
|
1260
|
+
input = <<-EOS
|
1261
|
+
term1::
|
1262
|
+
|
1263
|
+
def1
|
1264
|
+
|
1265
|
+
term2::
|
1266
|
+
|
1267
|
+
def2
|
1268
|
+
|
1269
|
+
literal
|
1270
|
+
|
1271
|
+
A new paragraph.
|
1272
|
+
EOS
|
1273
|
+
output = render_string input
|
1274
|
+
assert_xpath '//dl', output, 1
|
1275
|
+
assert_xpath '//dl/dd', output, 2
|
1276
|
+
assert_xpath '(//dl/dd)[1]/p[text() = "def1"]', output, 1
|
1277
|
+
assert_xpath '(//dl/dd)[2]/p[text() = "def2"]', output, 1
|
1278
|
+
assert_xpath '(//dl/dd)[2]/p/following-sibling::*[@class="literalblock"]', output, 1
|
1279
|
+
assert_xpath '(//dl/dd)[2]/p/following-sibling::*[@class="literalblock"]//pre[text() = "literal"]', output, 1
|
1280
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="paragraph"]', output, 1
|
1281
|
+
assert_xpath '(//*[@class="dlist"]/following-sibling::*[@class="paragraph"])[1]/p[text() = "A new paragraph."]', output, 1
|
1282
|
+
end
|
300
1283
|
end
|
301
1284
|
|
302
1285
|
context "Nested lists" do
|
303
1286
|
test "single-line adjacent nested elements" do
|
304
|
-
|
1287
|
+
input = <<-EOS
|
1288
|
+
term1:: def1
|
1289
|
+
label1::: detail1
|
1290
|
+
term2:: def2
|
1291
|
+
EOS
|
1292
|
+
output = render_string input
|
305
1293
|
assert_xpath '//dl', output, 2
|
306
1294
|
assert_xpath '//dl//dl', output, 1
|
307
1295
|
assert_xpath '(//dl)[1]/dt[1][normalize-space(text()) = "term1"]', output, 1
|
@@ -313,13 +1301,27 @@ context "Labeled lists (:dlist)" do
|
|
313
1301
|
end
|
314
1302
|
|
315
1303
|
test "single-line adjacent maximum nested elements" do
|
316
|
-
|
1304
|
+
input = <<-EOS
|
1305
|
+
term1:: def1
|
1306
|
+
label1::: detail1
|
1307
|
+
name1:::: value1
|
1308
|
+
item1;; price1
|
1309
|
+
term2:: def2
|
1310
|
+
EOS
|
1311
|
+
output = render_string input
|
317
1312
|
assert_xpath '//dl', output, 4
|
318
1313
|
assert_xpath '//dl//dl//dl//dl', output, 1
|
319
1314
|
end
|
320
1315
|
|
321
1316
|
test "single-line nested elements seperated by blank line at top level" do
|
322
|
-
|
1317
|
+
input = <<-EOS
|
1318
|
+
term1:: def1
|
1319
|
+
|
1320
|
+
label1::: detail1
|
1321
|
+
|
1322
|
+
term2:: def2
|
1323
|
+
EOS
|
1324
|
+
output = render_string input
|
323
1325
|
assert_xpath '//dl', output, 2
|
324
1326
|
assert_xpath '//dl//dl', output, 1
|
325
1327
|
assert_xpath '(//dl)[1]/dt[1][normalize-space(text()) = "term1"]', output, 1
|
@@ -330,21 +1332,32 @@ context "Labeled lists (:dlist)" do
|
|
330
1332
|
assert_xpath '(//dl)[1]/dt[2]/following-sibling::dd/p[text() = "def2"]', output, 1
|
331
1333
|
end
|
332
1334
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
1335
|
+
test "single-line nested elements seperated by blank line at nested level" do
|
1336
|
+
input = <<-EOS
|
1337
|
+
term1:: def1
|
1338
|
+
label1::: detail1
|
1339
|
+
|
1340
|
+
label2::: detail2
|
1341
|
+
term2:: def2
|
1342
|
+
EOS
|
1343
|
+
output = render_string input
|
1344
|
+
assert_xpath '//dl', output, 2
|
1345
|
+
assert_xpath '//dl//dl', output, 1
|
1346
|
+
assert_xpath '(//dl)[1]/dt[1][normalize-space(text()) = "term1"]', output, 1
|
1347
|
+
assert_xpath '(//dl)[1]/dt[1]/following-sibling::dd/p[text() = "def1"]', output, 1
|
1348
|
+
assert_xpath '//dl//dl/dt[normalize-space(text()) = "label1"]', output, 1
|
1349
|
+
assert_xpath '//dl//dl/dt/following-sibling::dd/p[text() = "detail1"]', output, 1
|
1350
|
+
assert_xpath '(//dl)[1]/dt[2][normalize-space(text()) = "term2"]', output, 1
|
1351
|
+
assert_xpath '(//dl)[1]/dt[2]/following-sibling::dd/p[text() = "def2"]', output, 1
|
1352
|
+
end
|
345
1353
|
|
346
1354
|
test "single-line adjacent nested elements with alternate delimiters" do
|
347
|
-
|
1355
|
+
input = <<-EOS
|
1356
|
+
term1:: def1
|
1357
|
+
label1;; detail1
|
1358
|
+
term2:: def2
|
1359
|
+
EOS
|
1360
|
+
output = render_string input
|
348
1361
|
assert_xpath '//dl', output, 2
|
349
1362
|
assert_xpath '//dl//dl', output, 1
|
350
1363
|
assert_xpath '(//dl)[1]/dt[1][normalize-space(text()) = "term1"]', output, 1
|
@@ -356,7 +1369,15 @@ context "Labeled lists (:dlist)" do
|
|
356
1369
|
end
|
357
1370
|
|
358
1371
|
test "multi-line adjacent nested elements" do
|
359
|
-
|
1372
|
+
input = <<-EOS
|
1373
|
+
term1::
|
1374
|
+
def1
|
1375
|
+
label1:::
|
1376
|
+
detail1
|
1377
|
+
term2::
|
1378
|
+
def2
|
1379
|
+
EOS
|
1380
|
+
output = render_string input
|
360
1381
|
assert_xpath '//dl', output, 2
|
361
1382
|
assert_xpath '//dl//dl', output, 1
|
362
1383
|
assert_xpath '(//dl)[1]/dt[1][normalize-space(text()) = "term1"]', output, 1
|
@@ -367,21 +1388,60 @@ context "Labeled lists (:dlist)" do
|
|
367
1388
|
assert_xpath '(//dl)[1]/dt[2]/following-sibling::dd/p[text() = "def2"]', output, 1
|
368
1389
|
end
|
369
1390
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
1391
|
+
test "multi-line nested elements seperated by blank line at nested level repeated" do
|
1392
|
+
input = <<-EOS
|
1393
|
+
term1::
|
1394
|
+
def1
|
1395
|
+
label1:::
|
1396
|
+
|
1397
|
+
detail1
|
1398
|
+
label2:::
|
1399
|
+
detail2
|
1400
|
+
|
1401
|
+
term2:: def2
|
1402
|
+
EOS
|
1403
|
+
output = render_string input
|
1404
|
+
assert_xpath '//dl', output, 2
|
1405
|
+
assert_xpath '//dl//dl', output, 1
|
1406
|
+
assert_xpath '(//dl)[1]/dt[1][normalize-space(text()) = "term1"]', output, 1
|
1407
|
+
assert_xpath '(//dl)[1]/dt[1]/following-sibling::dd/p[text() = "def1"]', output, 1
|
1408
|
+
assert_xpath '(//dl//dl/dt)[1][normalize-space(text()) = "label1"]', output, 1
|
1409
|
+
assert_xpath '(//dl//dl/dt)[1]/following-sibling::dd/p[text() = "detail1"]', output, 1
|
1410
|
+
assert_xpath '(//dl//dl/dt)[2][normalize-space(text()) = "label2"]', output, 1
|
1411
|
+
assert_xpath '(//dl//dl/dt)[2]/following-sibling::dd/p[text() = "detail2"]', output, 1
|
1412
|
+
end
|
1413
|
+
|
1414
|
+
test "multi-line element with indented nested element" do
|
1415
|
+
input = <<-EOS
|
1416
|
+
term1::
|
1417
|
+
def1
|
1418
|
+
label1;;
|
1419
|
+
detail1
|
1420
|
+
term2::
|
1421
|
+
def2
|
1422
|
+
EOS
|
1423
|
+
output = render_string input
|
1424
|
+
assert_xpath '//dl', output, 2
|
1425
|
+
assert_xpath '//dl//dl', output, 1
|
1426
|
+
assert_xpath '(//dl)[1]/dt', output, 2
|
1427
|
+
assert_xpath '(//dl)[1]/dd', output, 2
|
1428
|
+
assert_xpath '((//dl)[1]/dt)[1][normalize-space(text()) = "term1"]', output, 1
|
1429
|
+
assert_xpath '((//dl)[1]/dt)[1]/following-sibling::dd/p[text() = "def1"]', output, 1
|
1430
|
+
assert_xpath '//dl//dl/dt', output, 1
|
1431
|
+
assert_xpath '//dl//dl/dt[normalize-space(text()) = "label1"]', output, 1
|
1432
|
+
assert_xpath '//dl//dl/dt/following-sibling::dd/p[text() = "detail1"]', output, 1
|
1433
|
+
assert_xpath '((//dl)[1]/dt)[2][normalize-space(text()) = "term2"]', output, 1
|
1434
|
+
assert_xpath '((//dl)[1]/dt)[2]/following-sibling::dd/p[text() = "def2"]', output, 1
|
1435
|
+
end
|
382
1436
|
|
383
1437
|
test "mixed single and multi-line elements with indented nested elements" do
|
384
|
-
|
1438
|
+
input = <<-EOS
|
1439
|
+
term1:: def1
|
1440
|
+
label1:::
|
1441
|
+
detail1
|
1442
|
+
term2:: def2
|
1443
|
+
EOS
|
1444
|
+
output = render_string input
|
385
1445
|
assert_xpath '//dl', output, 2
|
386
1446
|
assert_xpath '//dl//dl', output, 1
|
387
1447
|
assert_xpath '(//dl)[1]/dt[1][normalize-space(text()) = "term1"]', output, 1
|
@@ -393,7 +1453,13 @@ context "Labeled lists (:dlist)" do
|
|
393
1453
|
end
|
394
1454
|
|
395
1455
|
test "multi-line elements with first paragraph folded to text with adjacent nested element" do
|
396
|
-
|
1456
|
+
input = <<-EOS
|
1457
|
+
term1:: def1
|
1458
|
+
continued
|
1459
|
+
label1:::
|
1460
|
+
detail1
|
1461
|
+
EOS
|
1462
|
+
output = render_string input
|
397
1463
|
assert_xpath '//dl', output, 2
|
398
1464
|
assert_xpath '//dl//dl', output, 1
|
399
1465
|
assert_xpath '(//dl)[1]/dt[1][normalize-space(text()) = "term1"]', output, 1
|
@@ -404,3 +1470,1115 @@ context "Labeled lists (:dlist)" do
|
|
404
1470
|
end
|
405
1471
|
end
|
406
1472
|
end
|
1473
|
+
|
1474
|
+
context 'Labeled lists redux' do
|
1475
|
+
|
1476
|
+
context 'Item without text inline' do
|
1477
|
+
|
1478
|
+
test 'folds text from subsequent line' do
|
1479
|
+
input = <<-EOS
|
1480
|
+
== Lists
|
1481
|
+
|
1482
|
+
term1::
|
1483
|
+
def1
|
1484
|
+
EOS
|
1485
|
+
|
1486
|
+
output = render_embedded_string input
|
1487
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1488
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1489
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
1490
|
+
end
|
1491
|
+
|
1492
|
+
test 'folds text from first line after blank lines' do
|
1493
|
+
input = <<-EOS
|
1494
|
+
== Lists
|
1495
|
+
|
1496
|
+
term1::
|
1497
|
+
|
1498
|
+
|
1499
|
+
def1
|
1500
|
+
EOS
|
1501
|
+
|
1502
|
+
output = render_embedded_string input
|
1503
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1504
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1505
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
1506
|
+
end
|
1507
|
+
|
1508
|
+
test 'folds text from first line after blank line and immediately preceding next item' do
|
1509
|
+
input = <<-EOS
|
1510
|
+
== Lists
|
1511
|
+
|
1512
|
+
term1::
|
1513
|
+
|
1514
|
+
def1
|
1515
|
+
term2:: def2
|
1516
|
+
EOS
|
1517
|
+
|
1518
|
+
output = render_embedded_string input
|
1519
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1520
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 2
|
1521
|
+
assert_xpath '(//*[@class="dlist"]//dd)[1]/p[text()="def1"]', output, 1
|
1522
|
+
end
|
1523
|
+
|
1524
|
+
test 'folds text from first line after comment line' do
|
1525
|
+
input = <<-EOS
|
1526
|
+
== Lists
|
1527
|
+
|
1528
|
+
term1::
|
1529
|
+
// comment
|
1530
|
+
def1
|
1531
|
+
EOS
|
1532
|
+
|
1533
|
+
output = render_embedded_string input
|
1534
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1535
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1536
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
1537
|
+
end
|
1538
|
+
|
1539
|
+
test 'folds text from line following comment line offset by blank line' do
|
1540
|
+
input = <<-EOS
|
1541
|
+
== Lists
|
1542
|
+
|
1543
|
+
term1::
|
1544
|
+
|
1545
|
+
// comment
|
1546
|
+
def1
|
1547
|
+
EOS
|
1548
|
+
|
1549
|
+
output = render_embedded_string input
|
1550
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1551
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1552
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
1553
|
+
end
|
1554
|
+
|
1555
|
+
test 'folds text from subsequent indented line' do
|
1556
|
+
input = <<-EOS
|
1557
|
+
== Lists
|
1558
|
+
|
1559
|
+
term1::
|
1560
|
+
def1
|
1561
|
+
EOS
|
1562
|
+
|
1563
|
+
output = render_embedded_string input
|
1564
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1565
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1566
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
1567
|
+
end
|
1568
|
+
|
1569
|
+
test 'folds text from indented line after blank line' do
|
1570
|
+
input = <<-EOS
|
1571
|
+
== Lists
|
1572
|
+
|
1573
|
+
term1::
|
1574
|
+
|
1575
|
+
def1
|
1576
|
+
EOS
|
1577
|
+
|
1578
|
+
output = render_embedded_string input
|
1579
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1580
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1581
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
1582
|
+
end
|
1583
|
+
|
1584
|
+
test 'folds text that looks like ruler offset by blank line' do
|
1585
|
+
input = <<-EOS
|
1586
|
+
== Lists
|
1587
|
+
|
1588
|
+
term1::
|
1589
|
+
|
1590
|
+
'''
|
1591
|
+
EOS
|
1592
|
+
|
1593
|
+
output = render_embedded_string input
|
1594
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1595
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1596
|
+
assert_xpath %(//*[@class="dlist"]//dd/p/em[text()="'"]), output, 1
|
1597
|
+
end
|
1598
|
+
|
1599
|
+
test 'folds text that looks like ruler offset by blank line and line comment' do
|
1600
|
+
input = <<-EOS
|
1601
|
+
== Lists
|
1602
|
+
|
1603
|
+
term1::
|
1604
|
+
|
1605
|
+
// comment
|
1606
|
+
'''
|
1607
|
+
EOS
|
1608
|
+
|
1609
|
+
output = render_embedded_string input
|
1610
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1611
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1612
|
+
assert_xpath %(//*[@class="dlist"]//dd/p/em[text()="'"]), output, 1
|
1613
|
+
end
|
1614
|
+
|
1615
|
+
test 'folds text that looks like ruler and the line following it offset by blank line' do
|
1616
|
+
input = <<-EOS
|
1617
|
+
== Lists
|
1618
|
+
|
1619
|
+
term1::
|
1620
|
+
|
1621
|
+
'''
|
1622
|
+
continued
|
1623
|
+
EOS
|
1624
|
+
|
1625
|
+
output = render_embedded_string input
|
1626
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1627
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1628
|
+
assert_xpath %(//*[@class="dlist"]//dd/p/em[text()="'"]), output, 1
|
1629
|
+
assert_xpath %(//*[@class="dlist"]//dd/p[normalize-space(text())="continued"]), output, 1
|
1630
|
+
end
|
1631
|
+
|
1632
|
+
test 'folds text that looks like title offset by blank line' do
|
1633
|
+
input = <<-EOS
|
1634
|
+
== Lists
|
1635
|
+
|
1636
|
+
term1::
|
1637
|
+
|
1638
|
+
.def1
|
1639
|
+
EOS
|
1640
|
+
|
1641
|
+
output = render_embedded_string input
|
1642
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1643
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1644
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()=".def1"]', output, 1
|
1645
|
+
end
|
1646
|
+
|
1647
|
+
test 'folds text that looks like title offset by blank line and line comment' do
|
1648
|
+
input = <<-EOS
|
1649
|
+
== Lists
|
1650
|
+
|
1651
|
+
term1::
|
1652
|
+
|
1653
|
+
// comment
|
1654
|
+
.def1
|
1655
|
+
EOS
|
1656
|
+
|
1657
|
+
output = render_embedded_string input
|
1658
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1659
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1660
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()=".def1"]', output, 1
|
1661
|
+
end
|
1662
|
+
|
1663
|
+
test 'folds text that looks like admonition offset by blank line' do
|
1664
|
+
input = <<-EOS
|
1665
|
+
== Lists
|
1666
|
+
|
1667
|
+
term1::
|
1668
|
+
|
1669
|
+
NOTE: def1
|
1670
|
+
EOS
|
1671
|
+
|
1672
|
+
output = render_embedded_string input
|
1673
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1674
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1675
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="NOTE: def1"]', output, 1
|
1676
|
+
end
|
1677
|
+
|
1678
|
+
test 'folds text of first literal line offset by blank line appends subsequent literals offset by blank line as blocks' do
|
1679
|
+
input = <<-EOS
|
1680
|
+
== Lists
|
1681
|
+
|
1682
|
+
term1::
|
1683
|
+
|
1684
|
+
def1
|
1685
|
+
|
1686
|
+
literal
|
1687
|
+
|
1688
|
+
|
1689
|
+
literal
|
1690
|
+
EOS
|
1691
|
+
|
1692
|
+
output = render_embedded_string input
|
1693
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1694
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1695
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
1696
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="literalblock"]', output, 2
|
1697
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="literalblock"]//pre[text()="literal"]', output, 2
|
1698
|
+
end
|
1699
|
+
|
1700
|
+
test 'folds text of subsequent line and appends following literal line offset by blank line as block if term has no inline definition' do
|
1701
|
+
input = <<-EOS
|
1702
|
+
== Lists
|
1703
|
+
|
1704
|
+
term1::
|
1705
|
+
def1
|
1706
|
+
|
1707
|
+
literal
|
1708
|
+
|
1709
|
+
term2:: def2
|
1710
|
+
EOS
|
1711
|
+
|
1712
|
+
output = render_embedded_string input
|
1713
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1714
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 2
|
1715
|
+
assert_xpath '(//*[@class="dlist"]//dd)[1]/p[text()="def1"]', output, 1
|
1716
|
+
assert_xpath '(//*[@class="dlist"]//dd)[1]/p/following-sibling::*[@class="literalblock"]', output, 1
|
1717
|
+
assert_xpath '(//*[@class="dlist"]//dd)[1]/p/following-sibling::*[@class="literalblock"]//pre[text()="literal"]', output, 1
|
1718
|
+
end
|
1719
|
+
|
1720
|
+
test 'appends literal line attached by continuation as block if item has no inline definition' do
|
1721
|
+
input = <<-EOS
|
1722
|
+
== Lists
|
1723
|
+
|
1724
|
+
term1::
|
1725
|
+
+
|
1726
|
+
literal
|
1727
|
+
EOS
|
1728
|
+
|
1729
|
+
output = render_embedded_string input
|
1730
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1731
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1732
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1733
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="literalblock"]', output, 1
|
1734
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="literalblock"]//pre[text()="literal"]', output, 1
|
1735
|
+
end
|
1736
|
+
|
1737
|
+
test 'appends literal line attached by continuation as block if item has no inline definition followed by ruler' do
|
1738
|
+
input = <<-EOS
|
1739
|
+
== Lists
|
1740
|
+
|
1741
|
+
term1::
|
1742
|
+
+
|
1743
|
+
literal
|
1744
|
+
|
1745
|
+
'''
|
1746
|
+
EOS
|
1747
|
+
|
1748
|
+
output = render_embedded_string input
|
1749
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1750
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1751
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1752
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="literalblock"]', output, 1
|
1753
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="literalblock"]//pre[text()="literal"]', output, 1
|
1754
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::hr', output, 1
|
1755
|
+
end
|
1756
|
+
|
1757
|
+
test 'appends line attached by continuation as block if item has no inline definition followed by ruler' do
|
1758
|
+
input = <<-EOS
|
1759
|
+
== Lists
|
1760
|
+
|
1761
|
+
term1::
|
1762
|
+
+
|
1763
|
+
para
|
1764
|
+
|
1765
|
+
'''
|
1766
|
+
EOS
|
1767
|
+
|
1768
|
+
output = render_embedded_string input
|
1769
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1770
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1771
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1772
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]', output, 1
|
1773
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]/p[text()="para"]', output, 1
|
1774
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::hr', output, 1
|
1775
|
+
end
|
1776
|
+
|
1777
|
+
test 'appends line attached by continuation as block if item has no inline definition followed by block' do
|
1778
|
+
input = <<-EOS
|
1779
|
+
== Lists
|
1780
|
+
|
1781
|
+
term1::
|
1782
|
+
+
|
1783
|
+
para
|
1784
|
+
|
1785
|
+
....
|
1786
|
+
literal
|
1787
|
+
....
|
1788
|
+
EOS
|
1789
|
+
|
1790
|
+
output = render_embedded_string input
|
1791
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1792
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1793
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1794
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]', output, 1
|
1795
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]/p[text()="para"]', output, 1
|
1796
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="literalblock"]', output, 1
|
1797
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="literalblock"]//pre[text()="literal"]', output, 1
|
1798
|
+
end
|
1799
|
+
|
1800
|
+
test 'appends block attached by continuation but not subsequent block not attached by continuation' do
|
1801
|
+
input = <<-EOS
|
1802
|
+
== Lists
|
1803
|
+
|
1804
|
+
term1::
|
1805
|
+
+
|
1806
|
+
....
|
1807
|
+
literal
|
1808
|
+
....
|
1809
|
+
....
|
1810
|
+
detached
|
1811
|
+
....
|
1812
|
+
EOS
|
1813
|
+
|
1814
|
+
output = render_embedded_string input
|
1815
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1816
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1817
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1818
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="literalblock"]', output, 1
|
1819
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="literalblock"]//pre[text()="literal"]', output, 1
|
1820
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="literalblock"]', output, 1
|
1821
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="literalblock"]//pre[text()="detached"]', output, 1
|
1822
|
+
end
|
1823
|
+
|
1824
|
+
test 'appends list if item has no inline definition' do
|
1825
|
+
input = <<-EOS
|
1826
|
+
== Lists
|
1827
|
+
|
1828
|
+
term1::
|
1829
|
+
|
1830
|
+
* one
|
1831
|
+
* two
|
1832
|
+
* three
|
1833
|
+
EOS
|
1834
|
+
|
1835
|
+
output = render_embedded_string input
|
1836
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1837
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1838
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1839
|
+
assert_xpath '//*[@class="dlist"]//dd//ul/li', output, 3
|
1840
|
+
end
|
1841
|
+
|
1842
|
+
test 'appends list to first term when followed immediately by second term' do
|
1843
|
+
input = <<-EOS
|
1844
|
+
== Lists
|
1845
|
+
|
1846
|
+
term1::
|
1847
|
+
|
1848
|
+
* one
|
1849
|
+
* two
|
1850
|
+
* three
|
1851
|
+
term2:: def2
|
1852
|
+
EOS
|
1853
|
+
|
1854
|
+
output = render_embedded_string input
|
1855
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1856
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 2
|
1857
|
+
assert_xpath '(//*[@class="dlist"]//dd)[1]/p', output, 0
|
1858
|
+
assert_xpath '(//*[@class="dlist"]//dd)[1]//ul/li', output, 3
|
1859
|
+
assert_xpath '(//*[@class="dlist"]//dd)[2]/p[text()="def2"]', output, 1
|
1860
|
+
end
|
1861
|
+
|
1862
|
+
test 'appends list and paragraph block when line following list attached by continuation' do
|
1863
|
+
input = <<-EOS
|
1864
|
+
== Lists
|
1865
|
+
|
1866
|
+
term1::
|
1867
|
+
|
1868
|
+
* one
|
1869
|
+
* two
|
1870
|
+
* three
|
1871
|
+
|
1872
|
+
+
|
1873
|
+
para
|
1874
|
+
EOS
|
1875
|
+
|
1876
|
+
output = render_embedded_string input
|
1877
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1878
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1879
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1880
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="ulist"]', output, 1
|
1881
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="ulist"]/ul/li', output, 3
|
1882
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="ulist"]/following-sibling::*[@class="paragraph"]', output, 1
|
1883
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="ulist"]/following-sibling::*[@class="paragraph"]/p[text()="para"]', output, 1
|
1884
|
+
end
|
1885
|
+
|
1886
|
+
test 'first continued line associated with nested list item and second continued line associated with term' do
|
1887
|
+
input = <<-EOS
|
1888
|
+
== Lists
|
1889
|
+
|
1890
|
+
term1::
|
1891
|
+
* one
|
1892
|
+
+
|
1893
|
+
nested list para
|
1894
|
+
|
1895
|
+
+
|
1896
|
+
term1 para
|
1897
|
+
EOS
|
1898
|
+
|
1899
|
+
output = render_embedded_string input
|
1900
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1901
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1902
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1903
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="ulist"]', output, 1
|
1904
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="ulist"]/ul/li', output, 1
|
1905
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="ulist"]/ul/li/*[@class="paragraph"]/p[text()="nested list para"]', output, 1
|
1906
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="ulist"]/following-sibling::*[@class="paragraph"]', output, 1
|
1907
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="ulist"]/following-sibling::*[@class="paragraph"]/p[text()="term1 para"]', output, 1
|
1908
|
+
end
|
1909
|
+
|
1910
|
+
test 'literal line attached by continuation swallows adjacent line that looks like term' do
|
1911
|
+
input = <<-EOS
|
1912
|
+
== Lists
|
1913
|
+
|
1914
|
+
term1::
|
1915
|
+
+
|
1916
|
+
literal
|
1917
|
+
notnestedterm:::
|
1918
|
+
+
|
1919
|
+
literal
|
1920
|
+
notnestedterm:::
|
1921
|
+
EOS
|
1922
|
+
|
1923
|
+
output = render_embedded_string input
|
1924
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1925
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1926
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1927
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="literalblock"]', output, 2
|
1928
|
+
assert_xpath %(//*[@class="dlist"]//dd/*[@class="literalblock"]//pre[text()=" literal\nnotnestedterm:::"]), output, 2
|
1929
|
+
end
|
1930
|
+
|
1931
|
+
test 'line attached by continuation is appended as paragraph if term has no inline definition' do
|
1932
|
+
input = <<-EOS
|
1933
|
+
== Lists
|
1934
|
+
|
1935
|
+
term1::
|
1936
|
+
+
|
1937
|
+
para
|
1938
|
+
EOS
|
1939
|
+
|
1940
|
+
output = render_embedded_string input
|
1941
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1942
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1943
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1944
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]', output, 1
|
1945
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]/p[text()="para"]', output, 1
|
1946
|
+
end
|
1947
|
+
|
1948
|
+
test 'appends line as paragraph if attached by continuation following blank line and line comment when term has no inline definition' do
|
1949
|
+
input = <<-EOS
|
1950
|
+
== Lists
|
1951
|
+
|
1952
|
+
term1::
|
1953
|
+
|
1954
|
+
// comment
|
1955
|
+
+
|
1956
|
+
para
|
1957
|
+
EOS
|
1958
|
+
|
1959
|
+
output = render_embedded_string input
|
1960
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1961
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1962
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1963
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]', output, 1
|
1964
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]/p[text()="para"]', output, 1
|
1965
|
+
end
|
1966
|
+
|
1967
|
+
test 'line attached by continuation offset by blank line is appended as paragraph if term has no inline definition' do
|
1968
|
+
input = <<-EOS
|
1969
|
+
== Lists
|
1970
|
+
|
1971
|
+
term1::
|
1972
|
+
|
1973
|
+
+
|
1974
|
+
para
|
1975
|
+
EOS
|
1976
|
+
|
1977
|
+
output = render_embedded_string input
|
1978
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1979
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
1980
|
+
assert_xpath '//*[@class="dlist"]//dd/p', output, 0
|
1981
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]', output, 1
|
1982
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]/p[text()="para"]', output, 1
|
1983
|
+
end
|
1984
|
+
|
1985
|
+
test 'delimited block breaks list even when term has no inline definition' do
|
1986
|
+
input = <<-EOS
|
1987
|
+
== Lists
|
1988
|
+
|
1989
|
+
term1::
|
1990
|
+
====
|
1991
|
+
detached
|
1992
|
+
====
|
1993
|
+
EOS
|
1994
|
+
|
1995
|
+
output = render_embedded_string input
|
1996
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
1997
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 0
|
1998
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="exampleblock"]', output, 1
|
1999
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="exampleblock"]//p[text()="detached"]', output, 1
|
2000
|
+
end
|
2001
|
+
|
2002
|
+
test 'attribute line breaks list even when term has no inline definition' do
|
2003
|
+
input = <<-EOS
|
2004
|
+
== Lists
|
2005
|
+
|
2006
|
+
term1::
|
2007
|
+
[verse]
|
2008
|
+
detached
|
2009
|
+
EOS
|
2010
|
+
|
2011
|
+
output = render_embedded_string input
|
2012
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2013
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 0
|
2014
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="verseblock"]', output, 1
|
2015
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="verseblock"]/pre[text()="detached"]', output, 1
|
2016
|
+
end
|
2017
|
+
|
2018
|
+
test 'id line breaks list even when term has no inline definition' do
|
2019
|
+
input = <<-EOS
|
2020
|
+
== Lists
|
2021
|
+
|
2022
|
+
term1::
|
2023
|
+
[[id]]
|
2024
|
+
detached
|
2025
|
+
EOS
|
2026
|
+
|
2027
|
+
output = render_embedded_string input
|
2028
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2029
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 0
|
2030
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="paragraph"]', output, 1
|
2031
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="paragraph"]/p[text()="detached"]', output, 1
|
2032
|
+
end
|
2033
|
+
end
|
2034
|
+
|
2035
|
+
context 'Item with text inline' do
|
2036
|
+
|
2037
|
+
test 'folds text from inline definition and subsequent line' do
|
2038
|
+
input = <<-EOS
|
2039
|
+
== Lists
|
2040
|
+
|
2041
|
+
term1:: def1
|
2042
|
+
continued
|
2043
|
+
EOS
|
2044
|
+
|
2045
|
+
output = render_embedded_string input
|
2046
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2047
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2048
|
+
assert_xpath %(//*[@class="dlist"]//dd/p[text()="def1\ncontinued"]), output, 1
|
2049
|
+
end
|
2050
|
+
|
2051
|
+
test 'folds text from inline definition and subsequent lines' do
|
2052
|
+
input = <<-EOS
|
2053
|
+
== Lists
|
2054
|
+
|
2055
|
+
term1:: def1
|
2056
|
+
continued
|
2057
|
+
continued
|
2058
|
+
EOS
|
2059
|
+
|
2060
|
+
output = render_embedded_string input
|
2061
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2062
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2063
|
+
# NOTE the extra endline is added as a result of whitespace in the ERB template
|
2064
|
+
assert_xpath %(//*[@class="dlist"]//dd/p[text()="def1\ncontinued\n\ncontinued"]), output, 1
|
2065
|
+
end
|
2066
|
+
|
2067
|
+
test 'folds text from inline definition and line following comment line' do
|
2068
|
+
input = <<-EOS
|
2069
|
+
== Lists
|
2070
|
+
|
2071
|
+
term1:: def1
|
2072
|
+
// comment
|
2073
|
+
continued
|
2074
|
+
EOS
|
2075
|
+
|
2076
|
+
output = render_embedded_string input
|
2077
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2078
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2079
|
+
assert_xpath %(//*[@class="dlist"]//dd/p[text()="def1\ncontinued"]), output, 1
|
2080
|
+
end
|
2081
|
+
|
2082
|
+
test 'folds text from inline definition and subsequent indented line' do
|
2083
|
+
input = <<-EOS
|
2084
|
+
== Lists
|
2085
|
+
|
2086
|
+
term1:: def1
|
2087
|
+
continued
|
2088
|
+
EOS
|
2089
|
+
|
2090
|
+
output = render_embedded_string input
|
2091
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2092
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2093
|
+
assert_xpath %(//*[@class="dlist"]//dd/p[text()="def1\ncontinued"]), output, 1
|
2094
|
+
end
|
2095
|
+
|
2096
|
+
test 'appends literal line offset by blank line as block if item has inline definition' do
|
2097
|
+
input = <<-EOS
|
2098
|
+
== Lists
|
2099
|
+
|
2100
|
+
term1:: def1
|
2101
|
+
|
2102
|
+
literal
|
2103
|
+
EOS
|
2104
|
+
|
2105
|
+
output = render_embedded_string input
|
2106
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2107
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2108
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
2109
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="literalblock"]', output, 1
|
2110
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="literalblock"]//pre[text()="literal"]', output, 1
|
2111
|
+
end
|
2112
|
+
|
2113
|
+
test 'appends literal line offset by blank line as block and appends line after continuation as block if item has inline definition' do
|
2114
|
+
input = <<-EOS
|
2115
|
+
== Lists
|
2116
|
+
|
2117
|
+
term1:: def1
|
2118
|
+
|
2119
|
+
literal
|
2120
|
+
+
|
2121
|
+
para
|
2122
|
+
EOS
|
2123
|
+
|
2124
|
+
output = render_embedded_string input
|
2125
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2126
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2127
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
2128
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="literalblock"]', output, 1
|
2129
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="literalblock"]//pre[text()="literal"]', output, 1
|
2130
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="literalblock"]/following-sibling::*[@class="paragraph"]', output, 1
|
2131
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="literalblock"]/following-sibling::*[@class="paragraph"]/p[text()="para"]', output, 1
|
2132
|
+
end
|
2133
|
+
|
2134
|
+
test 'appends line after continuation as block and literal line offset by blank line as block if item has inline definition' do
|
2135
|
+
input = <<-EOS
|
2136
|
+
== Lists
|
2137
|
+
|
2138
|
+
term1:: def1
|
2139
|
+
+
|
2140
|
+
para
|
2141
|
+
|
2142
|
+
literal
|
2143
|
+
EOS
|
2144
|
+
|
2145
|
+
output = render_embedded_string input
|
2146
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2147
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2148
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
2149
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="paragraph"]', output, 1
|
2150
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="paragraph"]/p[text()="para"]', output, 1
|
2151
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]/following-sibling::*[@class="literalblock"]', output, 1
|
2152
|
+
assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]/following-sibling::*[@class="literalblock"]//pre[text()="literal"]', output, 1
|
2153
|
+
end
|
2154
|
+
|
2155
|
+
test 'appends list if item has inline definition' do
|
2156
|
+
input = <<-EOS
|
2157
|
+
== Lists
|
2158
|
+
|
2159
|
+
term1:: def1
|
2160
|
+
|
2161
|
+
* one
|
2162
|
+
* two
|
2163
|
+
* three
|
2164
|
+
EOS
|
2165
|
+
|
2166
|
+
output = render_embedded_string input
|
2167
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2168
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
2169
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="ulist"]', output, 1
|
2170
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="ulist"]/ul/li', output, 3
|
2171
|
+
end
|
2172
|
+
|
2173
|
+
test 'appends literal line attached by continuation as block if item has inline definition followed by ruler' do
|
2174
|
+
input = <<-EOS
|
2175
|
+
== Lists
|
2176
|
+
|
2177
|
+
term1:: def1
|
2178
|
+
+
|
2179
|
+
literal
|
2180
|
+
|
2181
|
+
'''
|
2182
|
+
EOS
|
2183
|
+
|
2184
|
+
output = render_embedded_string input
|
2185
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2186
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2187
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
2188
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="literalblock"]', output, 1
|
2189
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="literalblock"]//pre[text()="literal"]', output, 1
|
2190
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::hr', output, 1
|
2191
|
+
end
|
2192
|
+
|
2193
|
+
test 'line offset by blank line breaks list if term has inline definition' do
|
2194
|
+
input = <<-EOS
|
2195
|
+
== Lists
|
2196
|
+
|
2197
|
+
term1:: def1
|
2198
|
+
|
2199
|
+
detached
|
2200
|
+
EOS
|
2201
|
+
|
2202
|
+
output = render_embedded_string input
|
2203
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2204
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2205
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
2206
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="paragraph"]', output, 1
|
2207
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="paragraph"]/p[text()="detached"]', output, 1
|
2208
|
+
end
|
2209
|
+
|
2210
|
+
test 'nested term with definition does not consume following heading' do
|
2211
|
+
input = <<-EOS
|
2212
|
+
== Lists
|
2213
|
+
|
2214
|
+
term::
|
2215
|
+
def
|
2216
|
+
nestedterm;;
|
2217
|
+
nesteddef
|
2218
|
+
|
2219
|
+
Detached
|
2220
|
+
~~~~~~~~
|
2221
|
+
EOS
|
2222
|
+
|
2223
|
+
output = render_embedded_string input
|
2224
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 2
|
2225
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 2
|
2226
|
+
assert_xpath '//*[@class="dlist"]/dl//dl', output, 1
|
2227
|
+
assert_xpath '//*[@class="dlist"]/dl//dl/dt', output, 1
|
2228
|
+
assert_xpath '((//*[@class="dlist"])[1]//dd)[1]/p[text()="def"]', output, 1
|
2229
|
+
assert_xpath '((//*[@class="dlist"])[1]//dd)[1]/p/following-sibling::*[@class="dlist"]', output, 1
|
2230
|
+
assert_xpath '((//*[@class="dlist"])[1]//dd)[1]/p/following-sibling::*[@class="dlist"]//dd/p[text()="nesteddef"]', output, 1
|
2231
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="sect2"]', output, 1
|
2232
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="sect2"]/h3[text()="Detached"]', output, 1
|
2233
|
+
end
|
2234
|
+
|
2235
|
+
test 'line attached by continuation is appended as paragraph if term has inline definition followed by detached paragraph' do
|
2236
|
+
input = <<-EOS
|
2237
|
+
== Lists
|
2238
|
+
|
2239
|
+
term1:: def1
|
2240
|
+
+
|
2241
|
+
para
|
2242
|
+
|
2243
|
+
detached
|
2244
|
+
EOS
|
2245
|
+
|
2246
|
+
output = render_embedded_string input
|
2247
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2248
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2249
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
2250
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="paragraph"]', output, 1
|
2251
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="paragraph"]/p[text()="para"]', output, 1
|
2252
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="paragraph"]', output, 1
|
2253
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="paragraph"]/p[text()="detached"]', output, 1
|
2254
|
+
end
|
2255
|
+
|
2256
|
+
test 'line attached by continuation is appended as paragraph if term has inline definition followed by detached block' do
|
2257
|
+
input = <<-EOS
|
2258
|
+
== Lists
|
2259
|
+
|
2260
|
+
term1:: def1
|
2261
|
+
+
|
2262
|
+
para
|
2263
|
+
|
2264
|
+
****
|
2265
|
+
detached
|
2266
|
+
****
|
2267
|
+
EOS
|
2268
|
+
|
2269
|
+
output = render_embedded_string input
|
2270
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2271
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2272
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
2273
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="paragraph"]', output, 1
|
2274
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="paragraph"]/p[text()="para"]', output, 1
|
2275
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="sidebarblock"]', output, 1
|
2276
|
+
assert_xpath '//*[@class="dlist"]/following-sibling::*[@class="sidebarblock"]//p[text()="detached"]', output, 1
|
2277
|
+
end
|
2278
|
+
|
2279
|
+
test 'line attached by continuation offset by line comment is appended as paragraph if term has inline definition' do
|
2280
|
+
input = <<-EOS
|
2281
|
+
== Lists
|
2282
|
+
|
2283
|
+
term1:: def1
|
2284
|
+
// comment
|
2285
|
+
+
|
2286
|
+
para
|
2287
|
+
EOS
|
2288
|
+
|
2289
|
+
output = render_embedded_string input
|
2290
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2291
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2292
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
2293
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="paragraph"]', output, 1
|
2294
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="paragraph"]/p[text()="para"]', output, 1
|
2295
|
+
end
|
2296
|
+
|
2297
|
+
test 'line attached by continuation offset by blank line is appended as paragraph if term has inline definition' do
|
2298
|
+
input = <<-EOS
|
2299
|
+
== Lists
|
2300
|
+
|
2301
|
+
term1:: def1
|
2302
|
+
|
2303
|
+
+
|
2304
|
+
para
|
2305
|
+
EOS
|
2306
|
+
|
2307
|
+
output = render_embedded_string input
|
2308
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2309
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2310
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="def1"]', output, 1
|
2311
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="paragraph"]', output, 1
|
2312
|
+
assert_xpath '//*[@class="dlist"]//dd/p/following-sibling::*[@class="paragraph"]/p[text()="para"]', output, 1
|
2313
|
+
end
|
2314
|
+
|
2315
|
+
test 'line comment offset by blank line divides lists because item has text' do
|
2316
|
+
input = <<-EOS
|
2317
|
+
== Lists
|
2318
|
+
|
2319
|
+
term1:: def1
|
2320
|
+
|
2321
|
+
//
|
2322
|
+
|
2323
|
+
term2:: def2
|
2324
|
+
EOS
|
2325
|
+
|
2326
|
+
output = render_embedded_string input
|
2327
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 2
|
2328
|
+
end
|
2329
|
+
|
2330
|
+
test 'ruler offset by blank line divides lists because item has text' do
|
2331
|
+
input = <<-EOS
|
2332
|
+
== Lists
|
2333
|
+
|
2334
|
+
term1:: def1
|
2335
|
+
|
2336
|
+
'''
|
2337
|
+
|
2338
|
+
term2:: def2
|
2339
|
+
EOS
|
2340
|
+
|
2341
|
+
output = render_embedded_string input
|
2342
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 2
|
2343
|
+
end
|
2344
|
+
|
2345
|
+
test 'block title offset by blank line divides lists and becomes title of second list because item has text' do
|
2346
|
+
input = <<-EOS
|
2347
|
+
== Lists
|
2348
|
+
|
2349
|
+
term1:: def1
|
2350
|
+
|
2351
|
+
.title
|
2352
|
+
|
2353
|
+
term2:: def2
|
2354
|
+
EOS
|
2355
|
+
|
2356
|
+
output = render_embedded_string input
|
2357
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 2
|
2358
|
+
assert_xpath '(//*[@class="dlist"])[2]/*[@class="title"][text()="title"]', output, 1
|
2359
|
+
end
|
2360
|
+
end
|
2361
|
+
end
|
2362
|
+
|
2363
|
+
context 'Callout lists' do
|
2364
|
+
test 'listing block with sequential callouts followed by adjacent callout list' do
|
2365
|
+
input = <<-EOS
|
2366
|
+
[source]
|
2367
|
+
----
|
2368
|
+
require 'asciidoctor' # <1>
|
2369
|
+
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
2370
|
+
puts doc.render # <3>
|
2371
|
+
----
|
2372
|
+
<1> Describe the first line
|
2373
|
+
<2> Describe the second line
|
2374
|
+
<3> Describe the third line
|
2375
|
+
EOS
|
2376
|
+
output = render_string input, :attributes => {'backend' => 'docbook45'}
|
2377
|
+
assert_xpath '//programlisting', output, 1
|
2378
|
+
assert_xpath '//programlisting//co', output, 3
|
2379
|
+
assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
|
2380
|
+
assert_xpath '(//programlisting//co)[2][@id = "CO1-2"]', output, 1
|
2381
|
+
assert_xpath '(//programlisting//co)[3][@id = "CO1-3"]', output, 1
|
2382
|
+
assert_xpath '//programlisting/following-sibling::calloutlist/callout', output, 3
|
2383
|
+
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[1][@arearefs = "CO1-1"]', output, 1
|
2384
|
+
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[2][@arearefs = "CO1-2"]', output, 1
|
2385
|
+
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[3][@arearefs = "CO1-3"]', output, 1
|
2386
|
+
end
|
2387
|
+
|
2388
|
+
test 'listing block with sequential callouts followed by non-adjacent callout list' do
|
2389
|
+
input = <<-EOS
|
2390
|
+
[source]
|
2391
|
+
----
|
2392
|
+
require 'asciidoctor' # <1>
|
2393
|
+
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
2394
|
+
puts doc.render # <3>
|
2395
|
+
----
|
2396
|
+
|
2397
|
+
Paragraph.
|
2398
|
+
|
2399
|
+
<1> Describe the first line
|
2400
|
+
<2> Describe the second line
|
2401
|
+
<3> Describe the third line
|
2402
|
+
EOS
|
2403
|
+
output = render_string input, :attributes => {'backend' => 'docbook45'}
|
2404
|
+
assert_xpath '//programlisting', output, 1
|
2405
|
+
assert_xpath '//programlisting//co', output, 3
|
2406
|
+
assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
|
2407
|
+
assert_xpath '(//programlisting//co)[2][@id = "CO1-2"]', output, 1
|
2408
|
+
assert_xpath '(//programlisting//co)[3][@id = "CO1-3"]', output, 1
|
2409
|
+
assert_xpath '//programlisting/following-sibling::*[1][self::simpara]', output, 1
|
2410
|
+
assert_xpath '//programlisting/following-sibling::calloutlist/callout', output, 3
|
2411
|
+
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[1][@arearefs = "CO1-1"]', output, 1
|
2412
|
+
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[2][@arearefs = "CO1-2"]', output, 1
|
2413
|
+
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[3][@arearefs = "CO1-3"]', output, 1
|
2414
|
+
end
|
2415
|
+
|
2416
|
+
test 'listing block with a callout that refers to two different lines' do
|
2417
|
+
input = <<-EOS
|
2418
|
+
[source]
|
2419
|
+
----
|
2420
|
+
require 'asciidoctor' # <1>
|
2421
|
+
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
2422
|
+
puts doc.render # <2>
|
2423
|
+
----
|
2424
|
+
<1> Import the library
|
2425
|
+
<2> Where the magic happens
|
2426
|
+
EOS
|
2427
|
+
output = render_string input, :attributes => {'backend' => 'docbook45'}
|
2428
|
+
assert_xpath '//programlisting', output, 1
|
2429
|
+
assert_xpath '//programlisting//co', output, 3
|
2430
|
+
assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
|
2431
|
+
assert_xpath '(//programlisting//co)[2][@id = "CO1-2"]', output, 1
|
2432
|
+
assert_xpath '(//programlisting//co)[3][@id = "CO1-3"]', output, 1
|
2433
|
+
assert_xpath '//programlisting/following-sibling::calloutlist/callout', output, 2
|
2434
|
+
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[1][@arearefs = "CO1-1"]', output, 1
|
2435
|
+
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[2][@arearefs = "CO1-2 CO1-3"]', output, 1
|
2436
|
+
end
|
2437
|
+
|
2438
|
+
test 'listing block with non-sequential callouts followed by adjacent callout list' do
|
2439
|
+
input = <<-EOS
|
2440
|
+
[source]
|
2441
|
+
----
|
2442
|
+
require 'asciidoctor' # <2>
|
2443
|
+
doc = Asciidoctor::Document.new('Hello, World!') # <3>
|
2444
|
+
puts doc.render # <1>
|
2445
|
+
----
|
2446
|
+
<1> Describe the first line
|
2447
|
+
<2> Describe the second line
|
2448
|
+
<3> Describe the third line
|
2449
|
+
EOS
|
2450
|
+
output = render_string input, :attributes => {'backend' => 'docbook45'}
|
2451
|
+
assert_xpath '//programlisting', output, 1
|
2452
|
+
assert_xpath '//programlisting//co', output, 3
|
2453
|
+
assert_xpath '(//programlisting//co)[1][@id = "CO1-1"]', output, 1
|
2454
|
+
assert_xpath '(//programlisting//co)[2][@id = "CO1-2"]', output, 1
|
2455
|
+
assert_xpath '(//programlisting//co)[3][@id = "CO1-3"]', output, 1
|
2456
|
+
assert_xpath '//programlisting/following-sibling::calloutlist/callout', output, 3
|
2457
|
+
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[1][@arearefs = "CO1-3"]', output, 1
|
2458
|
+
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[2][@arearefs = "CO1-1"]', output, 1
|
2459
|
+
assert_xpath '(//programlisting/following-sibling::calloutlist/callout)[3][@arearefs = "CO1-2"]', output, 1
|
2460
|
+
end
|
2461
|
+
|
2462
|
+
test 'two listing blocks can share the same callout list' do
|
2463
|
+
input = <<-EOS
|
2464
|
+
.Import library
|
2465
|
+
[source]
|
2466
|
+
----
|
2467
|
+
require 'asciidoctor' # <1>
|
2468
|
+
----
|
2469
|
+
|
2470
|
+
.Use library
|
2471
|
+
[source]
|
2472
|
+
----
|
2473
|
+
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
2474
|
+
puts doc.render # <3>
|
2475
|
+
----
|
2476
|
+
|
2477
|
+
<1> Describe the first line
|
2478
|
+
<2> Describe the second line
|
2479
|
+
<3> Describe the third line
|
2480
|
+
EOS
|
2481
|
+
output = render_string input, :attributes => {'backend' => 'docbook45'}
|
2482
|
+
assert_xpath '//programlisting', output, 2
|
2483
|
+
assert_xpath '(//programlisting)[1]//co', output, 1
|
2484
|
+
assert_xpath '(//programlisting)[1]//co[@id = "CO1-1"]', output, 1
|
2485
|
+
assert_xpath '(//programlisting)[2]//co', output, 2
|
2486
|
+
assert_xpath '((//programlisting)[2]//co)[1][@id = "CO1-2"]', output, 1
|
2487
|
+
assert_xpath '((//programlisting)[2]//co)[2][@id = "CO1-3"]', output, 1
|
2488
|
+
assert_xpath '(//calloutlist/callout)[1][@arearefs = "CO1-1"]', output, 1
|
2489
|
+
assert_xpath '(//calloutlist/callout)[2][@arearefs = "CO1-2"]', output, 1
|
2490
|
+
assert_xpath '(//calloutlist/callout)[3][@arearefs = "CO1-3"]', output, 1
|
2491
|
+
end
|
2492
|
+
|
2493
|
+
test 'two listing blocks each followed by an adjacent callout list' do
|
2494
|
+
input = <<-EOS
|
2495
|
+
.Import library
|
2496
|
+
[source]
|
2497
|
+
----
|
2498
|
+
require 'asciidoctor' # <1>
|
2499
|
+
----
|
2500
|
+
<1> Describe the first line
|
2501
|
+
|
2502
|
+
.Use library
|
2503
|
+
[source]
|
2504
|
+
----
|
2505
|
+
doc = Asciidoctor::Document.new('Hello, World!') # <1>
|
2506
|
+
puts doc.render # <2>
|
2507
|
+
----
|
2508
|
+
<1> Describe the second line
|
2509
|
+
<2> Describe the third line
|
2510
|
+
EOS
|
2511
|
+
output = render_string input, :attributes => {'backend' => 'docbook45'}
|
2512
|
+
assert_xpath '//programlisting', output, 2
|
2513
|
+
assert_xpath '(//programlisting)[1]//co', output, 1
|
2514
|
+
assert_xpath '(//programlisting)[1]//co[@id = "CO1-1"]', output, 1
|
2515
|
+
assert_xpath '(//programlisting)[2]//co', output, 2
|
2516
|
+
assert_xpath '((//programlisting)[2]//co)[1][@id = "CO2-1"]', output, 1
|
2517
|
+
assert_xpath '((//programlisting)[2]//co)[2][@id = "CO2-2"]', output, 1
|
2518
|
+
assert_xpath '//calloutlist', output, 2
|
2519
|
+
assert_xpath '(//calloutlist)[1]/callout', output, 1
|
2520
|
+
assert_xpath '((//calloutlist)[1]/callout)[1][@arearefs = "CO1-1"]', output, 1
|
2521
|
+
assert_xpath '(//calloutlist)[2]/callout', output, 2
|
2522
|
+
assert_xpath '((//calloutlist)[2]/callout)[1][@arearefs = "CO2-1"]', output, 1
|
2523
|
+
assert_xpath '((//calloutlist)[2]/callout)[2][@arearefs = "CO2-2"]', output, 1
|
2524
|
+
end
|
2525
|
+
|
2526
|
+
test 'callout list with block content' do
|
2527
|
+
input = <<-EOS
|
2528
|
+
[source]
|
2529
|
+
----
|
2530
|
+
require 'asciidoctor' # <1>
|
2531
|
+
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
2532
|
+
puts doc.render # <3>
|
2533
|
+
----
|
2534
|
+
<1> Imports the library
|
2535
|
+
as a RubyGem
|
2536
|
+
<2> Creates a new document
|
2537
|
+
* Scans the lines for known blocks
|
2538
|
+
* Converts the lines into blocks
|
2539
|
+
<3> Renders the document
|
2540
|
+
+
|
2541
|
+
You can write this to file rather than printing to stdout.
|
2542
|
+
EOS
|
2543
|
+
output = render_string input, :attributes => {'backend' => 'docbook45'}
|
2544
|
+
assert_xpath '//calloutlist', output, 1
|
2545
|
+
assert_xpath '//calloutlist/callout', output, 3
|
2546
|
+
assert_xpath '(//calloutlist/callout)[1]/*', output, 1
|
2547
|
+
assert_xpath '(//calloutlist/callout)[2]/para', output, 1
|
2548
|
+
assert_xpath '(//calloutlist/callout)[2]/itemizedlist', output, 1
|
2549
|
+
assert_xpath '(//calloutlist/callout)[3]/para', output, 1
|
2550
|
+
assert_xpath '(//calloutlist/callout)[3]/simpara', output, 1
|
2551
|
+
end
|
2552
|
+
|
2553
|
+
test 'escaped callout should not be interpreted as a callout' do
|
2554
|
+
input = <<-EOS
|
2555
|
+
[source]
|
2556
|
+
----
|
2557
|
+
require 'asciidoctor' # \\<1>
|
2558
|
+
----
|
2559
|
+
EOS
|
2560
|
+
output = render_string input, :attributes => {'backend' => 'docbook45'}
|
2561
|
+
assert_xpath '//co', output, 0
|
2562
|
+
end
|
2563
|
+
|
2564
|
+
test 'literal block with callouts' do
|
2565
|
+
input = <<-EOS
|
2566
|
+
....
|
2567
|
+
Roses are red <1>
|
2568
|
+
Violets are blue <2>
|
2569
|
+
....
|
2570
|
+
|
2571
|
+
|
2572
|
+
<1> And so is Ruby
|
2573
|
+
<2> But violet is more like purple
|
2574
|
+
EOS
|
2575
|
+
output = render_string input, :attributes => {'backend' => 'docbook45'}
|
2576
|
+
assert_xpath '//literallayout', output, 1
|
2577
|
+
assert_xpath '//literallayout//co', output, 2
|
2578
|
+
assert_xpath '(//literallayout//co)[1][@id = "CO1-1"]', output, 1
|
2579
|
+
assert_xpath '(//literallayout//co)[2][@id = "CO1-2"]', output, 1
|
2580
|
+
assert_xpath '//literallayout/following-sibling::*[1][self::calloutlist]/callout', output, 2
|
2581
|
+
assert_xpath '(//literallayout/following-sibling::*[1][self::calloutlist]/callout)[1][@arearefs = "CO1-1"]', output, 1
|
2582
|
+
assert_xpath '(//literallayout/following-sibling::*[1][self::calloutlist]/callout)[2][@arearefs = "CO1-2"]', output, 1
|
2583
|
+
end
|
2584
|
+
end
|