asciidoctor 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of asciidoctor might be problematic. Click here for more details.

Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +1 -1
  3. data/LICENSE +2 -2
  4. data/README.adoc +461 -0
  5. data/asciidoctor.gemspec +27 -16
  6. data/compat/asciidoc.conf +139 -0
  7. data/lib/asciidoctor.rb +212 -69
  8. data/lib/asciidoctor/abstract_block.rb +41 -0
  9. data/lib/asciidoctor/abstract_node.rb +128 -81
  10. data/lib/asciidoctor/attribute_list.rb +5 -2
  11. data/lib/asciidoctor/backends/base_template.rb +16 -4
  12. data/lib/asciidoctor/backends/docbook45.rb +112 -42
  13. data/lib/asciidoctor/backends/html5.rb +206 -90
  14. data/lib/asciidoctor/block.rb +5 -5
  15. data/lib/asciidoctor/cli/invoker.rb +38 -34
  16. data/lib/asciidoctor/cli/options.rb +3 -3
  17. data/lib/asciidoctor/document.rb +115 -13
  18. data/lib/asciidoctor/helpers.rb +16 -0
  19. data/lib/asciidoctor/lexer.rb +486 -359
  20. data/lib/asciidoctor/path_resolver.rb +360 -0
  21. data/lib/asciidoctor/reader.rb +122 -23
  22. data/lib/asciidoctor/renderer.rb +1 -33
  23. data/lib/asciidoctor/section.rb +1 -1
  24. data/lib/asciidoctor/substituters.rb +103 -19
  25. data/lib/asciidoctor/version.rb +1 -1
  26. data/man/asciidoctor.1 +6 -6
  27. data/man/asciidoctor.ad +5 -3
  28. data/stylesheets/asciidoctor.css +274 -0
  29. data/test/attributes_test.rb +133 -10
  30. data/test/blocks_test.rb +302 -17
  31. data/test/document_test.rb +269 -6
  32. data/test/fixtures/basic-docinfo.html +1 -0
  33. data/test/fixtures/basic-docinfo.xml +4 -0
  34. data/test/fixtures/basic.asciidoc +4 -0
  35. data/test/fixtures/docinfo.html +1 -0
  36. data/test/fixtures/docinfo.xml +2 -0
  37. data/test/fixtures/include-file.asciidoc +22 -1
  38. data/test/fixtures/stylesheets/custom.css +3 -0
  39. data/test/invoker_test.rb +38 -6
  40. data/test/lexer_test.rb +64 -21
  41. data/test/links_test.rb +4 -0
  42. data/test/lists_test.rb +251 -12
  43. data/test/paragraphs_test.rb +225 -30
  44. data/test/paths_test.rb +174 -0
  45. data/test/reader_test.rb +89 -2
  46. data/test/sections_test.rb +518 -16
  47. data/test/substitutions_test.rb +121 -10
  48. data/test/tables_test.rb +53 -13
  49. data/test/test_helper.rb +2 -2
  50. data/test/text_test.rb +5 -5
  51. metadata +46 -50
  52. data/README.asciidoc +0 -296
  53. data/lib/asciidoctor/errors.rb +0 -5
@@ -154,7 +154,15 @@ context "Lexer" do
154
154
  test "collect options attribute" do
155
155
  attributes = {}
156
156
  line = "quote, options='opt1,opt2 , opt3'"
157
- expected = {1 => 'quote', 'options' => 'opt1,opt2 , opt3', 'opt1-option' => nil, 'opt2-option' => nil, 'opt3-option' => nil}
157
+ expected = {1 => 'quote', 'options' => 'opt1,opt2 , opt3', 'opt1-option' => '', 'opt2-option' => '', 'opt3-option' => ''}
158
+ Asciidoctor::AttributeList.new(line).parse_into(attributes)
159
+ assert_equal expected, attributes
160
+ end
161
+
162
+ test "collect opts attribute as options" do
163
+ attributes = {}
164
+ line = "quote, opts='opt1,opt2 , opt3'"
165
+ expected = {1 => 'quote', 'options' => 'opt1,opt2 , opt3', 'opt1-option' => '', 'opt2-option' => '', 'opt3-option' => ''}
158
166
  Asciidoctor::AttributeList.new(line).parse_into(attributes)
