asciidoctor 1.5.7.1 → 1.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +95 -5
  3. data/Gemfile +23 -13
  4. data/README-de.adoc +482 -0
  5. data/README-fr.adoc +128 -119
  6. data/README-jp.adoc +2 -3
  7. data/README-zh_CN.adoc +2 -3
  8. data/README.adoc +131 -106
  9. data/asciidoctor.gemspec +9 -7
  10. data/data/locale/attributes-ar.adoc +1 -1
  11. data/data/locale/attributes-bg.adoc +1 -1
  12. data/data/locale/attributes-ca.adoc +1 -1
  13. data/data/locale/attributes-cs.adoc +1 -1
  14. data/data/locale/attributes-da.adoc +1 -1
  15. data/data/locale/attributes-de.adoc +1 -1
  16. data/data/locale/attributes-en.adoc +1 -1
  17. data/data/locale/attributes-es.adoc +1 -1
  18. data/data/locale/attributes-fa.adoc +1 -1
  19. data/data/locale/attributes-fi.adoc +1 -1
  20. data/data/locale/attributes-fr.adoc +1 -1
  21. data/data/locale/attributes-hu.adoc +1 -1
  22. data/data/locale/attributes-id.adoc +1 -1
  23. data/data/locale/attributes-it.adoc +1 -1
  24. data/data/locale/attributes-ja.adoc +1 -1
  25. data/data/locale/attributes-kr.adoc +1 -1
  26. data/data/locale/attributes-nb.adoc +1 -1
  27. data/data/locale/attributes-nl.adoc +1 -1
  28. data/data/locale/attributes-nn.adoc +1 -1
  29. data/data/locale/attributes-pl.adoc +1 -1
  30. data/data/locale/attributes-pt.adoc +1 -1
  31. data/data/locale/attributes-pt_BR.adoc +1 -1
  32. data/data/locale/attributes-ro.adoc +1 -1
  33. data/data/locale/attributes-ru.adoc +1 -1
  34. data/data/locale/attributes-sr.adoc +5 -4
  35. data/data/locale/attributes-sr_Latn.adoc +5 -4
  36. data/data/locale/attributes-sv.adoc +23 -0
  37. data/data/locale/attributes-tr.adoc +1 -1
  38. data/data/locale/attributes-uk.adoc +1 -1
  39. data/data/locale/attributes-zh_CN.adoc +1 -1
  40. data/data/locale/attributes-zh_TW.adoc +1 -1
  41. data/data/stylesheets/asciidoctor-default.css +23 -23
  42. data/lib/asciidoctor.rb +110 -104
  43. data/lib/asciidoctor/abstract_block.rb +55 -32
  44. data/lib/asciidoctor/abstract_node.rb +32 -17
  45. data/lib/asciidoctor/attribute_list.rb +8 -7
  46. data/lib/asciidoctor/block.rb +5 -7
  47. data/lib/asciidoctor/cli/options.rb +5 -9
  48. data/lib/asciidoctor/converter.rb +2 -2
  49. data/lib/asciidoctor/converter/docbook45.rb +7 -20
  50. data/lib/asciidoctor/converter/docbook5.rb +36 -37
  51. data/lib/asciidoctor/converter/factory.rb +10 -8
  52. data/lib/asciidoctor/converter/html5.rb +90 -65
  53. data/lib/asciidoctor/converter/manpage.rb +72 -62
  54. data/lib/asciidoctor/converter/template.rb +8 -6
  55. data/lib/asciidoctor/core_ext/1.8.7/concurrent/hash.rb +5 -0
  56. data/lib/asciidoctor/document.rb +62 -10
  57. data/lib/asciidoctor/extensions.rb +74 -16
  58. data/lib/asciidoctor/helpers.rb +11 -14
  59. data/lib/asciidoctor/list.rb +2 -2
  60. data/lib/asciidoctor/parser.rb +223 -195
  61. data/lib/asciidoctor/path_resolver.rb +15 -7
  62. data/lib/asciidoctor/reader.rb +65 -36
  63. data/lib/asciidoctor/section.rb +6 -4
  64. data/lib/asciidoctor/substitutors.rb +170 -149
  65. data/lib/asciidoctor/table.rb +16 -8
  66. data/lib/asciidoctor/version.rb +1 -1
  67. data/man/asciidoctor.1 +6 -5
  68. data/man/asciidoctor.adoc +3 -2
  69. data/test/api_test.rb +236 -0
  70. data/test/attribute_list_test.rb +242 -0
  71. data/test/attributes_test.rb +65 -52
  72. data/test/blocks_test.rb +408 -260
  73. data/test/converter_test.rb +7 -7
  74. data/test/document_test.rb +60 -54
  75. data/test/extensions_test.rb +218 -32
  76. data/test/fixtures/doctime-localtime.adoc +2 -0
  77. data/test/fixtures/section-a.adoc +4 -0
  78. data/test/fixtures/subs.adoc +0 -1
  79. data/test/invoker_test.rb +56 -18
  80. data/test/links_test.rb +105 -81
  81. data/test/lists_test.rb +636 -265
  82. data/test/logger_test.rb +1 -1
  83. data/test/manpage_test.rb +140 -3
  84. data/test/paragraphs_test.rb +42 -42
  85. data/test/parser_test.rb +63 -183
  86. data/test/paths_test.rb +21 -4
  87. data/test/preamble_test.rb +9 -9
  88. data/test/reader_test.rb +78 -28
  89. data/test/sections_test.rb +273 -151
  90. data/test/substitutions_test.rb +53 -19
  91. data/test/tables_test.rb +286 -163
  92. data/test/test_helper.rb +4 -3
  93. data/test/text_test.rb +65 -65
  94. metadata +16 -21
@@ -568,6 +568,12 @@ context 'Substitutions' do
568
568
  assert_equal '<span class="red">alert</span>', para.sub_quotes(para.source)
569
569
  end
570
570
 
571
+ test 'inline passthrough with id and role set using shorthand' do
572
+ para = block_from_string '[#id.role]+pass+'
573
+ # FIXME id should be propogated
574
+ assert_equal '<span class="role">pass</span>', para.content
575
+ end
576
+
571
577
  test 'should assign role attribute when shorthand style contains a role' do
572
578
  para = block_from_string 'blah'
573
579
  result = para.parse_quoted_text_attributes '.red#idref'
@@ -690,7 +696,7 @@ context 'Substitutions' do
690
696
  test 'should encode special characters in alt text of inline image' do
691
697
  input = 'A tiger\'s "roar" is < a bear\'s "growl"'
692
698
  expected = 'A tiger&#8217;s &quot;roar&quot; is &lt; a bear&#8217;s &quot;growl&quot;'
