asciidoctor 1.5.6.2 → 1.5.7
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.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +330 -143
- data/README-fr.adoc +441 -0
- data/README-jp.adoc +418 -0
- data/README-zh_CN.adoc +430 -0
- data/README.adoc +454 -0
- data/Rakefile +57 -0
- data/asciidoctor.gemspec +7 -1
- data/data/locale/attributes-ar.adoc +22 -0
- data/data/locale/attributes-bg.adoc +22 -0
- data/data/locale/attributes-ca.adoc +22 -0
- data/data/locale/attributes-cs.adoc +22 -0
- data/data/locale/attributes-da.adoc +22 -0
- data/data/locale/attributes-de.adoc +22 -0
- data/data/locale/attributes-en.adoc +23 -0
- data/data/locale/attributes-es.adoc +22 -0
- data/data/locale/attributes-fa.adoc +22 -0
- data/data/locale/attributes-fi.adoc +22 -0
- data/data/locale/attributes-fr.adoc +22 -0
- data/data/locale/attributes-hu.adoc +22 -0
- data/data/locale/attributes-id.adoc +22 -0
- data/data/locale/attributes-it.adoc +22 -0
- data/data/locale/attributes-ja.adoc +22 -0
- data/data/locale/attributes-kr.adoc +22 -0
- data/data/locale/attributes-nb.adoc +22 -0
- data/data/locale/attributes-nl.adoc +22 -0
- data/data/locale/attributes-nn.adoc +22 -0
- data/data/locale/attributes-pl.adoc +22 -0
- data/data/locale/attributes-pt.adoc +22 -0
- data/data/locale/attributes-pt_BR.adoc +22 -0
- data/data/locale/attributes-ro.adoc +22 -0
- data/data/locale/attributes-ru.adoc +22 -0
- data/data/locale/attributes-sr.adoc +22 -0
- data/data/locale/attributes-sr_Latn.adoc +22 -0
- data/data/locale/attributes-tr.adoc +22 -0
- data/data/locale/attributes-uk.adoc +22 -0
- data/data/locale/attributes-zh_CN.adoc +22 -0
- data/data/locale/attributes-zh_TW.adoc +22 -0
- data/data/locale/attributes.adoc +8 -649
- data/data/stylesheets/asciidoctor-default.css +77 -72
- data/features/xref.feature +366 -7
- data/lib/asciidoctor.rb +107 -93
- data/lib/asciidoctor/abstract_block.rb +247 -239
- data/lib/asciidoctor/abstract_node.rb +56 -58
- data/lib/asciidoctor/block.rb +3 -3
- data/lib/asciidoctor/callouts.rb +1 -1
- data/lib/asciidoctor/cli/invoker.rb +36 -9
- data/lib/asciidoctor/cli/options.rb +63 -25
- data/lib/asciidoctor/converter.rb +23 -13
- data/lib/asciidoctor/converter/base.rb +4 -0
- data/lib/asciidoctor/converter/docbook45.rb +16 -9
- data/lib/asciidoctor/converter/docbook5.rb +115 -97
- data/lib/asciidoctor/converter/factory.rb +29 -31
- data/lib/asciidoctor/converter/html5.rb +229 -192
- data/lib/asciidoctor/converter/manpage.rb +72 -50
- data/lib/asciidoctor/converter/template.rb +12 -12
- data/lib/asciidoctor/core_ext.rb +5 -1
- data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +6 -0
- data/lib/asciidoctor/document.rb +168 -77
- data/lib/asciidoctor/extensions.rb +79 -47
- data/lib/asciidoctor/helpers.rb +33 -11
- data/lib/asciidoctor/inline.rb +3 -2
- data/lib/asciidoctor/list.rb +2 -1
- data/lib/asciidoctor/logging.rb +122 -0
- data/lib/asciidoctor/parser.rb +406 -382
- data/lib/asciidoctor/path_resolver.rb +169 -162
- data/lib/asciidoctor/reader.rb +166 -121
- data/lib/asciidoctor/section.rb +45 -28
- data/lib/asciidoctor/stylesheets.rb +13 -5
- data/lib/asciidoctor/substitutors.rb +328 -254
- data/lib/asciidoctor/table.rb +105 -48
- data/lib/asciidoctor/timings.rb +34 -6
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +41 -23
- data/man/asciidoctor.adoc +14 -8
- data/test/api_test.rb +1004 -0
- data/test/attributes_test.rb +241 -50
- data/test/blocks_test.rb +549 -124
- data/test/converter_test.rb +170 -78
- data/test/document_test.rb +208 -767
- data/test/extensions_test.rb +188 -53
- data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +1 -1
- data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +1 -1
- data/test/fixtures/file-with-missing-include.adoc +1 -0
- data/test/fixtures/include-file.jsx +8 -0
- data/test/fixtures/lists.adoc +96 -0
- data/test/fixtures/other-chapters.adoc +11 -0
- data/test/fixtures/outer-include.adoc +5 -0
- data/test/fixtures/sample.asciidoc +5 -1
- data/test/fixtures/subdir/index.adoc +3 -0
- data/test/fixtures/subdir/inner-include.adoc +3 -0
- data/test/fixtures/subdir/middle-include.adoc +5 -0
- data/test/fixtures/tagged-class-enclosed.rb +0 -1
- data/test/fixtures/unclosed-tag.adoc +3 -0
- data/test/fixtures/unexpected-end-tag.adoc +4 -0
- data/test/invoker_test.rb +101 -40
- data/test/links_test.rb +266 -72
- data/test/lists_test.rb +243 -45
- data/test/logger_test.rb +211 -0
- data/test/manpage_test.rb +124 -6
- data/test/options_test.rb +46 -1
- data/test/paragraphs_test.rb +23 -10
- data/test/parser_test.rb +30 -1
- data/test/paths_test.rb +115 -33
- data/test/preamble_test.rb +1 -1
- data/test/reader_test.rb +337 -81
- data/test/sections_test.rb +656 -72
- data/test/substitutions_test.rb +182 -57
- data/test/tables_test.rb +324 -57
- data/test/test_helper.rb +77 -32
- data/test/text_test.rb +7 -7
- metadata +67 -3
data/test/tables_test.rb
CHANGED
@@ -21,7 +21,7 @@ context 'Tables' do
|
|
21
21
|
assert 100, table.columns.map {|col| col.attributes['colpcwidth'] }.reduce(:+)
|
22
22
|
output = doc.convert
|
23
23
|
assert_css 'table', output, 1
|
24
|
-
assert_css 'table.tableblock.frame-all.grid-all.
|
24
|
+
assert_css 'table.tableblock.frame-all.grid-all.stretch', output, 1
|
25
25
|
assert_css 'table > colgroup > col[style*="width: 33.3333%"]', output, 2
|
26
26
|
assert_css 'table > colgroup > col:last-of-type[style*="width: 33.3334%"]', output, 1
|
27
27
|
assert_css 'table tr', output, 3
|
@@ -37,6 +37,20 @@ context 'Tables' do
|
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
40
|
+
test 'should set stripes class if stripes option is set' do
|
41
|
+
input = <<-EOS
|
42
|
+
[stripes=odd]
|
43
|
+
|=======
|
44
|
+
|A |B |C
|
45
|
+
|a |b |c
|
46
|
+
|1 |2 |3
|
47
|
+
|=======
|
48
|
+
EOS
|
49
|
+
|
50
|
+
output = render_embedded_string input
|
51
|
+
assert_css 'table.stripes-odd', output, 1
|
52
|
+
end
|
53
|
+
|
40
54
|
test 'renders caption on simple psv table' do
|
41
55
|
input = <<-EOS
|
42
56
|
.Simple psv table
|
@@ -109,11 +123,11 @@ context 'Tables' do
|
|
109
123
|
test 'preserves escaped delimiters at the end of the line' do
|
110
124
|
input = <<-EOS
|
111
125
|
[%header,cols="1,1"]
|
112
|
-
|
126
|
+
|===
|
113
127
|
|A |B\\|
|
114
128
|
|A1 |B1\\|
|
115
129
|
|A2 |B2\\|
|
116
|
-
|
130
|
+
|===
|
117
131
|
EOS
|
118
132
|
output = render_embedded_string input
|
119
133
|
assert_css 'table', output, 1
|
@@ -130,11 +144,11 @@ context 'Tables' do
|
|
130
144
|
|
131
145
|
test 'should treat trailing pipe as an empty cell' do
|
132
146
|
input = <<-EOS
|
133
|
-
|
147
|
+
|===
|
134
148
|
|A1 |
|
135
149
|
|B1 |B2
|
136
150
|
|C1 |C2
|
137
|
-
|
151
|
+
|===
|
138
152
|
EOS
|
139
153
|
output = render_embedded_string input
|
140
154
|
assert_css 'table', output, 1
|
@@ -150,18 +164,23 @@ context 'Tables' do
|
|
150
164
|
input = <<-EOS
|
151
165
|
|===
|
152
166
|
A | here| a | there
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
167
|
+
| x
|
168
|
+
| y
|
169
|
+
| z
|
170
|
+
| end
|
171
|
+
|===
|
172
|
+
EOS
|
173
|
+
using_memory_logger do |logger|
|
174
|
+
output = render_embedded_string input
|
175
|
+
assert_css 'table', output, 1
|
176
|
+
assert_css 'table > tbody > tr', output, 2
|
177
|
+
assert_css 'table > tbody > tr > td', output, 8
|
178
|
+
assert_xpath '/table/tbody/tr[1]/td[1]/p[text()="A"]', output, 1
|
179
|
+
assert_xpath '/table/tbody/tr[1]/td[2]/p[text()="here"]', output, 1
|
180
|
+
assert_xpath '/table/tbody/tr[1]/td[3]/p[text()="a"]', output, 1
|
181
|
+
assert_xpath '/table/tbody/tr[1]/td[4]/p[text()="there"]', output, 1
|
182
|
+
assert_message logger, :ERROR, '<stdin>: line 2: table missing leading separator; recovering automatically', Hash
|
183
|
+
end
|
165
184
|
end
|
166
185
|
|
167
186
|
test 'performs normal substitutions on cell content' do
|
@@ -224,7 +243,7 @@ three
|
|
224
243
|
assert_equal %(<div class="verse"> one\n two\nthree</div>), result.to_s
|
225
244
|
end
|
226
245
|
|
227
|
-
test 'table and
|
246
|
+
test 'table and column width not assigned when autowidth option is specified' do
|
228
247
|
input = <<-EOS
|
229
248
|
[options="autowidth"]
|
230
249
|
|=======
|
@@ -235,9 +254,78 @@ three
|
|
235
254
|
EOS
|
236
255
|
output = render_embedded_string input
|
237
256
|
assert_css 'table', output, 1
|
257
|
+
assert_css 'table.fit-content', output, 1
|
238
258
|
assert_css 'table[style*="width"]', output, 0
|
239
259
|
assert_css 'table colgroup col', output, 3
|
240
|
-
assert_css 'table colgroup col[width]', output, 0
|
260
|
+
assert_css 'table colgroup col[style*="width"]', output, 0
|
261
|
+
end
|
262
|
+
|
263
|
+
test 'does not assign column width for autowidth columns in HTML output' do
|
264
|
+
input = <<-EOS
|
265
|
+
[cols="15%,3*~"]
|
266
|
+
|=======
|
267
|
+
|A |B |C |D
|
268
|
+
|a |b |c |d
|
269
|
+
|1 |2 |3 |4
|
270
|
+
|=======
|
271
|
+
EOS
|
272
|
+
doc = document_from_string input
|
273
|
+
table_row0 = doc.blocks[0].rows.body[0]
|
274
|
+
assert_equal 15, table_row0[0].attributes['width']
|
275
|
+
assert_equal 15, table_row0[0].attributes['colpcwidth']
|
276
|
+
refute_equal '', table_row0[0].attributes['autowidth-option']
|
277
|
+
expected_pcwidths = { 1 => 28.3333, 2 => 28.3333, 3 => 28.3334 }
|
278
|
+
(1..3).each do |i|
|
279
|
+
assert_equal 28.3333, table_row0[i].attributes['width']
|
280
|
+
assert_equal expected_pcwidths[i], table_row0[i].attributes['colpcwidth']
|
281
|
+
assert_equal '', table_row0[i].attributes['autowidth-option']
|
282
|
+
end
|
283
|
+
output = doc.convert :header_footer => false
|
284
|
+
assert_css 'table', output, 1
|
285
|
+
assert_css 'table colgroup col', output, 4
|
286
|
+
assert_css 'table colgroup col[style]', output, 1
|
287
|
+
assert_css 'table colgroup col[style*="width: 15%"]', output, 1
|
288
|
+
end
|
289
|
+
|
290
|
+
test 'can assign autowidth to all columns even when table has a width' do
|
291
|
+
input = <<-EOS
|
292
|
+
[cols="4*~",width=50%]
|
293
|
+
|=======
|
294
|
+
|A |B |C |D
|
295
|
+
|a |b |c |d
|
296
|
+
|1 |2 |3 |4
|
297
|
+
|=======
|
298
|
+
EOS
|
299
|
+
doc = document_from_string input
|
300
|
+
table_row0 = doc.blocks[0].rows.body[0]
|
301
|
+
(0..3).each do |i|
|
302
|
+
assert_equal 25, table_row0[i].attributes['width']
|
303
|
+
assert_equal 25, table_row0[i].attributes['colpcwidth']
|
304
|
+
assert_equal '', table_row0[i].attributes['autowidth-option']
|
305
|
+
end
|
306
|
+
output = doc.convert :header_footer => false
|
307
|
+
assert_css 'table', output, 1
|
308
|
+
assert_css 'table[style*="width: 50%;"]', output, 1
|
309
|
+
assert_css 'table colgroup col', output, 4
|
310
|
+
assert_css 'table colgroup col[style]', output, 0
|
311
|
+
end
|
312
|
+
|
313
|
+
test 'equally distributes remaining column width to autowidth columns in DocBook output' do
|
314
|
+
input = <<-EOS
|
315
|
+
[cols="15%,3*~"]
|
316
|
+
|=======
|
317
|
+
|A |B |C |D
|
318
|
+
|a |b |c |d
|
319
|
+
|1 |2 |3 |4
|
320
|
+
|=======
|
321
|
+
EOS
|
322
|
+
output = render_embedded_string input, :backend => 'docbook5'
|
323
|
+
assert_css 'tgroup[cols="4"]', output, 1
|
324
|
+
assert_css 'tgroup colspec', output, 4
|
325
|
+
assert_css 'tgroup colspec[colwidth]', output, 4
|
326
|
+
assert_css 'tgroup colspec[colwidth="15*"]', output, 1
|
327
|
+
assert_css 'tgroup colspec[colwidth="28.3333*"]', output, 2
|
328
|
+
assert_css 'tgroup colspec[colwidth="28.3334*"]', output, 1
|
241
329
|
end
|
242
330
|
|
243
331
|
test 'explicit table width is used even when autowidth option is specified' do
|
@@ -253,16 +341,16 @@ three
|
|
253
341
|
assert_css 'table', output, 1
|
254
342
|
assert_css 'table[style*="width"]', output, 1
|
255
343
|
assert_css 'table colgroup col', output, 3
|
256
|
-
assert_css 'table colgroup col[width]', output, 0
|
344
|
+
assert_css 'table colgroup col[style*="width"]', output, 0
|
257
345
|
end
|
258
346
|
|
259
347
|
test 'first row sets number of columns when not specified' do
|
260
348
|
input = <<-EOS
|
261
|
-
|
349
|
+
|===
|
262
350
|
|first |second |third |fourth
|
263
351
|
|1 |2 |3
|
264
352
|
|4
|
265
|
-
|
353
|
+
|===
|
266
354
|
EOS
|
267
355
|
output = render_embedded_string input
|
268
356
|
assert_css 'table', output, 1
|
@@ -392,6 +480,8 @@ three
|
|
392
480
|
assert_css 'table > tfoot > tr > td', output, 2
|
393
481
|
assert_css 'table > tbody', output, 1
|
394
482
|
assert_css 'table > tbody > tr', output, 3
|
483
|
+
table_section_names = (xmlnodes_at_css 'table > *', output).map(&:node_name).select {|n| n.start_with? 't' }
|
484
|
+
assert_equal %w(thead tbody tfoot), table_section_names
|
395
485
|
end
|
396
486
|
|
397
487
|
test 'table with header and footer docbook' do
|
@@ -425,6 +515,19 @@ three
|
|
425
515
|
assert_css 'table > tgroup > tbody', output, 1
|
426
516
|
assert_css 'table > tgroup > tbody > row', output, 3
|
427
517
|
assert_css 'table > tgroup > tbody > row', output, 3
|
518
|
+
table_section_names = (xmlnodes_at_css 'table > tgroup > *', output).map(&:node_name).select {|n| n.start_with? 't' }
|
519
|
+
assert_equal %w(thead tbody tfoot), table_section_names
|
520
|
+
end
|
521
|
+
|
522
|
+
test 'should recognize ends as an alias to topbot for frame when converting to DocBook' do
|
523
|
+
input = <<-EOS
|
524
|
+
[frame=ends]
|
525
|
+
|===
|
526
|
+
|A |B |C
|
527
|
+
|===
|
528
|
+
EOS
|
529
|
+
output = render_embedded_string input, :backend => 'docbook'
|
530
|
+
assert_css 'informaltable[frame="topbot"]', output, 1
|
428
531
|
end
|
429
532
|
|
430
533
|
test 'table with landscape orientation in DocBook' do
|
@@ -613,11 +716,11 @@ just text
|
|
613
716
|
test 'styles not applied to header cells' do
|
614
717
|
input = <<-EOS
|
615
718
|
[cols="1h,1s,1e",options="header,footer"]
|
616
|
-
|
719
|
+
|===
|
617
720
|
|Name |Occupation| Website
|
618
721
|
|Octocat |Social coding| https://github.com
|
619
722
|
|Name |Occupation| Website
|
620
|
-
|
723
|
+
|===
|
621
724
|
EOS
|
622
725
|
output = render_embedded_string input
|
623
726
|
assert_css 'table', output, 1
|
@@ -639,7 +742,7 @@ just text
|
|
639
742
|
test 'vertical table headers use th element instead of header class' do
|
640
743
|
input = <<-EOS
|
641
744
|
[cols="1h,1s,1e"]
|
642
|
-
|
745
|
+
|===
|
643
746
|
|
644
747
|
|Name |Occupation| Website
|
645
748
|
|
@@ -647,7 +750,7 @@ just text
|
|
647
750
|
|
648
751
|
|Name |Occupation| Website
|
649
752
|
|
650
|
-
|
753
|
+
|===
|
651
754
|
EOS
|
652
755
|
output = render_embedded_string input
|
653
756
|
assert_css 'table', output, 1
|
@@ -837,12 +940,12 @@ d|9 2+>|10
|
|
837
940
|
|
838
941
|
test 'assigns unique column names for table with implicit column count and colspans in first row' do
|
839
942
|
input = <<-EOS
|
840
|
-
|
943
|
+
|===
|
841
944
|
| 2+| Node 0 2+| Node 1
|
842
945
|
|
843
946
|
| Host processes | Core 0 | Core 1 | Core 4 | Core 5
|
844
947
|
| Guest processes | Core 2 | Core 3 | Core 6 | Core 7
|
845
|
-
|
948
|
+
|===
|
846
949
|
EOS
|
847
950
|
|
848
951
|
output = render_embedded_string input, :backend => 'docbook'
|
@@ -859,7 +962,7 @@ d|9 2+>|10
|
|
859
962
|
|
860
963
|
test 'ignores cell with colspan that exceeds colspec' do
|
861
964
|
input = <<-EOS
|
862
|
-
[cols=
|
965
|
+
[cols=2*]
|
863
966
|
|===
|
864
967
|
3+|A
|
865
968
|
|B
|
@@ -868,10 +971,12 @@ a|C
|
|
868
971
|
more C
|
869
972
|
|===
|
870
973
|
EOS
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
974
|
+
using_memory_logger do |logger|
|
975
|
+
output = render_embedded_string input
|
976
|
+
assert_css 'table', output, 1
|
977
|
+
assert_css 'table *', output, 0
|
978
|
+
assert_message logger, :ERROR, '<stdin>: line 5: dropping cell because it exceeds specified number of columns', Hash
|
979
|
+
end
|
875
980
|
end
|
876
981
|
|
877
982
|
test 'paragraph, verse and literal content' do
|
@@ -943,7 +1048,7 @@ third paragraph
|
|
943
1048
|
assert_xpath %((//p[@class="tableblock"])[3][text()="third paragraph"]), result, 1
|
944
1049
|
end
|
945
1050
|
|
946
|
-
test 'basic
|
1051
|
+
test 'basic AsciiDoc cell' do
|
947
1052
|
input = <<-EOS
|
948
1053
|
|===
|
949
1054
|
a|--
|
@@ -962,7 +1067,19 @@ content
|
|
962
1067
|
assert_css 'table.tableblock td.tableblock .openblock .paragraph', result, 1
|
963
1068
|
end
|
964
1069
|
|
965
|
-
test '
|
1070
|
+
test 'AsciiDoc table cell should be wrapped in div with class "content"' do
|
1071
|
+
input = <<-EOS
|
1072
|
+
|===
|
1073
|
+
a|AsciiDoc table cell
|
1074
|
+
|===
|
1075
|
+
EOS
|
1076
|
+
|
1077
|
+
result = render_embedded_string input
|
1078
|
+
assert_css 'table.tableblock td.tableblock > div.content', result, 1
|
1079
|
+
assert_css 'table.tableblock td.tableblock > div.content > div.paragraph', result, 1
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
test 'doctype can be set in AsciiDoc table cell' do
|
966
1083
|
input = <<-EOS
|
967
1084
|
|===
|
968
1085
|
a|
|
@@ -1024,7 +1141,7 @@ doctype={doctype}
|
|
1024
1141
|
assert_includes result, '{backend-html5-doctype-article}'
|
1025
1142
|
end
|
1026
1143
|
|
1027
|
-
test '
|
1144
|
+
test 'AsciiDoc content' do
|
1028
1145
|
input = <<-EOS
|
1029
1146
|
[cols="1e,1,5a",frame="topbot",options="header"]
|
1030
1147
|
|===
|
@@ -1033,9 +1150,11 @@ doctype={doctype}
|
|
1033
1150
|
|badges |xhtml11, html5 |
|
1034
1151
|
Link badges ('XHTML 1.1' and 'CSS') in document footers.
|
1035
1152
|
|
1036
|
-
NOTE
|
1153
|
+
[NOTE]
|
1154
|
+
====
|
1155
|
+
The path names of images, icons and scripts are relative path
|
1037
1156
|
names to the output document not the source document.
|
1038
|
-
|
1157
|
+
====
|
1039
1158
|
|[[X97]] docinfo, docinfo1, docinfo2 |All backends |
|
1040
1159
|
These three attributes control which document information
|
1041
1160
|
files will be included in the the header of the output file:
|
@@ -1050,23 +1169,52 @@ DocBook outputs. If the input file is the standard input then the
|
|
1050
1169
|
output file name is used.
|
1051
1170
|
|===
|
1052
1171
|
EOS
|
1053
|
-
doc = document_from_string input
|
1172
|
+
doc = document_from_string input, :sourcemap => true
|
1054
1173
|
table = doc.blocks.first
|
1055
1174
|
refute_nil table
|
1056
1175
|
tbody = table.rows.body
|
1057
1176
|
assert_equal 2, tbody.size
|
1177
|
+
body_cell_1_2 = tbody[0][1]
|
1178
|
+
assert_equal 5, body_cell_1_2.lineno
|
1058
1179
|
body_cell_1_3 = tbody[0][2]
|
1059
1180
|
refute_nil body_cell_1_3.inner_document
|
1060
1181
|
assert body_cell_1_3.inner_document.nested?
|
1061
1182
|
assert_equal doc, body_cell_1_3.inner_document.parent_document
|
1062
1183
|
assert_equal doc.converter, body_cell_1_3.inner_document.converter
|
1063
|
-
|
1184
|
+
assert_equal 5, body_cell_1_3.lineno
|
1185
|
+
assert_equal 6, body_cell_1_3.inner_document.lineno
|
1186
|
+
note = (body_cell_1_3.inner_document.find_by :context => :admonition)[0]
|
1187
|
+
assert_equal 9, note.lineno
|
1188
|
+
output = doc.convert :header_footer => false
|
1064
1189
|
|
1065
1190
|
assert_css 'table > tbody > tr', output, 2
|
1066
1191
|
assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(3) div.admonitionblock', output, 1
|
1067
1192
|
assert_css 'table > tbody > tr:nth-child(2) > td:nth-child(3) div.dlist', output, 1
|
1068
1193
|
end
|
1069
1194
|
|
1195
|
+
test 'should preserve leading indentation in contents of AsciiDoc table cell if contents starts with newline' do
|
1196
|
+
input = <<-EOS
|
1197
|
+
|===
|
1198
|
+
a|
|
1199
|
+
$ command
|
1200
|
+
a| paragraph
|
1201
|
+
|===
|
1202
|
+
EOS
|
1203
|
+
doc = document_from_string input, :sourcemap => true
|
1204
|
+
table = doc.blocks[0]
|
1205
|
+
tbody = table.rows.body
|
1206
|
+
assert_equal 1, table.lineno
|
1207
|
+
assert_equal 2, tbody[0][0].lineno
|
1208
|
+
assert_equal 3, tbody[0][0].inner_document.lineno
|
1209
|
+
assert_equal 4, tbody[1][0].lineno
|
1210
|
+
output = doc.convert :header_footer => false
|
1211
|
+
assert_css 'td', output, 2
|
1212
|
+
assert_xpath '(//td)[1]//*[@class="literalblock"]', output, 1
|
1213
|
+
assert_xpath '(//td)[2]//*[@class="paragraph"]', output, 1
|
1214
|
+
assert_xpath '(//pre)[1][text()="$ command"]', output, 1
|
1215
|
+
assert_xpath '(//p)[1][text()="paragraph"]', output, 1
|
1216
|
+
end
|
1217
|
+
|
1070
1218
|
test 'preprocessor directive on first line of an AsciiDoc table cell should be processed' do
|
1071
1219
|
input = <<-EOS
|
1072
1220
|
|===
|
@@ -1074,7 +1222,7 @@ a|include::fixtures/include-file.asciidoc[]
|
|
1074
1222
|
|===
|
1075
1223
|
EOS
|
1076
1224
|
|
1077
|
-
output = render_embedded_string input, :safe => :safe, :base_dir =>
|
1225
|
+
output = render_embedded_string input, :safe => :safe, :base_dir => testdir
|
1078
1226
|
assert_match(/included content/, output)
|
1079
1227
|
end
|
1080
1228
|
|
@@ -1096,6 +1244,31 @@ content
|
|
1096
1244
|
assert_xpath '//a[@href="#_more"][text()="More"]', result, 1
|
1097
1245
|
end
|
1098
1246
|
|
1247
|
+
test 'should discover anchor at start of cell and register it as a reference' do
|
1248
|
+
input = <<-EOS
|
1249
|
+
The highest peak in the Front Range is <<grays-peak>>, which tops <<mount-evans>> by just a few feet.
|
1250
|
+
|
1251
|
+
[cols="1s,1"]
|
1252
|
+
|===
|
1253
|
+
|[[mount-evans,Mount Evans]]Mount Evans
|
1254
|
+
|14,271 feet
|
1255
|
+
|
1256
|
+
h|[[grays-peak,Grays Peak]]
|
1257
|
+
Grays Peak
|
1258
|
+
|14,278 feet
|
1259
|
+
|===
|
1260
|
+
EOS
|
1261
|
+
doc = document_from_string input
|
1262
|
+
refs = doc.catalog[:refs]
|
1263
|
+
assert refs.key?('mount-evans')
|
1264
|
+
assert refs.key?('grays-peak')
|
1265
|
+
output = doc.convert :header_footer => false
|
1266
|
+
assert_xpath '(//p)[1]/a[@href="#grays-peak"][text()="Grays Peak"]', output, 1
|
1267
|
+
assert_xpath '(//p)[1]/a[@href="#mount-evans"][text()="Mount Evans"]', output, 1
|
1268
|
+
assert_xpath '(//table/tbody/tr)[1]//td//a[@id="mount-evans"]', output, 1
|
1269
|
+
assert_xpath '(//table/tbody/tr)[2]//th//a[@id="grays-peak"]', output, 1
|
1270
|
+
end
|
1271
|
+
|
1099
1272
|
test 'footnotes should not be shared between an AsciiDoc table cell and the main document' do
|
1100
1273
|
input = <<-EOS
|
1101
1274
|
|===
|
@@ -1104,7 +1277,7 @@ a|AsciiDoc footnote:[A lightweight markup language.]
|
|
1104
1277
|
EOS
|
1105
1278
|
|
1106
1279
|
result = render_string input
|
1107
|
-
assert_css '#
|
1280
|
+
assert_css '#_footnotedef_1', result, 1
|
1108
1281
|
end
|
1109
1282
|
|
1110
1283
|
test 'callout numbers should be globally unique, including AsciiDoc table cells' do
|
@@ -1113,25 +1286,25 @@ a|AsciiDoc footnote:[A lightweight markup language.]
|
|
1113
1286
|
|
1114
1287
|
== Section 1
|
1115
1288
|
|
1116
|
-
|
1289
|
+
|===
|
1117
1290
|
a|
|
1118
1291
|
[source, yaml]
|
1119
1292
|
----
|
1120
1293
|
key: value <1>
|
1121
1294
|
----
|
1122
1295
|
<1> First callout
|
1123
|
-
|
1296
|
+
|===
|
1124
1297
|
|
1125
1298
|
== Section 2
|
1126
1299
|
|
1127
|
-
|
1300
|
+
|===
|
1128
1301
|
a|
|
1129
1302
|
[source, yaml]
|
1130
1303
|
----
|
1131
1304
|
key: value <1>
|
1132
1305
|
----
|
1133
1306
|
<1> Second callout
|
1134
|
-
|
1307
|
+
|===
|
1135
1308
|
|
1136
1309
|
== Section 3
|
1137
1310
|
|
@@ -1359,6 +1532,50 @@ plain
|
|
1359
1532
|
assert_xpath '(/table/tbody/tr/td)[1][@style="background-color: red;"]', output, 1
|
1360
1533
|
assert_xpath '(/table/tbody/tr/td)[2][@style="background-color: green;"]', output, 0
|
1361
1534
|
end
|
1535
|
+
|
1536
|
+
test 'should warn if table block is not terminated' do
|
1537
|
+
input = <<-EOS
|
1538
|
+
outside
|
1539
|
+
|
1540
|
+
|===
|
1541
|
+
|
|
1542
|
+
inside
|
1543
|
+
|
1544
|
+
still inside
|
1545
|
+
|
1546
|
+
eof
|
1547
|
+
EOS
|
1548
|
+
|
1549
|
+
using_memory_logger do |logger|
|
1550
|
+
output = render_embedded_string input
|
1551
|
+
assert_xpath '/table', output, 1
|
1552
|
+
assert_message logger, :WARN, '<stdin>: line 3: unterminated table block', Hash
|
1553
|
+
end
|
1554
|
+
end
|
1555
|
+
|
1556
|
+
test 'should show correct line number in warning about unterminated block inside AsciiDoc table cell' do
|
1557
|
+
input = <<-EOS
|
1558
|
+
outside
|
1559
|
+
|
1560
|
+
* list item
|
1561
|
+
+
|
1562
|
+
|===
|
1563
|
+
|cell
|
1564
|
+
a|inside
|
1565
|
+
|
1566
|
+
====
|
1567
|
+
unterminated example block
|
1568
|
+
|===
|
1569
|
+
|
1570
|
+
eof
|
1571
|
+
EOS
|
1572
|
+
|
1573
|
+
using_memory_logger do |logger|
|
1574
|
+
output = render_embedded_string input
|
1575
|
+
assert_xpath '//ul//table', output, 1
|
1576
|
+
assert_message logger, :WARN, '<stdin>: line 9: unterminated example block', Hash
|
1577
|
+
end
|
1578
|
+
end
|
1362
1579
|
end
|
1363
1580
|
|
1364
1581
|
context 'DSV' do
|
@@ -1415,11 +1632,11 @@ single cell
|
|
1415
1632
|
|
1416
1633
|
test 'should treat trailing colon as an empty cell' do
|
1417
1634
|
input = <<-EOS
|
1418
|
-
|
1635
|
+
:===
|
1419
1636
|
A1:
|
1420
1637
|
B1:B2
|
1421
1638
|
C1:C2
|
1422
|
-
|
1639
|
+
:===
|
1423
1640
|
EOS
|
1424
1641
|
output = render_embedded_string input
|
1425
1642
|
assert_css 'table', output, 1
|
@@ -1436,11 +1653,11 @@ C1:C2
|
|
1436
1653
|
|
1437
1654
|
test 'should treat trailing comma as an empty cell' do
|
1438
1655
|
input = <<-EOS
|
1439
|
-
|
1656
|
+
,===
|
1440
1657
|
A1,
|
1441
1658
|
B1,B2
|
1442
1659
|
C1,C2
|
1443
|
-
|
1660
|
+
,===
|
1444
1661
|
EOS
|
1445
1662
|
output = render_embedded_string input
|
1446
1663
|
assert_css 'table', output, 1
|
@@ -1452,6 +1669,36 @@ C1,C2
|
|
1452
1669
|
assert_xpath '/table/tbody/tr[2]/td[1]/p[text()="B1"]', output, 1
|
1453
1670
|
end
|
1454
1671
|
|
1672
|
+
test 'should preserve newlines in quoted CSV values' do
|
1673
|
+
input = <<-EOS
|
1674
|
+
[cols="1,1,1l"]
|
1675
|
+
,===
|
1676
|
+
"A
|
1677
|
+
B
|
1678
|
+
C","one
|
1679
|
+
|
1680
|
+
two
|
1681
|
+
|
1682
|
+
three","do
|
1683
|
+
|
1684
|
+
re
|
1685
|
+
|
1686
|
+
me"
|
1687
|
+
,===
|
1688
|
+
EOS
|
1689
|
+
output = render_embedded_string input
|
1690
|
+
assert_css 'table', output, 1
|
1691
|
+
assert_css 'table > colgroup > col', output, 3
|
1692
|
+
assert_css 'table > tbody > tr', output, 1
|
1693
|
+
assert_xpath '/table/tbody/tr[1]/td', output, 3
|
1694
|
+
assert_xpath %(/table/tbody/tr[1]/td[1]/p[text()="A\nB\nC"]), output, 1
|
1695
|
+
assert_xpath '/table/tbody/tr[1]/td[2]/p', output, 3
|
1696
|
+
assert_xpath '/table/tbody/tr[1]/td[2]/p[1][text()="one"]', output, 1
|
1697
|
+
assert_xpath '/table/tbody/tr[1]/td[2]/p[2][text()="two"]', output, 1
|
1698
|
+
assert_xpath '/table/tbody/tr[1]/td[2]/p[3][text()="three"]', output, 1
|
1699
|
+
assert_xpath %(/table/tbody/tr[1]/td[3]//pre[text()="do\n\nre\n\nme"]), output, 1
|
1700
|
+
end
|
1701
|
+
|
1455
1702
|
test 'mixed unquoted records and quoted records with escaped quotes, commas, and wrapped lines' do
|
1456
1703
|
input = <<-EOS
|
1457
1704
|
[format="csv",options="header"]
|
@@ -1473,11 +1720,31 @@ air, moon roof, loaded",4799.00
|
|
1473
1720
|
assert_css 'table > tbody > tr', output, 6
|
1474
1721
|
assert_xpath '((//tbody/tr)[1]/td)[4]/p[text()="ac, abs, moon"]', output, 1
|
1475
1722
|
assert_xpath %(((//tbody/tr)[2]/td)[3]/p[text()='Venture "Extended Edition"']), output, 1
|
1476
|
-
assert_xpath
|
1723
|
+
assert_xpath %(((//tbody/tr)[4]/td)[4]/p[text()="MUST SELL!\nair, moon roof, loaded"]), output, 1
|
1477
1724
|
assert_xpath %(((//tbody/tr)[5]/td)[4]/p[text()='"This one#{decode_char 8217}s gonna to blow you#{decode_char 8217}re socks off," per the sticker']), output, 1
|
1478
1725
|
assert_xpath %(((//tbody/tr)[6]/td)[4]/p[text()='Check it, "this one#{decode_char 8217}s gonna to blow you#{decode_char 8217}re socks off", per the sticker']), output, 1
|
1479
1726
|
end
|
1480
1727
|
|
1728
|
+
test 'should allow quotes around a CSV value to be on their own lines' do
|
1729
|
+
input = <<-EOS
|
1730
|
+
[cols=2*]
|
1731
|
+
,===
|
1732
|
+
"
|
1733
|
+
A
|
1734
|
+
","
|
1735
|
+
B
|
1736
|
+
"
|
1737
|
+
,===
|
1738
|
+
EOS
|
1739
|
+
output = render_embedded_string input
|
1740
|
+
assert_css 'table', output, 1
|
1741
|
+
assert_css 'table > colgroup > col', output, 2
|
1742
|
+
assert_css 'table > tbody > tr', output, 1
|
1743
|
+
assert_xpath '/table/tbody/tr[1]/td', output, 2
|
1744
|
+
assert_xpath '/table/tbody/tr[1]/td[1]/p[text()="A"]', output, 1
|
1745
|
+
assert_xpath '/table/tbody/tr[1]/td[2]/p[text()="B"]', output, 1
|
1746
|
+
end
|
1747
|
+
|
1481
1748
|
test 'csv format shorthand' do
|
1482
1749
|
input = <<-EOS
|
1483
1750
|
,===
|
@@ -1582,7 +1849,7 @@ single cell
|
|
1582
1849
|
|===
|
1583
1850
|
EOS
|
1584
1851
|
output = render_embedded_string input, :backend => 'docbook45'
|
1585
|
-
|
1852
|
+
assert_includes output, '<?dbfo keep-together="auto"?>'
|
1586
1853
|
end
|
1587
1854
|
|
1588
1855
|
test 'table with breakable db5' do
|
@@ -1595,7 +1862,7 @@ single cell
|
|
1595
1862
|
|===
|
1596
1863
|
EOS
|
1597
1864
|
output = render_embedded_string input, :backend => 'docbook5'
|
1598
|
-
|
1865
|
+
assert_includes output, '<?dbfo keep-together="auto"?>'
|
1599
1866
|
end
|
1600
1867
|
|
1601
1868
|
test 'table with unbreakable db5' do
|
@@ -1608,7 +1875,7 @@ single cell
|
|
1608
1875
|
|===
|
1609
1876
|
EOS
|
1610
1877
|
output = render_embedded_string input, :backend => 'docbook5'
|
1611
|
-
|
1878
|
+
assert_includes output, '<?dbfo keep-together="always"?>'
|
1612
1879
|
end
|
1613
1880
|
|
1614
1881
|
test 'table with unbreakable db45' do
|
@@ -1621,12 +1888,12 @@ single cell
|
|
1621
1888
|
|===
|
1622
1889
|
EOS
|
1623
1890
|
output = render_embedded_string input, :backend => 'docbook45'
|
1624
|
-
|
1891
|
+
assert_includes output, '<?dbfo keep-together="always"?>'
|
1625
1892
|
end
|
1626
1893
|
|
1627
1894
|
test 'no implicit header row if cell in first line is quoted and spans multiple lines' do
|
1628
1895
|
input = <<-EOS
|
1629
|
-
[cols=2*]
|
1896
|
+
[cols=2*l]
|
1630
1897
|
,===
|
1631
1898
|
"A1
|
1632
1899
|
|
@@ -1640,7 +1907,7 @@ A2,B2
|
|
1640
1907
|
assert_css 'table > thead', output, 0
|
1641
1908
|
assert_css 'table > tbody', output, 1
|
1642
1909
|
assert_css 'table > tbody > tr', output, 2
|
1643
|
-
assert_xpath
|
1910
|
+
assert_xpath %((//td)[1]//pre[text()="A1\n\nA1 continued"]), output, 1
|
1644
1911
|
end
|
1645
1912
|
end
|
1646
1913
|
end
|