159
167
  assert_equal expected, attributes
160
168
  end
@@ -176,16 +184,19 @@ context "Lexer" do
176
184
 
177
185
  test "parse author first" do
178
186
  metadata, = parse_header_metadata 'Stuart'
179
- assert_equal 3, metadata.size
180
- assert_equal 'Stuart', metadata['author']
187
+ assert_equal 5, metadata.size
188
+ assert_equal 1, metadata['authorcount']
189
+ assert_equal metadata['author'], metadata['authors']
181
190
  assert_equal 'Stuart', metadata['firstname']
182
191
  assert_equal 'S', metadata['authorinitials']
183
192
  end
184
193
 
185
194
  test "parse author first last" do
186
195
  metadata, = parse_header_metadata 'Yukihiro Matsumoto'
187
- assert_equal 4, metadata.size
196
+ assert_equal 6, metadata.size
197
+ assert_equal 1, metadata['authorcount']
188
198
  assert_equal 'Yukihiro Matsumoto', metadata['author']
199
+ assert_equal metadata['author'], metadata['authors']
189
200
  assert_equal 'Yukihiro', metadata['firstname']
190
201
  assert_equal 'Matsumoto', metadata['lastname']
191
202
  assert_equal 'YM', metadata['authorinitials']
@@ -193,8 +204,10 @@ context "Lexer" do
193
204
 
194
205
  test "parse author first middle last" do
195
206
  metadata, = parse_header_metadata 'David Heinemeier Hansson'
196
- assert_equal 5, metadata.size
207
+ assert_equal 7, metadata.size
208
+ assert_equal 1, metadata['authorcount']
197
209
  assert_equal 'David Heinemeier Hansson', metadata['author']
210
+ assert_equal metadata['author'], metadata['authors']
198
211
  assert_equal 'David', metadata['firstname']
199
212
  assert_equal 'Heinemeier', metadata['middlename']
200
213
  assert_equal 'Hansson', metadata['lastname']
@@ -203,8 +216,10 @@ context "Lexer" do
203
216
 
204
217
  test "parse author first middle last email" do
205
218
  metadata, = parse_header_metadata 'David Heinemeier Hansson <rails@ruby-lang.org>'
206
- assert_equal 6, metadata.size
219
+ assert_equal 8, metadata.size
220
+ assert_equal 1, metadata['authorcount']
207
221
  assert_equal 'David Heinemeier Hansson', metadata['author']
222
+ assert_equal metadata['author'], metadata['authors']
208
223
  assert_equal 'David', metadata['firstname']
209
224
  assert_equal 'Heinemeier', metadata['middlename']
210
225
  assert_equal 'Hansson', metadata['lastname']
@@ -214,8 +229,10 @@ context "Lexer" do
214
229
 
215
230
  test "parse author first email" do
216
231
  metadata, = parse_header_metadata 'Stuart <founder@asciidoc.org>'
217
- assert_equal 4, metadata.size
232
+ assert_equal 6, metadata.size
233
+ assert_equal 1, metadata['authorcount']
218
234
  assert_equal 'Stuart', metadata['author']
235
+ assert_equal metadata['author'], metadata['authors']
219
236
  assert_equal 'Stuart', metadata['firstname']
220
237
  assert_equal 'founder@asciidoc.org', metadata['email']
221
238
  assert_equal 'S', metadata['authorinitials']
@@ -223,8 +240,10 @@ context "Lexer" do
223
240
 
224
241
  test "parse author first last email" do
225
242
  metadata, = parse_header_metadata 'Stuart Rackham <founder@asciidoc.org>'
226
- assert_equal 5, metadata.size
243
+ assert_equal 7, metadata.size
244
+ assert_equal 1, metadata['authorcount']
227
245
  assert_equal 'Stuart Rackham', metadata['author']
246
+ assert_equal metadata['author'], metadata['authors']
228
247
  assert_equal 'Stuart', metadata['firstname']