693
- output = (render_embedded_string %(image:tiger-roar.png[#{input}]), :doctype => :inline).gsub(/>\s+</, '><')
699
+ output = (convert_inline_string %(image:tiger-roar.png[#{input}])).gsub(/>\s+</, '><')
694
700
  assert_equal %(<span class="image"><img src="tiger-roar.png" alt="#{expected}"></span>), output
695
701
  end
696
702
 
@@ -783,7 +789,7 @@ context 'Substitutions' do
783
789
 
784
790
  test 'an inline image macro with a float attribute should be interpreted as a floating image' do
785
791
  para = block_from_string %(image:http://example.com/images/tiger.png[tiger, float="right"] Beware of the tigers!)
786
- assert_equal %{<span class="image" style="float: right"><img src="http://example.com/images/tiger.png" alt="tiger"></span> Beware of the tigers!},
792
+ assert_equal %{<span class="image right"><img src="http://example.com/images/tiger.png" alt="tiger"></span> Beware of the tigers!},
787
793
  para.sub_macros(para.source).gsub(/>\s+</, '><')
788
794
  end
789
795
 
@@ -842,7 +848,9 @@ context 'Substitutions' do
842
848
 
843
849
  using_memory_logger do |logger|
844
850
  sect = block_from_string input, :attributes => { 'data-uri' => '', 'iconsdir' => 'fixtures', 'docdir' => testdir }, :safe => :server, :catalog_assets => true
845
- assert_includes sect.document.catalog[:images], 'fixtures/dot.gif'
851
+ assert 1, sect.document.catalog[:images].size
852
+ assert_equal 'fixtures/dot.gif', sect.document.catalog[:images][0].to_s
853
+ assert_nil sect.document.catalog[:images][0].imagesdir
846
854
  assert logger.empty?
847
855
  end
848
856
  end
@@ -857,7 +865,7 @@ context 'Substitutions' do
857
865
  assert_equal %{<span class="icon">[github]</span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
858
866
  end
859
867
 
860
- test 'an icon macro should render alt text if icons are disabled and alt is given' do
868
+ test 'an icon macro should output alt text if icons are disabled and alt is given' do
861
869
  para = block_from_string 'icon:github[alt="GitHub"]'
862
870
  assert_equal %{<span class="icon">[GitHub]</span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
863
871
  end
@@ -877,7 +885,7 @@ context 'Substitutions' do
877
885
  assert_equal %{<span class="icon red"><i class="fa fa-heart" title="Heart me"></i></span>}, para.sub_macros(para.source).gsub(/>\s+</, '><')
878
886
  end
879
887
 
880
- test 'a single-line footnote macro should be registered and rendered as a footnote' do
888
+ test 'a single-line footnote macro should be registered and output as a footnote' do
881
889
  para = block_from_string('Sentence text footnote:[An example footnote.].')
882
890
  assert_equal %(Sentence text <sup class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnotedef_1" title="View footnote.">1</a>]</sup>.), para.sub_macros(para.source)
883
891
  assert_equal 1, para.document.catalog[:footnotes].size
@@ -887,7 +895,7 @@ context 'Substitutions' do
887
895
  assert_equal 'An example footnote.', footnote.text
888
896
  end
889
897
 
890
- test 'a multi-line footnote macro should be registered and rendered as a footnote without endline' do
898
+ test 'a multi-line footnote macro should be registered and output as a footnote without endline' do
891
899
  para = block_from_string("Sentence text footnote:[An example footnote\nwith wrapped text.].")
892
900
  assert_equal %(Sentence text <sup class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnotedef_1" title="View footnote.">1</a>]</sup>.), para.sub_macros(para.source)
893
901
  assert_equal 1, para.document.catalog[:footnotes].size
@@ -897,7 +905,7 @@ context 'Substitutions' do
897
905
  assert_equal "An example footnote with wrapped text.", footnote.text
898
906
  end
899
907
 
900
- test 'an escaped closing square bracket in a footnote should be unescaped when rendered' do
908
+ test 'an escaped closing square bracket in a footnote should be unescaped when converted' do
901
909
  para = block_from_string(%(footnote:[a #{BACKSLASH}] b].))
902
910
  assert_equal %(<sup class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnotedef_1" title="View footnote.">1</a>]</sup>.), para.sub_macros(para.source)
903
911
  assert_equal 1, para.document.catalog[:footnotes].size
@@ -973,7 +981,7 @@ context 'Substitutions' do
973
981
  foofootnote:[+http://example.com+]barfootnote:[+http://acme.com+]baz
974
982
  EOS
975
983
 
976
- result = render_embedded_string input, :doctype => 'inline', :backend => 'docbook'
984
+ result = convert_string_to_embedded input, :doctype => 'inline', :backend => 'docbook'
977
985
  assert_equal 'foo<footnote><simpara>http://example.com</simpara></footnote>bar<footnote><simpara>http://acme.com</simpara></footnote>baz', result
978
986
  end
979
987
 
@@ -991,7 +999,7 @@ foofootnote:[+http://example.com+]barfootnote:[+http://acme.com+]baz
991
999
  assert_equal "Another footnote.", footnote2.text
992
1000
  end
993
1001
 
994
- test 'a footnoteref macro with id and single-line text should be registered and rendered as a footnote' do
1002
+ test 'a footnoteref macro with id and single-line text should be registered and output as a footnote' do
995
1003
  para = block_from_string('Sentence text footnoteref:[ex1, An example footnote.].')
996
1004
  assert_equal %(Sentence text <sup class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" class="footnote" href="#_footnotedef_1" title="View footnote.">1</a>]</sup>.), para.sub_macros(para.source)
997
1005
  assert_equal 1, para.document.catalog[:footnotes].size
@@ -1001,7 +1009,7 @@ foofootnote:[+http://example.com+]barfootnote:[+http://acme.com+]baz
1001
1009
  assert_equal 'An example footnote.', footnote.text
1002
1010
  end
1003
1011
 
1004
- test 'a footnoteref macro with id and multi-line text should be registered and rendered as a footnote without endlines' do
1012
+ test 'a footnoteref macro with id and multi-line text should be registered and output as a footnote without endlines' do
1005
1013
  para = block_from_string("Sentence text footnoteref:[ex1, An example footnote\nwith wrapped text.].")
1006
1014
  assert_equal %(Sentence text <sup class="footnote" id="_footnote_ex1">[<a id="_footnoteref_1" class="footnote" href="#_footnotedef_1" title="View footnote.">1</a>]</sup>.), para.sub_macros(para.source)
1007
1015
  assert_equal 1, para.document.catalog[:footnotes].size
@@ -1039,7 +1047,7 @@ You can also file a support request.footnote:sub[]
1039
1047
  If all else fails, you can give us a call.footnoteref:[sub]
1040
1048
  EOS
1041
1049
 
1042
- output = render_embedded_string input
1050
+ output = convert_string_to_embedded input
1043
1051
  assert_css '#_footnotedef_1', output, 1
1044
1052
  assert_css 'p a[href="#_footnotedef_1"]', output, 3
1045
1053
  assert_css '#footnotes .footnote', output, 1
@@ -1050,7 +1058,7 @@ If all else fails, you can give us a call.footnoteref:[sub]
1050
1058
  notable text.footnote:id[about this [text\]], footnote:id[], footnote:id[]
1051
1059
  EOS
1052
1060
 
1053
- output = render_embedded_string input
1061
+ output = convert_string_to_embedded input
1054
1062
  assert_xpath '(//p)[1]/sup[starts-with(@class,"footnote")]', output, 3
1055
1063
  assert_xpath '(//p)[1]/sup[@class="footnote"]', output, 1
1056
1064
  assert_xpath '(//p)[1]/sup[@class="footnoteref"]', output, 2
@@ -1065,7 +1073,7 @@ The footnote:[] macro can be used for defining and referencing footnotes.
1065
1073
  The footnoteref:[] macro is now deprecated.
1066
1074
  EOS
1067
1075
 
1068
- output = render_embedded_string input
1076
+ output = convert_string_to_embedded input
1069
1077
  assert_includes output, 'The footnote:[] macro'
1070
1078
  assert_includes output, 'The footnoteref:[] macro'
1071
1079
  end
@@ -1075,7 +1083,7 @@ The footnoteref:[] macro is now deprecated.
1075
1083
  You can download the software from the product page.footnote:1[Option only available if you have an active subscription.]
1076
1084
  EOS
1077
1085
 
1078
- output = render_embedded_string input
1086
+ output = convert_string_to_embedded input
1079
1087
  assert_css '#_footnote_1', output, 1
1080
1088
  assert_css 'p sup#_footnote_1', output, 1
1081
1089
  assert_css 'p a#_footnoteref_1', output, 1
@@ -1131,6 +1139,14 @@ You can download the software from the product page.footnote:1[Option only avail
1131
1139
  end
1132
1140
  end
1133
1141
 
1142
+ test 'should escape concealed index term if second bracket is preceded by a backslash' do
1143
+ input = %[National Institute of Science and Technology (#{BACKSLASH}((NIST)))]
1144
+ doc = document_from_string input, :header_footer => false
1145
+ output = doc.convert
1146
+ assert_xpath '//p[text()="National Institute of Science and Technology (((NIST)))"]', output, 1
1147
+ assert doc.catalog[:indexterms].empty?
1148
+ end
1149
+
1134
1150
  test 'should only escape enclosing brackets if concealed index term is preceded by a backslash' do
1135
1151
  input = %[National Institute of Science and Technology #{BACKSLASH}(((NIST)))]
1136
1152
  doc = document_from_string input, :header_footer => false
@@ -1267,6 +1283,14 @@ EOS
1267
1283
  assert_equal ['cat'], para.document.catalog[:indexterms][1]
1268
1284
  end
1269
1285
 
1286
+ test 'should escape visible index term if preceded by a backslash' do
1287
+ sentence = "The #{BACKSLASH}((tiger)) (Panthera tigris) is the largest #{BACKSLASH}((cat)) species."
1288
+ para = block_from_string(sentence)
1289
+ output = para.sub_macros(para.source)
1290
+ assert_equal 'The ((tiger)) (Panthera tigris) is the largest ((cat)) species.', output
1291
+ assert para.document.catalog[:indexterms].empty?
1292
+ end
1293
+
1270
1294
  test 'normal substitutions are performed on an index term 2 macro' do
1271
1295
  sentence = 'The ((*tiger*)) (Panthera tigris) is the largest cat species.'
1272
1296
  para = block_from_string sentence
@@ -1526,6 +1550,16 @@ EOS
1526
1550
  assert_equal [:specialcharacters], para.passthroughs[0][:subs]
1527
1551
  end
1528
1552
 
1553
+ test 'should not crash if role on passthrough is enclosed in quotes' do
1554
+ %W(
1555
+ ['role']#{BACKSLASH}++This++++++++++++
1556
+ ['role']#{BACKSLASH}+++++++++This++++++++++++
1557
+ ).each do |input|
1558
+ para = block_from_string input
1559
+ assert_includes para.content, %(<span class="'role'">)
1560
+ end
1561
+ end
1562
+
1529
1563
  test 'should allow inline double plus passthrough to be escaped using backslash' do
1530
1564
  para = block_from_string("you need to replace `int a = n#{BACKSLASH}++;` with `int a = ++n;`!")
1531
1565
  result = para.apply_subs para.source
@@ -1576,7 +1610,7 @@ EOS
1576
1610
 
1577
1611
  test 'should find and replace placeholder duplicated by substitution' do
1578
1612
  input = %q(+first passthrough+ followed by link:$$http://example.com/__u_no_format_me__$$[] with passthrough)
1579
- result = render_embedded_string input, :doctype => :inline
1613
+ result = convert_inline_string input
1580
1614
  assert_equal 'first passthrough followed by <a href="http://example.com/__u_no_format_me__" class="bare">http://example.com/__u_no_format_me__</a> with passthrough', result
1581
1615
  end
1582
1616
 
@@ -1622,12 +1656,12 @@ EOS
1622
1656
  end
1623
1657
 
1624
1658
  test 'should restore nested passthroughs' do
1625
- result = render_embedded_string %q(+Sometimes you feel pass:q[`mono`].+ Sometimes you +$$don't$$+.), :doctype => :inline
1659
+ result = convert_inline_string %q(+Sometimes you feel pass:q[`mono`].+ Sometimes you +$$don't$$+.)
1626
1660
  assert_equal %q(Sometimes you feel <code>mono</code>. Sometimes you don't.), result
1627
1661
  end
1628
1662
 
1629
1663
  test 'should honor role on double plus passthrough' do
1630
- result = render_embedded_string 'Print the version using [var]++{asciidoctor-version}++.', :doctype => :inline
1664
+ result = convert_inline_string 'Print the version using [var]++{asciidoctor-version}++.'
1631
1665
  assert_equal 'Print the version using <span class="var">{asciidoctor-version}</span>.', result
1632
1666
  end
1633
1667
 
@@ -1854,13 +1888,13 @@ foo&#8201;&#8212;&#8201;'
1854
1888
 
1855
1889
  test 'preserves entity references' do
1856
1890
  input = '&amp; &#169; &#10004; &#128512; &#x2022; &#x1f600;'
1857
- result = render_embedded_string input, :doctype => :inline
1891
+ result = convert_inline_string input
1858
1892
  assert_equal input, result
1859
1893
  end
1860
1894
 
1861
1895
  test 'only preserves named entities with two or more letters' do
1862
1896
  input = '&amp; &a; &gt;'
1863
- result = render_embedded_string input, :doctype => :inline
1897
+ result = convert_inline_string input
1864
1898
  assert_equal '&amp; &amp;a; &gt;', result
1865
1899
  end
1866
1900
 
@@ -7,7 +7,7 @@ end
7
7
  context 'Tables' do
8
8
 
9
9
  context 'PSV' do
10
- test 'renders simple psv table' do
10
+ test 'converts simple psv table' do
11
11
  input = <<-EOS
12
12
  |=======
13
13
  |A |B |C
@@ -37,6 +37,20 @@ context 'Tables' do
37
37
  }
38
38
  end
39
39
 
40
+ test 'should add direction CSS class if float attribute is set on table' do
41
+ input = <<-EOS
42
+ [float=left]
43
+ |=======
44
+ |A |B |C
45
+ |a |b |c
46
+ |1 |2 |3
47
+ |=======
48
+ EOS
49
+
50
+ output = convert_string_to_embedded input
51
+ assert_css 'table.left', output, 1
52
+ end
53
+
40
54
  test 'should set stripes class if stripes option is set' do
41
55
  input = <<-EOS
42
56
  [stripes=odd]
@@ -47,11 +61,11 @@ context 'Tables' do
47
61
  |=======
48
62
  EOS
49
63
 
50
- output = render_embedded_string input
64
+ output = convert_string_to_embedded input
51
65
  assert_css 'table.stripes-odd', output, 1
52
66
  end
53
67
 
54
- test 'renders caption on simple psv table' do
68
+ test 'outputs a caption on simple psv table' do
55
69
  input = <<-EOS
56
70
  .Simple psv table
57
71
  |=======
@@ -60,7 +74,7 @@ context 'Tables' do
60
74
  |1 |2 |3
61
75
  |=======
62
76
  EOS
63
- output = render_embedded_string input
77
+ output = convert_string_to_embedded input
64
78
  assert_xpath '/table/caption[@class="title"][text()="Table 1. Simple psv table"]', output, 1
65
79
  assert_xpath '/table/caption/following-sibling::colgroup', output, 1
66
80
  end
@@ -81,7 +95,7 @@ context 'Tables' do
81
95
  |7 |8 |9
82
96
  |=======
83
97
  EOS
84
- output = render_embedded_string input
98
+ output = convert_string_to_embedded input
85
99
  assert_css 'table:root', output, 3
86
100
  assert_xpath '(/table)[1]/caption', output, 1
87
101
  assert_xpath '(/table)[1]/caption[text()="Table 1. First numbered table"]', output, 1
@@ -90,7 +104,7 @@ context 'Tables' do
90
104
  assert_xpath '(/table)[3]/caption[text()="Table 2. Second numbered table"]', output, 1
91
105
  end
92
106
 
93
- test 'renders explicit caption on simple psv table' do
107
+ test 'uses explicit caption in front of title in place of default caption and number' do
94
108
  input = <<-EOS
95
109
  [caption="All the Data. "]
96
110
  .Simple psv table
@@ -100,18 +114,64 @@ context 'Tables' do
100
114
  |1 |2 |3
101
115
  |=======
102
116
  EOS
103
- output = render_embedded_string input
117
+ output = convert_string_to_embedded input
104
118
  assert_xpath '/table/caption[@class="title"][text()="All the Data. Simple psv table"]', output, 1
105
119
  assert_xpath '/table/caption/following-sibling::colgroup', output, 1
106
120
  end
107
121
 
122
+ test 'disables caption when caption attribute on table is empty' do
123
+ input = <<-EOS
124
+ [caption=]
125
+ .Simple psv table
126
+ |=======
127
+ |A |B |C
128
+ |a |b |c
129
+ |1 |2 |3
130
+ |=======
131
+ EOS
132
+ output = convert_string_to_embedded input
133
+ assert_xpath '/table/caption[@class="title"][text()="Simple psv table"]', output, 1
134
+ assert_xpath '/table/caption/following-sibling::colgroup', output, 1
135
+ end
136
+
137
+ test 'disables caption when caption attribute on table is empty string' do
138
+ input = <<-EOS
139
+ [caption=""]
140
+ .Simple psv table
141
+ |=======
142
+ |A |B |C
143
+ |a |b |c
144
+ |1 |2 |3
145
+ |=======
146
+ EOS
147
+ output = convert_string_to_embedded input
148
+ assert_xpath '/table/caption[@class="title"][text()="Simple psv table"]', output, 1
149
+ assert_xpath '/table/caption/following-sibling::colgroup', output, 1
150
+ end
151
+
152
+ test 'disables caption on table when table-caption document attribute is unset' do
153
+ input = <<-EOS
154
+ :!table-caption:
155
+
156
+ .Simple psv table
157
+ |=======
158
+ |A |B |C
159
+ |a |b |c
160
+ |1 |2 |3
161
+ |=======
162
+ EOS
163
+ output = convert_string_to_embedded input
164
+ assert_xpath '/table/caption[@class="title"][text()="Simple psv table"]', output, 1
165
+ assert_xpath '/table/caption/following-sibling::colgroup', output, 1
166
+ end
167
+
108
168
  test 'ignores escaped separators' do
109
169
  input = <<-EOS
110
170
  |===
111
171
  |A \\| here| a \\| there
112
172
  |===
113
173
  EOS
114
- output = render_embedded_string input
174
+ output = convert_string_to_embedded input
115
175
  assert_css 'table', output, 1
116
176
  assert_css 'table > colgroup > col', output, 2
117
177
  assert_css 'table > tbody > tr', output, 1
@@ -129,7 +189,7 @@ context 'Tables' do
129
189
  |A2 |B2\\|
130
190
  |===
131
191
  EOS
132
- output = render_embedded_string input
192
+ output = convert_string_to_embedded input
133
193
  assert_css 'table', output, 1
134
194
  assert_css 'table > colgroup > col', output, 2
135
195
  assert_css 'table > thead > tr', output, 1
@@ -150,7 +210,7 @@ context 'Tables' do
150
210
  |C1 |C2
151
211
  |===
152
212
  EOS
153
- output = render_embedded_string input
213
+ output = convert_string_to_embedded input
154
214
  assert_css 'table', output, 1
155
215
  assert_css 'table > colgroup > col', output, 2
156
216
  assert_css 'table > tbody > tr', output, 3
@@ -171,7 +231,7 @@ A | here| a | there
171
231
  |===
172
232
  EOS
173
233
  using_memory_logger do |logger|
174
- output = render_embedded_string input
234
+ output = convert_string_to_embedded input
175
235
  assert_css 'table', output, 1
176
236
  assert_css 'table > tbody > tr', output, 2
177
237
  assert_css 'table > tbody > tr > td', output, 8
@@ -190,7 +250,7 @@ A | here| a | there
190
250
  |{show_title} |Coming soon...
191
251
  |===
192
252
  EOS
193
- output = render_embedded_string input
253
+ output = convert_string_to_embedded input
194
254
  assert_xpath '//tbody/tr/td[1]/p[text()="Cool new show"]', output, 1
195
255
  assert_xpath %(//tbody/tr/td[2]/p[text()='Coming soon#{decode_char 8230}#{decode_char 8203}']), output, 1
196
256
  end
@@ -204,7 +264,7 @@ three
204
264
  <four>
205
265
  |===
206
266
  EOS
207
- output = render_embedded_string input
267
+ output = convert_string_to_embedded input
208
268
  result = xmlnodes_at_xpath('/table//pre', output, 1)
209
269
  assert_equal %(<pre>one\n*two*\nthree\n&lt;four&gt;</pre>), result.to_s
210
270
  end
@@ -221,7 +281,7 @@ three
221
281
  | normal
222
282
  |===
223
283
  EOS
224
- output = render_embedded_string input
284
+ output = convert_string_to_embedded input
225
285
  result = xmlnodes_at_xpath('/table//pre', output, 1)
226
286
  assert_equal %(<pre> one\n two\nthree</pre>), result.to_s
227
287
  end
@@ -238,7 +298,7 @@ three
238
298
  | normal
239
299
  |===
240
300
  EOS
241
- output = render_embedded_string input
301
+ output = convert_string_to_embedded input
242
302
  result = xmlnodes_at_xpath('/table//div[@class="verse"]', output, 1)
243
303
  assert_equal %(<div class="verse"> one\n two\nthree</div>), result.to_s
244
304
  end
@@ -252,7 +312,7 @@ three
252
312
  |1 |2 |3
253
313
  |=======
254
314
  EOS
255
- output = render_embedded_string input
315
+ output = convert_string_to_embedded input
256
316
  assert_css 'table', output, 1
257
317
  assert_css 'table.fit-content', output, 1
258
318
  assert_css 'table[style*="width"]', output, 0
@@ -319,7 +379,7 @@ three
319
379
  |1 |2 |3 |4
320
380
  |=======
321
381
  EOS
322
- output = render_embedded_string input, :backend => 'docbook5'
382
+ output = convert_string_to_embedded input, :backend => 'docbook5'
323
383
  assert_css 'tgroup[cols="4"]', output, 1
324
384
  assert_css 'tgroup colspec', output, 4
325
385
  assert_css 'tgroup colspec[colwidth]', output, 4
@@ -337,7 +397,7 @@ three
337
397
  |1 |2 |3
338
398
  |=======
339
399
  EOS
340
- output = render_embedded_string input
400
+ output = convert_string_to_embedded input
341
401
  assert_css 'table', output, 1
342
402
  assert_css 'table[style*="width"]', output, 1
343
403
  assert_css 'table colgroup col', output, 3
@@ -352,7 +412,7 @@ three
352
412
  |4
353
413
  |===
354
414
  EOS
355
- output = render_embedded_string input
415
+ output = convert_string_to_embedded input
356
416
  assert_css 'table', output, 1
357
417
  assert_css 'table > colgroup > col', output, 4
358
418
  assert_css 'table > tbody > tr', output, 2
@@ -367,7 +427,7 @@ three
367
427
  |A |B |C |a |b |c |1 |2 |3
368
428
  |===
369
429
  EOS
370
- output = render_embedded_string input
430
+ output = convert_string_to_embedded input
371
431
  assert_css 'table', output, 1
372
432
  assert_css 'table > tbody > tr', output, 3
373
433
  end
@@ -380,7 +440,7 @@ three
380
440
  |1 |2 |a |b
381
441
  |===
382
442
  EOS
383
- output = render_embedded_string input
443
+ output = convert_string_to_embedded input
384
444
  assert_css 'table', output, 1
385
445
  assert_css 'table > colgroup > col', output, 3
386
446
  assert_css 'table > tbody > tr', output, 2
@@ -394,7 +454,7 @@ three
394
454
  |1 |2 |a |b
395
455
  |===
396
456
  EOS
397
- output = render_embedded_string input
457
+ output = convert_string_to_embedded input
398
458
  assert_css 'table', output, 1
399
459
  assert_css 'table > colgroup > col', output, 3
400
460
  assert_css 'table > tbody > tr', output, 2
@@ -408,12 +468,29 @@ three
408
468
  |1 |2 |a |b
409
469
  |===
410
470
  EOS
411
- output = render_embedded_string input
471
+ output = convert_string_to_embedded input
412
472
  assert_css 'table', output, 1
413
473
  assert_css 'table > colgroup > col', output, 2
414
474
  assert_css 'table > tbody > tr', output, 3
415
475
  end
416
476
 
477
+ test 'cols may be separated by semi-colon instead of comma' do
478
+ input = <<-EOS
479
+ [cols="1s;3m"]
480
+ |===
481
+ | strong
482
+ | mono
483
+ |===
484
+ EOS
485
+ output = convert_string_to_embedded input
486
+ assert_css 'table', output, 1
487
+ assert_css 'table > colgroup > col', output, 2
488
+ assert_css 'col[style="width: 25%;"]', output, 1
489
+ assert_css 'col[style="width: 75%;"]', output, 1
490
+ assert_xpath '(//td)[1]//strong', output, 1
491
+ assert_xpath '(//td)[2]//code', output, 1
492
+ end
493
+
417
494
  test 'cols attribute may include spaces' do
418
495
  input = <<-EOS
419
496
  [cols=" 1, 1 "]
@@ -421,7 +498,7 @@ three
421
498
  |one |two |1 |2 |a |b
422
499
  |===
423
500
  EOS
424
- output = render_embedded_string input
501
+ output = convert_string_to_embedded input
425
502
  assert_css 'table', output, 1
426
503
  assert_css 'table > colgroup > col', output, 2
427
504
  assert_css 'col[style="width: 50%;"]', output, 2
@@ -436,7 +513,7 @@ three
436
513
  |1 |2 |a |b
437
514
  |===
438
515
  EOS
439
- output = render_embedded_string input
516
+ output = convert_string_to_embedded input
440
517
  assert_css 'table', output, 1
441
518
  assert_css 'table > colgroup > col', output, 2
442
519
  assert_css 'col[style="width: 50%;"]', output, 2
@@ -451,7 +528,7 @@ three
451
528
  |1 |2 |a |b
452
529
  |===
453
530
  EOS
454
- output = render_embedded_string input
531
+ output = convert_string_to_embedded input
455
532
  assert_css 'table', output, 1
456
533
  assert_css 'table > colgroup > col', output, 2
457
534
  assert_css 'col[style="width: 50%;"]', output, 2
@@ -469,7 +546,7 @@ three
469
546
  |Total |6
470
547
  |===
471
548
  EOS
472
- output = render_embedded_string input
549
+ output = convert_string_to_embedded input
473
550
  assert_css 'table', output, 1
474
551
  assert_css 'table > colgroup > col', output, 2
475
552
  assert_css 'table > thead', output, 1
@@ -496,7 +573,7 @@ three
496
573
  |Total |6
497
574
  |===
498
575
  EOS
499
- output = render_embedded_string input, :backend => 'docbook'
576
+ output = convert_string_to_embedded input, :backend => 'docbook'
500
577
  assert_css 'table', output, 1
501
578
  assert_css 'table[frame="topbot"]', output, 1
502
579
  assert_css 'table > title', output, 1
@@ -526,7 +603,7 @@ three
526
603
  |A |B |C
527
604
  |===
528
605
  EOS
529
- output = render_embedded_string input, :backend => 'docbook'
606
+ output = convert_string_to_embedded input, :backend => 'docbook'
530
607
  assert_css 'informaltable[frame="topbot"]', output, 1
531
608
  end
532
609
 
@@ -539,7 +616,7 @@ three
539
616
  |===
540
617
  EOS
541
618
 
542
- output = render_embedded_string input, :backend => 'docbook'
619
+ output = convert_string_to_embedded input, :backend => 'docbook'
543
620
  assert_css 'informaltable', output, 1
544
621
  assert_css 'informaltable[orient="land"]', output, 1
545
622
  end
@@ -557,7 +634,7 @@ three
557
634
  |Data B2
558
635
  |===
559
636
  EOS
560
- output = render_embedded_string input
637
+ output = convert_string_to_embedded input
561
638
  assert_css 'table', output, 1
562
639
  assert_css 'table > colgroup > col', output, 2
563
640
  assert_css 'table > thead', output, 1
@@ -574,7 +651,7 @@ three
574
651
 
575
652
  |===
576
653
  EOS
577
- output = render_embedded_string input
654
+ output = convert_string_to_embedded input
578
655
  assert_css 'table', output, 1
579
656
  assert_css 'table > colgroup > col', output, 2
580
657
  assert_css 'table > thead', output, 1
@@ -593,7 +670,7 @@ three
593
670
  |Data B1
594
671
  |===
595
672
  EOS
596
- output = render_embedded_string input
673
+ output = convert_string_to_embedded input
597
674
  assert_css 'table', output, 1
598
675
  assert_css 'table[style*="width"]', output, 0
599
676
  assert_css 'table > colgroup > col', output, 2
@@ -615,7 +692,7 @@ three
615
692
  |Data B2
616
693
  |===
617
694
  EOS
618
- output = render_embedded_string input
695
+ output = convert_string_to_embedded input
619
696
  assert_css 'table', output, 1
620
697
  assert_css 'table > colgroup > col', output, 2
621
698
  assert_css 'table > thead', output, 0
@@ -636,7 +713,7 @@ A1 continued|B1
636
713
  |B2
637
714
  |===
638
715
  EOS
639
- output = render_embedded_string input
716
+ output = convert_string_to_embedded input
640
717
  assert_css 'table', output, 1
641
718
  assert_css 'table > colgroup > col', output, 2
642
719
  assert_css 'table > thead', output, 0
@@ -661,7 +738,7 @@ just text
661
738
  |B2
662
739
  |===
663
740
  EOS
664
- output = render_embedded_string input
741
+ output = convert_string_to_embedded input
665
742
  assert_css 'table', output, 1
666
743
  assert_css 'table > colgroup > col', output, 2
667
744
  assert_css 'table > thead', output, 0
@@ -684,7 +761,7 @@ just text
684
761
 
685
762
  |===
686
763
  EOS
687
- output = render_embedded_string input
764
+ output = convert_string_to_embedded input
688
765
  assert_css 'table', output, 1
689
766
  assert_css 'table > colgroup > col', output, 2
690
767
  assert_css 'table > thead', output, 0
@@ -705,7 +782,7 @@ just text
705
782
  |Data B2
706
783
  |===
707
784
  EOS
708
- output = render_embedded_string input
785
+ output = convert_string_to_embedded input
709
786
  assert_css 'table', output, 1
710
787
  assert_css 'table > colgroup > col', output, 2
711
788
  assert_css 'table > thead', output, 0
@@ -722,7 +799,7 @@ just text
722
799
  |Name |Occupation| Website
723
800
  |===
724
801
  EOS
725
- output = render_embedded_string input
802
+ output = convert_string_to_embedded input
726
803
  assert_css 'table', output, 1
727
804
  assert_css 'table > thead > tr > th', output, 3
728
805
  assert_css 'table > thead > tr > th > *', output, 0
@@ -752,7 +829,7 @@ just text
752
829
 
753
830
  |===
754
831
  EOS
755
- output = render_embedded_string input
832
+ output = convert_string_to_embedded input
756
833
  assert_css 'table', output, 1
757
834
  assert_css 'table > tbody > tr > th', output, 3
758
835
  assert_css 'table > tbody > tr > td', output, 6
@@ -784,7 +861,7 @@ I am getting in shape!
784
861
 
785
862
  |===
786
863
  EOS
787
- output = render_embedded_string input
864
+ output = convert_string_to_embedded input
788
865
  assert_css 'table', output, 1
789
866
  assert_css 'table[style*="width: 80%"]', output, 1
790
867
  assert_xpath '/table/caption[@class="title"][text()="Table 1. Horizontal and vertical source data"]', output, 1
@@ -813,7 +890,7 @@ I am getting in shape!
813
890
  |===
814
891
  EOS
815
892
 
816
- output = render_embedded_string input
893
+ output = convert_string_to_embedded input
817
894
  assert_xpath '/table/colgroup/col', output, 2
818
895
  assert_xpath '(/table/colgroup/col)[1][@style="width: 10%;"]', output, 1
819
896
  assert_xpath '(/table/colgroup/col)[2][@style="width: 90%;"]', output, 1
@@ -829,7 +906,7 @@ I am getting in shape!
829
906
  d|9 2+>|10
830
907
  |===
831
908
  EOS
832
- output = render_embedded_string input
909
+ output = convert_string_to_embedded input
833
910
  assert_css 'table', output, 1
834
911
  assert_css 'table > colgroup > col[style*="width: 25%"]', output, 4
835
912
  assert_css 'table > tbody > tr', output, 4
@@ -864,7 +941,7 @@ d|9 2+>|10
864
941
  |AAA |BBB |CCC
865
942
  |===
866
943
  EOS
867
- output = render_embedded_string input
944
+ output = convert_string_to_embedded input
868
945
  assert_css 'table > tbody > tr:nth-child(1) > td', output, 2
869
946
  assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(1)[colspan="2"]', output, 1
870
947
  assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(2):not([colspan])', output, 1
@@ -880,7 +957,7 @@ d|9 2+>|10
880
957
  |b |c
881
958
  |===
882
959
  EOS
883
- output = render_embedded_string input
960
+ output = convert_string_to_embedded input
884
961
  assert_css 'table', output, 1
885
962
  assert_css 'table > colgroup > col', output, 3
886
963
  assert_css 'table > tbody > tr', output, 3
@@ -909,7 +986,7 @@ d|9 2+>|10
909
986
  |===
910
987
  EOS
911
988
 
912
- output = render_embedded_string input, :backend => 'docbook'
989
+ output = convert_string_to_embedded input, :backend => 'docbook'
913
990
  assert_xpath '//colspec', output, 2
914
991
  assert_xpath '(//colspec)[1][@colname="col_1"]', output, 1
915
992
  assert_xpath '(//colspec)[2][@colname="col_2"]', output, 1
@@ -926,7 +1003,7 @@ d|9 2+>|10
926
1003
  |===
927
1004
  EOS
928
1005
 
929
- output = render_embedded_string input, :backend => 'docbook'
1006
+ output = convert_string_to_embedded input, :backend => 'docbook'
930
1007
  assert_xpath '//colspec', output, 3
931
1008
  assert_xpath '(//colspec)[1][@colname="col_1"]', output, 1
932
1009
  assert_xpath '(//colspec)[2][@colname="col_2"]', output, 1
@@ -948,7 +1025,7 @@ d|9 2+>|10
948
1025
  |===
949
1026
  EOS
950
1027
 
951
- output = render_embedded_string input, :backend => 'docbook'
1028
+ output = convert_string_to_embedded input, :backend => 'docbook'
952
1029
  assert_xpath '//colspec', output, 5
953
1030
  (1..5).each do |n|
954
1031
  assert_xpath %((//colspec)[#{n}][@colname="col_#{n}"]), output, 1
@@ -972,7 +1049,7 @@ more C
972
1049
  |===
973
1050
  EOS
974
1051
  using_memory_logger do |logger|
975
- output = render_embedded_string input
1052
+ output = convert_string_to_embedded input
976
1053
  assert_css 'table', output, 1
977
1054
  assert_css 'table *', output, 0
978
1055
  assert_message logger, :ERROR, '<stdin>: line 5: dropping cell because it exceeds specified number of columns', Hash
@@ -1012,7 +1089,7 @@ of a potentially great harvest of future knowledge and wisdom.
1012
1089
  I wouldn't have it any other way.
1013
1090
  |===
1014
1091
  EOS
1015
- output = render_embedded_string input
1092
+ output = convert_string_to_embedded input
1016
1093
  assert_css 'table', output, 1
1017
1094
  assert_css 'table > colgroup > col', output, 3
1018
1095
  assert_css 'table > thead', output, 1
@@ -1042,7 +1119,7 @@ third paragraph
1042
1119
  |===
1043
1120
  EOS
1044
1121
 
1045
- result = render_embedded_string input
1122
+ result = convert_string_to_embedded input
1046
1123
  assert_xpath %((//p[@class="tableblock"])[1][text()="first wrapped\nparagraph"]), result, 1
1047
1124
  assert_xpath %((//p[@class="tableblock"])[2][text()="second paragraph"]), result, 1
1048
1125
  assert_xpath %((//p[@class="tableblock"])[3][text()="third paragraph"]), result, 1
@@ -1059,7 +1136,7 @@ content
1059
1136
  |===
1060
1137
  EOS
1061
1138
 
1062
- result = render_embedded_string input
1139
+ result = convert_string_to_embedded input
1063
1140
  assert_css 'table.tableblock', result, 1
1064
1141
  assert_css 'table.tableblock td.tableblock', result, 1
1065
1142
  assert_css 'table.tableblock td.tableblock .openblock', result, 1
@@ -1074,7 +1151,7 @@ a|AsciiDoc table cell
1074
1151
  |===
1075
1152
  EOS
1076
1153
 
1077
- result = render_embedded_string input
1154
+ result = convert_string_to_embedded input
1078
1155
  assert_css 'table.tableblock td.tableblock > div.content', result, 1
1079
1156
  assert_css 'table.tableblock td.tableblock > div.content > div.paragraph', result, 1
1080
1157
  end
@@ -1089,7 +1166,7 @@ content
1089
1166
  |===
1090
1167
  EOS
1091
1168
 
1092
- result = render_embedded_string input
1169
+ result = convert_string_to_embedded input
1093
1170
  assert_css 'table.tableblock', result, 1
1094
1171
  assert_css 'table.tableblock .paragraph', result, 0
1095
1172
  end
@@ -1111,7 +1188,7 @@ doctype={doctype}
1111
1188
  |===
1112
1189
  EOS
1113
1190
 
1114
- result = render_embedded_string input, :attributes => { 'attribute-missing' => 'skip' }
1191
+ result = convert_string_to_embedded input, :attributes => { 'attribute-missing' => 'skip' }
1115
1192
  assert_includes result, 'doctype=article'
1116
1193
  refute_includes result, '{backend-html5-doctype-article}'
1117
1194
  assert_includes result, '{backend-html5-doctype-book}'
@@ -1135,7 +1212,7 @@ doctype={doctype}
1135
1212
  |===
1136
1213
  EOS
1137
1214
 
1138
- result = render_embedded_string input, :attributes => { 'attribute-missing' => 'skip' }
1215
+ result = convert_string_to_embedded input, :attributes => { 'attribute-missing' => 'skip' }
1139
1216
  assert_includes result, 'doctype=book'
1140
1217
  refute_includes result, '{backend-html5-doctype-book}'
1141
1218
  assert_includes result, '{backend-html5-doctype-article}'
@@ -1222,7 +1299,7 @@ a|include::fixtures/include-file.asciidoc[]
1222
1299
  |===
1223
1300
  EOS
1224
1301
 
1225
- output = render_embedded_string input, :safe => :safe, :base_dir => testdir
1302
+ output = convert_string_to_embedded input, :safe => :safe, :base_dir => testdir
1226
1303
  assert_match(/included content/, output)
1227
1304
  end
1228
1305
 
@@ -1239,7 +1316,7 @@ a|See <<_more>>
1239
1316
  content
1240
1317
  EOS
1241
1318
 
1242
- result = render_string input
1319
+ result = convert_string input
1243
1320
  assert_xpath '//a[@href="#_more"]', result, 1
1244
1321
  assert_xpath '//a[@href="#_more"][text()="More"]', result, 1
1245
1322
  end
@@ -1276,7 +1353,7 @@ a|AsciiDoc footnote:[A lightweight markup language.]
1276
1353
  |===
1277
1354
  EOS
1278
1355
 
1279
- result = render_string input
1356
+ result = convert_string input
1280
1357
  assert_css '#_footnotedef_1', result, 1
1281
1358
  end
1282
1359
 
@@ -1315,7 +1392,7 @@ key: value <1>
1315
1392
  <1> Third callout
1316
1393
  EOS
1317
1394
 
1318
- result = render_string input, :backend => 'docbook'
1395
+ result = convert_string input, :backend => 'docbook'
1319
1396
  conums = xmlnodes_at_xpath '//co', result
1320
1397
  assert_equal 3, conums.size
1321
1398
  ['CO1-1', 'CO2-1', 'CO3-1'].each_with_index do |conum, idx|
@@ -1338,7 +1415,7 @@ The word 'italic' is emphasized.
1338
1415
  |===
1339
1416
  EOS
1340
1417
 
1341
- result = render_embedded_string input
1418
+ result = convert_string_to_embedded input
1342
1419
  assert_xpath '//em[text()="italic"]', result, 1
1343
1420
  end
1344
1421
 
@@ -1358,7 +1435,7 @@ The word 'slanted' is emphasized.
1358
1435
  The word 'askew' is emphasized.
1359
1436
  EOS
1360
1437
 
1361
- result = render_embedded_string input
1438
+ result = convert_string_to_embedded input
1362
1439
  assert_xpath '//em[text()="italic"]', result, 1
1363
1440
  assert_xpath '//em[text()="oblique"]', result, 1
1364
1441
  assert_xpath '//em[text()="slanted"]', result, 1
@@ -1383,7 +1460,7 @@ The word 'slanted' is not emphasized.
1383
1460
  The word 'askew' is emphasized.
1384
1461
  EOS
1385
1462
 
1386
- result = render_embedded_string input
1463
+ result = convert_string_to_embedded input
1387
1464
  assert_xpath '//em[text()="italic"]', result, 1
1388
1465
  assert_xpath '//em[text()="oblique"]', result, 1
1389
1466
  assert_xpath '//em[text()="slanted"]', result, 0
@@ -1402,7 +1479,7 @@ The word 'askew' is emphasized.
1402
1479
  !===
1403
1480
  |===
1404
1481
  EOS
1405
- output = render_embedded_string input
1482
+ output = convert_string_to_embedded input
1406
1483
  assert_css 'table', output, 2
1407
1484
  assert_css 'table table', output, 1
1408
1485
  assert_css 'table > tbody > tr > td:nth-child(2) table', output, 1
@@ -1422,7 +1499,7 @@ a|
1422
1499
  |===
1423
1500
  EOS
1424
1501
 
1425
- output = render_embedded_string input
1502
+ output = convert_string_to_embedded input
1426
1503
  assert_css 'table', output, 2
1427
1504
  assert_css 'table table', output, 1
1428
1505
  assert_css 'table > tbody > tr > td:nth-child(2) table', output, 1
@@ -1441,7 +1518,7 @@ a|AsciiDoc content
1441
1518
  |===
1442
1519
  EOS
1443
1520
 
1444
- output = render_string input
1521
+ output = convert_string input
1445
1522
  assert_css '.toc', output, 1
1446
1523
  assert_css 'table .toc', output, 0
1447
1524
  end
@@ -1463,7 +1540,7 @@ content
1463
1540
  |===
1464
1541
  EOS
1465
1542
 
1466
- output = render_string input
1543
+ output = convert_string input
1467
1544
  assert_css '.toc', output, 1
1468
1545
  assert_css 'table .toc', output, 1
1469
1546
  end
@@ -1489,7 +1566,7 @@ content
1489
1566
  |===
1490
1567
  EOS
1491
1568
 
1492
- output = render_string input
1569
+ output = convert_string input
1493
1570
  assert_css '.toc', output, 2
1494
1571
  assert_css '#toc', output, 1
1495
1572
  assert_css 'table .toc', output, 1
@@ -1506,7 +1583,7 @@ content
1506
1583
  |===
1507
1584
  EOS
1508
1585
 
1509
- output = render_string input
1586
+ output = convert_string input
1510
1587
  assert_css 'table', output, 1
1511
1588
  assert_css 'table > tbody > tr > td', output, 1
1512
1589
  assert_css 'table > tbody > tr > td #preamble', output, 0
@@ -1526,7 +1603,7 @@ plain
1526
1603
  |===
1527
1604
  EOS
1528
1605
 
1529
- output = render_embedded_string input
1606
+ output = convert_string_to_embedded input
1530
1607
  assert_xpath '(/table/thead/tr/th)[1][@style="background-color: green;"]', output, 1
1531
1608
  assert_xpath '(/table/thead/tr/th)[2][@style="background-color: green;"]', output, 0
1532
1609
  assert_xpath '(/table/tbody/tr/td)[1][@style="background-color: red;"]', output, 1
@@ -1547,7 +1624,7 @@ eof
1547
1624
  EOS
1548
1625
 
1549
1626
  using_memory_logger do |logger|
1550
- output = render_embedded_string input
1627
+ output = convert_string_to_embedded input
1551
1628
  assert_xpath '/table', output, 1
1552
1629
  assert_message logger, :WARN, '<stdin>: line 3: unterminated table block', Hash
1553
1630
  end
@@ -1571,16 +1648,107 @@ eof
1571
1648
  EOS
1572
1649
 
1573
1650
  using_memory_logger do |logger|
1574
- output = render_embedded_string input
1651
+ output = convert_string_to_embedded input
1575
1652
  assert_xpath '//ul//table', output, 1
1576
1653
  assert_message logger, :WARN, '<stdin>: line 9: unterminated example block', Hash
1577
1654
  end
1578
1655
  end
1656
+
1657
+ test 'custom separator for an AsciiDoc table cell' do
1658
+ input = <<-EOS
1659
+ [cols=2,separator=!]
1660
+ |===
1661
+ !Pipe output to vim
1662
+ a!
1663
+ ----
1664
+ asciidoctor -o - -s test.adoc | view -
1665
+ ----
1666
+ |===
1667
+ EOS
1668
+ output = convert_string_to_embedded input
1669
+ assert_css 'table', output, 1
1670
+ assert_css 'table > colgroup > col', output, 2
1671
+ assert_css 'table > tbody > tr', output, 1
1672
+ assert_css 'table > tbody > tr:nth-child(1) > td', output, 2
1673
+ assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(1) p', output, 1
1674
+ assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(2) .listingblock', output, 1
1675
+ end
1676
+
1677
+ test 'table with breakable option docbook 4.5' do
1678
+ input = <<-EOS
1679
+ .Table with breakable
1680
+ [%breakable]
1681
+ |===
1682
+ |Item |Quantity
1683
+ |Item 1 |1
1684
+ |===
1685
+ EOS
1686
+ output = convert_string_to_embedded input, :backend => 'docbook45'
1687
+ assert_includes output, '<?dbfo keep-together="auto"?>'
1688
+ end
1689
+
1690
+ test 'table with breakable option docbook 5' do
1691
+ input = <<-EOS
1692
+ .Table with breakable
1693
+ [%breakable]
1694
+ |===
1695
+ |Item |Quantity
1696
+ |Item 1 |1
1697
+ |===
1698
+ EOS
1699
+ output = convert_string_to_embedded input, :backend => 'docbook5'
1700
+ assert_includes output, '<?dbfo keep-together="auto"?>'
1701
+ end
1702
+
1703
+ test 'table with unbreakable option docbook 5' do
1704
+ input = <<-EOS
1705
+ .Table with unbreakable
1706
+ [%unbreakable]
1707
+ |===
1708
+ |Item |Quantity
1709
+ |Item 1 |1
1710
+ |===
1711
+ EOS
1712
+ output = convert_string_to_embedded input, :backend => 'docbook5'
1713
+ assert_includes output, '<?dbfo keep-together="always"?>'
1714
+ end
1715
+
1716
+ test 'table with unbreakable option docbook 4.5' do
1717
+ input = <<-EOS
1718
+ .Table with unbreakable
1719
+ [%unbreakable]
1720
+ |===
1721
+ |Item |Quantity
1722
+ |Item 1 |1
1723
+ |===
1724
+ EOS
1725
+ output = convert_string_to_embedded input, :backend => 'docbook45'
1726
+ assert_includes output, '<?dbfo keep-together="always"?>'
1727
+ end
1728
+
1729
+ test 'no implicit header row if cell in first line is quoted and spans multiple lines' do
1730
+ input = <<-EOS
1731
+ [cols=2*l]
1732
+ ,===
1733
+ "A1
1734
+
1735
+ A1 continued",B1
1736
+ A2,B2
1737
+ ,===
1738
+ EOS
1739
+ output = convert_string_to_embedded input
1740
+ assert_css 'table', output, 1
1741
+ assert_css 'table > colgroup > col', output, 2
1742
+ assert_css 'table > thead', output, 0
1743
+ assert_css 'table > tbody', output, 1
1744
+ assert_css 'table > tbody > tr', output, 2
1745
+ assert_xpath %((//td)[1]//pre[text()="A1\n\nA1 continued"]), output, 1
1746
+ end
1579
1747
  end
1580
1748
 
1581
1749
  context 'DSV' do
1582
1750
 
1583
- test 'renders simple dsv table' do
1751
+ test 'converts simple dsv table' do
1584
1752
  input = <<-EOS
1585
1753
  [width="75%",format="dsv"]
1586
1754
  |===
@@ -1611,7 +1779,7 @@ a:b:c
1611
1779
  1:2:3
1612
1780
  :===
1613
1781
  EOS
1614
- output = render_embedded_string input
1782
+ output = convert_string_to_embedded input
1615
1783
  assert_css 'table', output, 1
1616
1784
  assert_css 'table > colgroup > col', output, 3
1617
1785
  assert_css 'table > tbody > tr', output, 2
@@ -1626,7 +1794,7 @@ single cell
1626
1794
  :===
1627
1795
  EOS
1628
1796
 
1629
- output = render_embedded_string input
1797
+ output = convert_string_to_embedded input
1630
1798
  assert_css 'table td', output, 1
1631
1799
  end
1632
1800
 
@@ -1638,7 +1806,7 @@ B1:B2
1638
1806
  C1:C2
1639
1807
  :===
1640
1808
  EOS
1641
- output = render_embedded_string input
1809
+ output = convert_string_to_embedded input
1642
1810
  assert_css 'table', output, 1
1643
1811
  assert_css 'table > colgroup > col', output, 2
1644
1812
  assert_css 'table > tbody > tr', output, 3
@@ -1659,7 +1827,7 @@ B1,B2
1659
1827
  C1,C2
1660
1828
  ,===
1661
1829
  EOS
1662
- output = render_embedded_string input
1830
+ output = convert_string_to_embedded input
1663
1831
  assert_css 'table', output, 1
1664
1832
  assert_css 'table > colgroup > col', output, 2
1665
1833
  assert_css 'table > tbody > tr', output, 3
@@ -1669,6 +1837,22 @@ C1,C2
1669
1837
  assert_xpath '/table/tbody/tr[2]/td[1]/p[text()="B1"]', output, 1
1670
1838
  end
1671
1839
 
1840
+ test 'should log error but not crash if cell data has unclosed quote' do
1841
+ input = <<-EOS
1842
+ ,===
1843
+ a,b
1844
+ c,"
1845
+ ,===
1846
+ EOS
1847
+ using_memory_logger do |logger|
1848
+ output = convert_string_to_embedded input
1849
+ assert_css 'table', output, 1
1850
+ assert_css 'table td', output, 4
1851
+ assert_xpath '(/table/td)[4]/p', output, 0
1852
+ assert_message logger, :ERROR, '<stdin>: line 3: unclosed quote in CSV data; setting cell to empty', Hash
1853
+ end
1854
+ end
1855
+
1672
1856
  test 'should preserve newlines in quoted CSV values' do
1673
1857
  input = <<-EOS
1674
1858
  [cols="1,1,1l"]
@@ -1686,7 +1870,7 @@ re
1686
1870
  me"
1687
1871
  ,===
1688
1872
  EOS
1689
- output = render_embedded_string input
1873
+ output = convert_string_to_embedded input
1690
1874
  assert_css 'table', output, 1
1691
1875
  assert_css 'table > colgroup > col', output, 3
1692
1876
  assert_css 'table > tbody > tr', output, 1
@@ -1713,7 +1897,7 @@ air, moon roof, loaded",4799.00
1713
1897
  2000,Toyota,Tundra,"Check it, ""this one's gonna to blow you're socks off"", per the sticker",10000.00
1714
1898
  |===
1715
1899
  EOS
1716
- output = render_embedded_string input
1900
+ output = convert_string_to_embedded input
1717
1901
  assert_css 'table', output, 1
1718
1902
  assert_css 'table > colgroup > col[style*="width: 20%"]', output, 5
1719
1903
  assert_css 'table > thead > tr', output, 1
@@ -1736,7 +1920,7 @@ B
1736
1920
  "
1737
1921
  ,===
1738
1922
  EOS
1739
- output = render_embedded_string input
1923
+ output = convert_string_to_embedded input
1740
1924
  assert_css 'table', output, 1
1741
1925
  assert_css 'table > colgroup > col', output, 2
1742
1926
  assert_css 'table > tbody > tr', output, 1
@@ -1752,7 +1936,7 @@ a,b,c
1752
1936
  1,2,3
1753
1937
  ,===
1754
1938
  EOS
1755
- output = render_embedded_string input
1939
+ output = convert_string_to_embedded input
1756
1940
  assert_css 'table', output, 1
1757
1941
  assert_css 'table > colgroup > col', output, 3
1758
1942
  assert_css 'table > tbody > tr', output, 2
@@ -1768,7 +1952,7 @@ a\tb\tc
1768
1952
  1\t2\t3
1769
1953
  ,===
1770
1954
  EOS
1771
- output = render_embedded_string input
1955
+ output = convert_string_to_embedded input
1772
1956
  assert_css 'table', output, 1
1773
1957
  assert_css 'table > colgroup > col', output, 3
1774
1958
  assert_css 'table > tbody > tr', output, 2
@@ -1784,7 +1968,7 @@ a;b;c
1784
1968
  1;2;3
1785
1969
  |===
1786
1970
  EOS
1787
- output = render_embedded_string input
1971
+ output = convert_string_to_embedded input
1788
1972
  assert_css 'table', output, 1
1789
1973
  assert_css 'table > colgroup > col', output, 3
1790
1974
  assert_css 'table > tbody > tr', output, 2
@@ -1800,7 +1984,7 @@ a\tb\tc
1800
1984
  1\t2\t3
1801
1985
  ,===
1802
1986
  EOS
1803
- output = render_embedded_string input
1987
+ output = convert_string_to_embedded input
1804
1988
  assert_css 'table', output, 1
1805
1989
  assert_css 'table > colgroup > col', output, 3
1806
1990
  assert_css 'table > tbody > tr', output, 2
@@ -1808,26 +1992,6 @@ a\tb\tc
1808
1992
  assert_css 'table > tbody > tr:nth-child(2) > td', output, 3
1809
1993
  end
1810
1994
 
1811
- test 'custom separator for an AsciiDoc table cell' do
1812
- input = <<-EOS
1813
- [cols=2,separator=!]
1814
- |===
1815
- !Pipe output to vim
1816
- a!
1817
- ----
1818
- asciidoctor -o - -s test.adoc | view -
1819
- ----
1820
- |===
1821
- EOS
1822
- output = render_embedded_string input
1823
- assert_css 'table', output, 1
1824
- assert_css 'table > colgroup > col', output, 2
1825
- assert_css 'table > tbody > tr', output, 1
1826
- assert_css 'table > tbody > tr:nth-child(1) > td', output, 2
1827
- assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(1) p', output, 1
1828
- assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(2) .listingblock', output, 1
1829
- end
1830
-
1831
1995
  test 'single cell in CSV table should only produce single row' do
1832
1996
  input = <<-EOS
1833
1997
  ,===
@@ -1835,79 +1999,38 @@ single cell
1835
1999
  ,===
1836
2000
  EOS
1837
2001
 
1838
- output = render_embedded_string input
2002
+ output = convert_string_to_embedded input
1839
2003
  assert_css 'table td', output, 1
1840
2004
  end
1841
2005
 
1842
- test 'table with breakable db45' do
1843
- input = <<-EOS
1844
- .Table with breakable
1845
- [options="breakable"]
1846
- |===
1847
- |Item |Quantity
1848
- |Item 1 |1
1849
- |===
1850
- EOS
1851
- output = render_embedded_string input, :backend => 'docbook45'
1852
- assert_includes output, '<?dbfo keep-together="auto"?>'
1853
- end
1854
-
1855
- test 'table with breakable db5' do
2006
+ test 'cell formatted with AsciiDoc style' do
1856
2007
  input = <<-EOS
1857
- .Table with breakable
1858
- [options="breakable"]
1859
- |===
1860
- |Item |Quantity
1861
- |Item 1 |1
1862
- |===
1863
- EOS
1864
- output = render_embedded_string input, :backend => 'docbook5'
1865
- assert_includes output, '<?dbfo keep-together="auto"?>'
1866
- end
2008
+ [cols="1,1,1a",separator=;]
2009
+ ,===
2010
+ element;description;example
1867
2011
 
1868
- test 'table with unbreakable db5' do
1869
- input = <<-EOS
1870
- .Table with unbreakable
1871
- [options="unbreakable"]
1872
- |===
1873
- |Item |Quantity
1874
- |Item 1 |1
1875
- |===
2012
+ thematic break,a visible break; also known as a horizontal rule;---
2013
+ ,===
1876
2014
  EOS
1877
- output = render_embedded_string input, :backend => 'docbook5'
1878
- assert_includes output, '<?dbfo keep-together="always"?>'
1879
- end
1880
2015
 
1881
- test 'table with unbreakable db45' do
1882
- input = <<-EOS
1883
- .Table with unbreakable
1884
- [options="unbreakable"]
1885
- |===
1886
- |Item |Quantity
1887
- |Item 1 |1
1888
- |===
1889
- EOS
1890
- output = render_embedded_string input, :backend => 'docbook45'
1891
- assert_includes output, '<?dbfo keep-together="always"?>'
2016
+ output = convert_string_to_embedded input
2017
+ assert_css 'table tbody hr', output, 1
1892
2018
  end
1893
2019
 
1894
- test 'no implicit header row if cell in first line is quoted and spans multiple lines' do
2020
+ test 'should strip whitespace around contents of AsciiDoc cell' do
1895
2021
  input = <<-EOS
1896
- [cols=2*l]
2022
+ [cols="1,1,1a",separator=;]
1897
2023
  ,===
1898
- "A1
2024
+ element;description;example
1899
2025
 
1900
- A1 continued",B1
1901
- A2,B2
2026
+ paragraph;contiguous lines of words and phrases;"
2027
+ one sentence, one line
2028
+ "
1902
2029
  ,===
1903
2030
  EOS
1904
- output = render_embedded_string input
1905
- assert_css 'table', output, 1
1906
- assert_css 'table > colgroup > col', output, 2
1907
- assert_css 'table > thead', output, 0
1908
- assert_css 'table > tbody', output, 1
1909
- assert_css 'table > tbody > tr', output, 2
1910
- assert_xpath %((//td)[1]//pre[text()="A1\n\nA1 continued"]), output, 1
2031
+
2032
+ output = convert_string_to_embedded input
2033
+ assert_xpath '/table/tbody//*[@class="paragraph"]/p[text()="one sentence, one line"]', output, 1
1911
2034
  end
1912
2035
  end
1913
2036
  end