229
248
  assert_equal 'Rackham', metadata['lastname']
230
249
  assert_equal 'founder@asciidoc.org', metadata['email']
@@ -233,8 +252,10 @@ context "Lexer" do
233
252
 
234
253
  test "parse author with hyphen" do
235
254
  metadata, = parse_header_metadata 'Tim Berners-Lee <founder@www.org>'
236
- assert_equal 5, metadata.size
255
+ assert_equal 7, metadata.size
256
+ assert_equal 1, metadata['authorcount']
237
257
  assert_equal 'Tim Berners-Lee', metadata['author']
258
+ assert_equal metadata['author'], metadata['authors']
238
259
  assert_equal 'Tim', metadata['firstname']
239
260
  assert_equal 'Berners-Lee', metadata['lastname']
240
261
  assert_equal 'founder@www.org', metadata['email']
@@ -243,8 +264,10 @@ context "Lexer" do
243
264
 
244
265
  test "parse author with single quote" do
245
266
  metadata, = parse_header_metadata 'Stephen O\'Grady <founder@redmonk.com>'
246
- assert_equal 5, metadata.size
267
+ assert_equal 7, metadata.size
268
+ assert_equal 1, metadata['authorcount']
247
269
  assert_equal 'Stephen O\'Grady', metadata['author']
270
+ assert_equal metadata['author'], metadata['authors']
248
271
  assert_equal 'Stephen', metadata['firstname']
249
272
  assert_equal 'O\'Grady', metadata['lastname']
250
273
  assert_equal 'founder@redmonk.com', metadata['email']
@@ -253,8 +276,10 @@ context "Lexer" do
253
276
 
254
277
  test "parse author with dotted initial" do
255
278
  metadata, = parse_header_metadata 'Heiko W. Rupp <hwr@example.de>'
256
- assert_equal 6, metadata.size
279
+ assert_equal 8, metadata.size
280
+ assert_equal 1, metadata['authorcount']
257
281
  assert_equal 'Heiko W. Rupp', metadata['author']
282
+ assert_equal metadata['author'], metadata['authors']
258
283
  assert_equal 'Heiko', metadata['firstname']
259
284
  assert_equal 'W.', metadata['middlename']
260
285
  assert_equal 'Rupp', metadata['lastname']
@@ -264,8 +289,10 @@ context "Lexer" do
264
289
 
265
290
  test "parse author with underscore" do
266
291
  metadata, = parse_header_metadata 'Tim_E Fella'
267
- assert_equal 4, metadata.size
292
+ assert_equal 6, metadata.size
293
+ assert_equal 1, metadata['authorcount']
268
294
  assert_equal 'Tim E Fella', metadata['author']
295
+ assert_equal metadata['author'], metadata['authors']
269
296
  assert_equal 'Tim E', metadata['firstname']
270
297
  assert_equal 'Fella', metadata['lastname']
271
298
  assert_equal 'TF', metadata['authorinitials']
@@ -273,8 +300,10 @@ context "Lexer" do
273
300
 
274
301
  test "parse author condenses whitespace" do
275
302
  metadata, = parse_header_metadata ' Stuart Rackham <founder@asciidoc.org>'
276
- assert_equal 5, metadata.size
303
+ assert_equal 7, metadata.size
304
+ assert_equal 1, metadata['authorcount']
277
305
  assert_equal 'Stuart Rackham', metadata['author']
306
+ assert_equal metadata['author'], metadata['authors']
278
307
  assert_equal 'Stuart', metadata['firstname']
279
308
  assert_equal 'Rackham', metadata['lastname']
280
309
  assert_equal 'founder@asciidoc.org', metadata['email']
@@ -283,15 +312,26 @@ context "Lexer" do
283
312
 
284
313
  test "parse invalid author line becomes author" do
285
314
  metadata, = parse_header_metadata ' Stuart Rackham, founder of AsciiDoc <founder@asciidoc.org>'
286
- assert_equal 3, metadata.size
315
+ assert_equal 5, metadata.size
316
+ assert_equal 1, metadata['authorcount']
287
317
  assert_equal 'Stuart Rackham, founder of AsciiDoc <founder@asciidoc.org>', metadata['author']
318
+ assert_equal metadata['author'], metadata['authors']
288
319
  assert_equal 'Stuart Rackham, founder of AsciiDoc <founder@asciidoc.org>', metadata['firstname']
289
320
  assert_equal 'S', metadata['authorinitials']
290
321
  end
291
322
 
323
+ test 'parse multiple authors' do
324
+ metadata, = parse_header_metadata 'Doc Writer <doc.writer@asciidoc.org>; John Smith <john.smith@asciidoc.org>'
325
+ assert_equal 2, metadata['authorcount']
326
+ assert_equal 'Doc Writer, John Smith', metadata['authors']
327
+ assert_equal 'Doc Writer', metadata['author']
328
+ assert_equal 'Doc Writer', metadata['author_1']
329
+ assert_equal 'John Smith', metadata['author_2']
330
+ end
331
+
292
332
  test "parse rev number date remark" do
293
333
  metadata, = parse_header_metadata "Ryan Waldron\nv0.0.7, 2013-12-18: The first release you can stand on"
294
- assert_equal 7, metadata.size
334
+ assert_equal 9, metadata.size
295
335
  assert_equal '0.0.7', metadata['revnumber']
296
336
  assert_equal '2013-12-18', metadata['revdate']
297
337
  assert_equal 'The first release you can stand on', metadata['revremark']
@@ -299,20 +339,20 @@ context "Lexer" do
299
339
 
300
340
  test "parse rev date" do
301
341
  metadata, = parse_header_metadata "Ryan Waldron\n2013-12-18"
302
- assert_equal 5, metadata.size
342
+ assert_equal 7, metadata.size
303
343
  assert_equal '2013-12-18', metadata['revdate']
304
344
  end
305
345
 
306
346
  # while compliant w/ AsciiDoc, this is just sloppy parsing
307
347
  test "treats arbitrary text on rev line as revdate" do
308
348
  metadata, = parse_header_metadata "Ryan Waldron\nfoobar\n"
309
- assert_equal 5, metadata.size
349
+ assert_equal 7, metadata.size
310
350
  assert_equal 'foobar', metadata['revdate']
311
351
  end
312
352
 
313
353
  test "parse rev date remark" do
314
354
  metadata, = parse_header_metadata "Ryan Waldron\n2013-12-18: The first release you can stand on"
315
- assert_equal 6, metadata.size
355
+ assert_equal 8, metadata.size
316
356
  assert_equal '2013-12-18', metadata['revdate']
317
357
  assert_equal 'The first release you can stand on', metadata['revremark']
318
358
  end
@@ -331,7 +371,8 @@ context "Lexer" do
331
371
 
332
372
  test "skip line comments before author" do
333
373
  metadata, = parse_header_metadata "// Asciidoctor\n// release artist\nRyan Waldron"
334
- assert_equal 4, metadata.size
374
+ assert_equal 6, metadata.size
375
+ assert_equal 1, metadata['authorcount']
335
376
  assert_equal 'Ryan Waldron', metadata['author']
336
377
  assert_equal 'Ryan', metadata['firstname']
337
378
  assert_equal 'Waldron', metadata['lastname']
@@ -340,7 +381,8 @@ context "Lexer" do
340
381
 
341
382
  test "skip block comment before author" do
342
383
  metadata, = parse_header_metadata "////\nAsciidoctor\nrelease artist\n////\nRyan Waldron"
343
- assert_equal 4, metadata.size
384
+ assert_equal 6, metadata.size
385
+ assert_equal 1, metadata['authorcount']
344
386
  assert_equal 'Ryan Waldron', metadata['author']
345
387
  assert_equal 'Ryan', metadata['firstname']
346
388
  assert_equal 'Waldron', metadata['lastname']
@@ -349,7 +391,8 @@ context "Lexer" do
349
391
 
350
392
  test "skip block comment before rev" do
351
393
  metadata, = parse_header_metadata "Ryan Waldron\n////\nAsciidoctor\nrelease info\n////\nv0.0.7, 2013-12-18"
352
- assert_equal 6, metadata.size
394
+ assert_equal 8, metadata.size
395
+ assert_equal 1, metadata['authorcount']
353
396
  assert_equal 'Ryan Waldron', metadata['author']
354
397
  assert_equal '0.0.7', metadata['revnumber']
355
398
  assert_equal '2013-12-18', metadata['revdate']
@@ -30,6 +30,10 @@ context 'Links' do
30
30
  assert_xpath '//a[@href="http://asciidoc.org"][text()="http://asciidoc.org"]', render_string('(http://asciidoc.org) is the project page for AsciiDoc.'), 1
31
31
  end
32
32
 
33
+ test 'qualified url containing round brackets' do
34
+ assert_xpath '//a[@href="http://jruby.org/apidocs/org/jruby/Ruby.html#addModule(org.jruby.RubyModule)"][text()="addModule() adds a Ruby module"]', render_string('http://jruby.org/apidocs/org/jruby/Ruby.html#addModule(org.jruby.RubyModule)[addModule() adds a Ruby module]'), 1
35
+ end
36
+
33
37
  test 'qualified url adjacent to text in square brackets' do
34
38
  assert_xpath '//a[@href="http://asciidoc.org"][text()="AsciiDoc"]', render_string(']http://asciidoc.org[AsciiDoc] project page.'), 1
35
39
  end
@@ -16,6 +16,28 @@ List
16
16
  assert_xpath '//ul/li', output, 3
17
17
  end
18
18
 
19
+ test 'indented dash elements using spaces' do
20
+ input = <<-EOS
21
+ - Foo
22
+ - Boo
23
+ - Blech
24
+ EOS
25
+ output = render_string input
26
+ assert_xpath '//ul', output, 1
27
+ assert_xpath '//ul/li', output, 3
28
+ end
29
+
30
+ test 'indented dash elements using tabs' do
31
+ input = <<-EOS
32
+ \t-\tFoo
33
+ \t-\tBoo
34
+ \t-\tBlech
35
+ EOS
36
+ output = render_string input
37
+ assert_xpath '//ul', output, 1
38
+ assert_xpath '//ul/li', output, 3
39
+ end
40
+
19
41
  test "dash elements separated by blank lines should merge lists" do
20
42
  input = <<-EOS
21
43
  List
@@ -150,6 +172,40 @@ wrapped content
150
172
  assert_xpath "//ul/li[1]/p[text() = 'Foo\n:foo: bar']", output, 1
151
173
  end
152
174
 
175
+ test 'a list item with a nested marker terminates non-indented paragraph for text of list item' do
176
+ input = <<-EOS
177
+ - Foo
178
+ Bar
179
+ * Foo
180
+ EOS
181
+
182
+ output = render_embedded_string input
183
+ assert_css 'ul ul', output, 1
184
+ assert !output.include?('* Foo')
185
+ end
186
+
187
+ test 'a list item for a different list terminates non-indented paragraph for text of list item' do
188
+ input = <<-EOS
189
+ == Example 1
190
+
191
+ - Foo
192
+ Bar
193
+ . Foo
194
+
195
+ == Example 2
196
+
197
+ * Item
198
+ text
199
+ term:: def
200
+ EOS
201
+
202
+ output = render_embedded_string input
203
+ assert_css 'ul ol', output, 1
204
+ assert !output.include?('* Foo')
205
+ assert_css 'ul dl', output, 1
206
+ assert !output.include?('term:: def')
207
+ end
208
+
153
209
  test 'an indented wrapped line is unindented and folded into text of list item' do
154
210
  input = <<-EOS
155
211
  List
@@ -186,6 +242,40 @@ second wrapped line
186
242
  assert_equal 'second wrapped line', lines[2].chomp
187
243
  end
188
244
 
245
+ test 'a list item with a nested marker terminates indented paragraph for text of list item' do
246
+ input = <<-EOS
247
+ - Foo
248
+ Bar
249
+ * Foo
250
+ EOS
251
+
252
+ output = render_embedded_string input
253
+ assert_css 'ul ul', output, 1
254
+ assert !output.include?('* Foo')
255
+ end
256
+
257
+ test 'a list item for a different list terminates indented paragraph for text of list item' do
258
+ input = <<-EOS
259
+ == Example 1
260
+
261
+ - Foo
262
+ Bar
263
+ . Foo
264
+
265
+ == Example 2
266
+
267
+ * Item
268
+ text
269
+ term:: def
270
+ EOS
271
+
272
+ output = render_embedded_string input
273
+ assert_css 'ul ol', output, 1
274
+ assert !output.include?('* Foo')
275
+ assert_css 'ul dl', output, 1
276
+ assert !output.include?('term:: def')
277
+ end
278
+
189
279
  test "a literal paragraph offset by blank lines in list content is appended as a literal block" do
190
280
  input = <<-EOS
191
281
  List
@@ -331,6 +421,28 @@ List
331
421
  assert_xpath '//ul/li', output, 3
332
422
  end
333
423
 
424
+ test 'indented asterisk elements using spaces' do
425
+ input = <<-EOS
426
+ * Foo
427
+ * Boo
428
+ * Blech
429
+ EOS
430
+ output = render_string input
431
+ assert_xpath '//ul', output, 1
432
+ assert_xpath '//ul/li', output, 3
433
+ end
434
+
435
+ test 'indented asterisk elements using tabs' do
436
+ input = <<-EOS
437
+ \t*\tFoo
438
+ \t*\tBoo
439
+ \t*\tBlech
440
+ EOS
441
+ output = render_string input
442
+ assert_xpath '//ul', output, 1
443
+ assert_xpath '//ul/li', output, 3
444
+ end
445
+
334
446
  test "asterisk elements separated by blank lines should merge lists" do
335
447
  input = <<-EOS
336
448
  List
@@ -455,6 +567,21 @@ item
455
567
  assert_xpath '//ul/li', output, 2
456
568
  assert_xpath '//h2[@id = "sec"][text() = "Section"]', output, 1
457
569
  end
570
+
571
+ test 'should not find section title immediately below last list item' do
572
+ input = <<-EOS
573
+ * first
574
+ * second
575
+ == Not a section
576
+ EOS
577
+
578
+ output = render_embedded_string input
579
+ assert_css 'ul', output, 1
580
+ assert_css 'ul > li', output, 2
581
+ assert_css 'h2', output, 0
582
+ assert output.include?('== Not a section')
583
+ assert_xpath %((//li)[2]/p[text() = "second\n== Not a section"]), output, 1
584
+ end
458
585
  end
459
586
 
460
587
  context "Lists with inline markup" do
@@ -472,7 +599,7 @@ List
472
599
  assert_xpath '//ul/li', output, 3
473
600
  assert_xpath '(//ul/li)[1]//strong', output, 1
474
601
  assert_xpath '(//ul/li)[2]//em', output, 1
475
- assert_xpath '(//ul/li)[3]//tt', output, 1
602
+ assert_xpath '(//ul/li)[3]//code', output, 1
476
603
  end
477
604
 
478
605
  test "attribute substitutions" do
@@ -1287,6 +1414,28 @@ List
1287
1414
  assert_xpath '//ol/li', output, 3
1288
1415
  end
1289
1416
 
1417
+ test 'indented dot elements using spaces' do
1418
+ input = <<-EOS
1419
+ . Foo
1420
+ . Boo
1421
+ . Blech
1422
+ EOS
1423
+ output = render_string input
1424
+ assert_xpath '//ol', output, 1
1425
+ assert_xpath '//ol/li', output, 3
1426
+ end
1427
+
1428
+ test 'indented dot elements using tabs' do
1429
+ input = <<-EOS
1430
+ \t.\tFoo
1431
+ \t.\tBoo
1432
+ \t.\tBlech
1433
+ EOS
1434
+ output = render_string input
1435
+ assert_xpath '//ol', output, 1
1436
+ assert_xpath '//ol/li', output, 3
1437
+ end
1438
+
1290
1439
  test "dot elements separated by blank lines should merge lists" do
1291
1440
  input = <<-EOS
1292
1441
  List
@@ -1409,6 +1558,21 @@ term1:: def1
1409
1558
  assert_xpath '(//dl/dt)[2]/following-sibling::dd/p[text() = "def2"]', output, 1
1410
1559
  end
1411
1560
 
1561
+ test "single-line indented adjacent elements with tabs" do
1562
+ input = <<-EOS
1563
+ term1::\tdef1
1564
+ \tterm2::\tdef2
1565
+ EOS
1566
+ output = render_string input
1567
+ assert_xpath '//dl', output, 1
1568
+ assert_xpath '//dl/dt', output, 2
1569
+ assert_xpath '//dl/dt/following-sibling::dd', output, 2
1570
+ assert_xpath '(//dl/dt)[1][normalize-space(text()) = "term1"]', output, 1
1571
+ assert_xpath '(//dl/dt)[1]/following-sibling::dd/p[text() = "def1"]', output, 1
1572
+ assert_xpath '(//dl/dt)[2][normalize-space(text()) = "term2"]', output, 1
1573
+ assert_xpath '(//dl/dt)[2]/following-sibling::dd/p[text() = "def2"]', output, 1
1574
+ end
1575
+
1412
1576
  test "single-line elements separated by blank line should create a single list" do
1413
1577
  input = <<-EOS
1414
1578
  term1:: def1
@@ -2055,20 +2219,46 @@ second term:: definition
2055
2219
  assert_xpath '((//tr)[2]/td)[2]/p[normalize-space(text())="definition"]', output, 1
2056
2220
  end
2057
2221
 
2058
- test 'should render qanda list with proper semantics' do
2222
+ test 'should render qanda list in HTML with proper semantics' do
2059
2223
  input = <<-EOS
2060
2224
  [qanda]
2061
- Question one::
2062
- Answer one.
2063
- Question two::
2064
- Answer two.
2225
+ Question 1::
2226
+ Answer 1.
2227
+ Question 2::
2228
+ Answer 2.
2065
2229
  EOS
2066
2230
  output = render_embedded_string input
2067
2231
  assert_css '.qlist.qanda', output, 1
2068
- assert_css '.qlist ol', output, 1
2069
- assert_css '.qlist ol li', output, 2
2070
- assert_css '.qlist ol li:nth-child(1) p em', output, 1
2071
- assert_css '.qlist ol li:nth-child(1) p', output, 2
2232
+ assert_css '.qanda > ol', output, 1
2233
+ assert_css '.qanda > ol > li', output, 2
2234
+ (1..2).each do |idx|
2235
+ assert_css ".qanda > ol > li:nth-child(#{idx}) > p", output, 2
2236
+ assert_css ".qanda > ol > li:nth-child(#{idx}) > p:first-child > em", output, 1
2237
+ assert_xpath "/*[@class = 'qlist qanda']/ol/li[#{idx}]/p[1]/em[normalize-space(text()) = 'Question #{idx}']", output, 1
2238
+ assert_css ".qanda > ol > li:nth-child(#{idx}) > p:last-child > *", output, 0
2239
+ assert_xpath "/*[@class = 'qlist qanda']/ol/li[#{idx}]/p[2][normalize-space(text()) = 'Answer #{idx}.']", output, 1
2240
+ end
2241
+ end
2242
+
2243
+ test 'should render qanda list in DocBook with proper semantics' do
2244
+ input = <<-EOS
2245
+ [qanda]
2246
+ Question 1::
2247
+ Answer 1.
2248
+ Question 2::
2249
+ Answer 2.
2250
+ EOS
2251
+ output = render_embedded_string input, :backend => 'docbook'
2252
+ assert_css 'qandaset', output, 1
2253
+ assert_css 'qandaset > qandaentry', output, 2
2254
+ (1..2).each do |idx|
2255
+ assert_css "qandaset > qandaentry:nth-child(#{idx}) > question", output, 1
2256
+ assert_css "qandaset > qandaentry:nth-child(#{idx}) > question > simpara", output, 1
2257
+ assert_xpath "/qandaset/qandaentry[#{idx}]/question/simpara[normalize-space(text()) = 'Question #{idx}']", output, 1
2258
+ assert_css "qandaset > qandaentry:nth-child(#{idx}) > answer", output, 1
2259
+ assert_css "qandaset > qandaentry:nth-child(#{idx}) > answer > simpara", output, 1
2260
+ assert_xpath "/qandaset/qandaentry[#{idx}]/answer/simpara[normalize-space(text()) = 'Answer #{idx}.']", output, 1
2261
+ end
2072
2262
  end
2073
2263
 
2074
2264
  test 'should render bibliography list with proper semantics' do
@@ -2640,6 +2830,55 @@ para
2640
2830
  assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]', output, 1
2641
2831
  assert_xpath '//*[@class="dlist"]//dd/*[@class="paragraph"]/p[text()="para"]', output, 1
2642
2832
  end
2833
+
2834
+ test 'attached paragraph does not break on adjacent nested labeled list term' do
2835
+ input = <<-EOS
2836
+ term1:: def
2837
+ +
2838
+ more definition
2839
+ not a term::: def
2840
+ EOS
2841
+
2842
+ output = render_embedded_string input
2843
+ assert_css '.dlist > dl > dt', output, 1
2844
+ assert_css '.dlist > dl > dd', output, 1
2845
+ assert_css '.dlist > dl > dd > .paragraph', output, 1
2846
+ assert output.include?('not a term::: def')
2847
+ end
2848
+
2849
+ # FIXME pending
2850
+ =begin
2851
+ test 'attached paragraph does not break on adjacent sibling labeled list term' do
2852
+ input = <<-EOS
2853
+ term1:: def
2854
+ +
2855
+ more definition
2856
+ not a term:: def
2857
+ EOS
2858
+
2859
+ output = render_embedded_string input
2860
+ assert_css '.dlist > dl > dt', output, 1
2861
+ assert_css '.dlist > dl > dd', output, 1
2862
+ assert_css '.dlist > dl > dd > .paragraph', output, 1
2863
+ assert output.include?('not a term:: def')
2864
+ end
2865
+ =end
2866
+
2867
+ test 'attached styled paragraph does not break on adjacent nested labeled list term' do
2868
+ input = <<-EOS
2869
+ term1:: def
2870
+ +
2871
+ [quote]
2872
+ more definition
2873
+ not a term::: def
2874
+ EOS
2875
+
2876
+ output = render_embedded_string input
2877
+ assert_css '.dlist > dl > dt', output, 1
2878
+ assert_css '.dlist > dl > dd', output, 1
2879
+ assert_css '.dlist > dl > dd > .quoteblock', output, 1
2880
+ assert output.include?('not a term::: def')
2881
+ end
2643
2882
 
2644
2883
  test 'appends line as paragraph if attached by continuation following blank line and line comment when term has no inline definition' do
2645
2884
  input = <<-EOS
@@ -3292,11 +3531,11 @@ puts doc.render # <3>
3292
3531
  output = render_embedded_string input, :attributes => {'icons' => ''}
3293
3532
  assert_css '.listingblock code > img', output, 3
3294
3533
  (1..3).each do |i|
3295
- assert_xpath %((/div[@class="listingblock"]//code/img)[#{i}][@src="images/icons/callouts/#{i}.png"][@alt="#{i}"]), output, 1
3534
+ assert_xpath %((/div[@class="listingblock"]//code/img)[#{i}][@src="./images/icons/callouts/#{i}.png"][@alt="#{i}"]), output, 1
3296
3535
  end
3297
3536
  assert_css '.colist table td img', output, 3
3298
3537
  (1..3).each do |i|
3299
- assert_xpath %((/div[@class="colist arabic"]//td/img)[#{i}][@src="images/icons/callouts/#{i}.png"][@alt="#{i}"]), output, 1
3538
+ assert_xpath %((/div[@class="colist arabic"]//td/img)[#{i}][@src="./images/icons/callouts/#{i}.png"][@alt="#{i}"]), output, 1
3300
3539
  end
3301
3540
  end
3302
3541
  end