asciidoctor 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of asciidoctor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +67 -5
- data/CONTRIBUTING.adoc +171 -0
- data/LICENSE.adoc +1 -1
- data/README.adoc +62 -30
- data/bin/asciidoctor +3 -3
- data/bin/asciidoctor-safe +8 -5
- data/lib/asciidoctor.rb +10 -21
- data/lib/asciidoctor/abstract_block.rb +29 -11
- data/lib/asciidoctor/abstract_node.rb +11 -6
- data/lib/asciidoctor/callouts.rb +6 -10
- data/lib/asciidoctor/cli/options.rb +2 -2
- data/lib/asciidoctor/converter.rb +1 -1
- data/lib/asciidoctor/converter/docbook5.rb +46 -23
- data/lib/asciidoctor/converter/factory.rb +3 -3
- data/lib/asciidoctor/converter/html5.rb +27 -24
- data/lib/asciidoctor/converter/manpage.rb +72 -61
- data/lib/asciidoctor/converter/template.rb +5 -9
- data/lib/asciidoctor/document.rb +18 -18
- data/lib/asciidoctor/extensions.rb +5 -5
- data/lib/asciidoctor/helpers.rb +2 -2
- data/lib/asciidoctor/inline.rb +2 -2
- data/lib/asciidoctor/parser.rb +59 -59
- data/lib/asciidoctor/path_resolver.rb +23 -15
- data/lib/asciidoctor/reader.rb +34 -29
- data/lib/asciidoctor/section.rb +6 -8
- data/lib/asciidoctor/substitutors.rb +2 -2
- data/lib/asciidoctor/table.rb +46 -23
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +11 -11
- data/man/asciidoctor.adoc +2 -2
- data/test/attributes_test.rb +21 -37
- data/test/blocks_test.rb +41 -14
- data/test/converter_test.rb +4 -4
- data/test/document_test.rb +61 -8
- data/test/extensions_test.rb +2 -2
- data/test/invoker_test.rb +3 -3
- data/test/links_test.rb +13 -3
- data/test/lists_test.rb +114 -114
- data/test/manpage_test.rb +203 -0
- data/test/paragraphs_test.rb +3 -3
- data/test/parser_test.rb +4 -4
- data/test/preamble_test.rb +1 -1
- data/test/reader_test.rb +149 -109
- data/test/sections_test.rb +137 -27
- data/test/substitutions_test.rb +24 -16
- data/test/tables_test.rb +183 -31
- data/test/test_helper.rb +10 -22
- metadata +9 -6
- data/compat/asciidoc.conf +0 -395
- data/compat/font-awesome-3-compat.css +0 -397
data/test/sections_test.rb
CHANGED
@@ -264,9 +264,71 @@ preamble
|
|
264
264
|
test "document title with symmetric syntax" do
|
265
265
|
assert_xpath "//h1[not(@id)][text() = 'My Title']", render_string("= My Title =")
|
266
266
|
end
|
267
|
+
|
268
|
+
test 'should assign id on document title to body' do
|
269
|
+
input = <<-EOS
|
270
|
+
[[idname]]
|
271
|
+
= Document Title
|
272
|
+
|
273
|
+
content
|
274
|
+
EOS
|
275
|
+
output = render_string input
|
276
|
+
assert_css 'body#idname', output, 1
|
277
|
+
end
|
278
|
+
|
279
|
+
test 'should assign id defined using shorthand syntax on document title to body' do
|
280
|
+
input = <<-EOS
|
281
|
+
[#idname]
|
282
|
+
= Document Title
|
283
|
+
|
284
|
+
content
|
285
|
+
EOS
|
286
|
+
output = render_string input
|
287
|
+
assert_css 'body#idname', output, 1
|
288
|
+
end
|
289
|
+
|
290
|
+
test 'should use inline id instead of id defined in block attributes' do
|
291
|
+
input = <<-EOS
|
292
|
+
[#idname-block]
|
293
|
+
= Document Title [[idname-inline]]
|
294
|
+
|
295
|
+
content
|
296
|
+
EOS
|
297
|
+
output = render_string input
|
298
|
+
assert_css 'body#idname-inline', output, 1
|
299
|
+
end
|
300
|
+
|
301
|
+
test 'block id above document title sets id on document' do
|
302
|
+
input = <<-EOS
|
303
|
+
[[reference]]
|
304
|
+
= Reference Manual
|
305
|
+
:css-signature: refguide
|
306
|
+
|
307
|
+
preamble
|
308
|
+
EOS
|
309
|
+
doc = document_from_string input
|
310
|
+
assert_equal 'reference', doc.id
|
311
|
+
assert_equal 'refguide', doc.attr('css-signature')
|
312
|
+
output = doc.render
|
313
|
+
assert_css 'body#reference', output, 1
|
314
|
+
end
|
315
|
+
|
316
|
+
test 'should discard style, role and options shorthand attributes defined on document title' do
|
317
|
+
input = <<-EOS
|
318
|
+
[style#idname.rolename%optionname]
|
319
|
+
= Document Title
|
320
|
+
|
321
|
+
content
|
322
|
+
EOS
|
323
|
+
doc = document_from_string input
|
324
|
+
assert doc.blocks[0].attributes.empty?
|
325
|
+
output = doc.convert
|
326
|
+
assert_css 'body#idname', output, 1
|
327
|
+
assert_css '.rolename', output, 0
|
328
|
+
end
|
267
329
|
end
|
268
330
|
|
269
|
-
context "level 1" do
|
331
|
+
context "level 1" do
|
270
332
|
test "with multiline syntax" do
|
271
333
|
assert_xpath "//h2[@id='_my_section'][text() = 'My Section']", render_string("My Section\n-----------")
|
272
334
|
end
|
@@ -292,7 +354,7 @@ preamble
|
|
292
354
|
test "with XML entity" do
|
293
355
|
assert_xpath "//h2[@id='_where_s_the_love'][text() = \"Where#{[8217].pack('U*')}s the love?\"]", render_string("== Where's the love?")
|
294
356
|
end
|
295
|
-
|
357
|
+
|
296
358
|
test "with non-word character" do
|
297
359
|
assert_xpath "//h2[@id='_where_s_the_love'][text() = \"Where’s the love?\"]", render_string("== Where’s the love?")
|
298
360
|
end
|
@@ -351,7 +413,7 @@ content
|
|
351
413
|
end if ::RUBY_MIN_VERSION_1_9
|
352
414
|
end
|
353
415
|
|
354
|
-
context "level 2" do
|
416
|
+
context "level 2" do
|
355
417
|
test "with multiline syntax" do
|
356
418
|
assert_xpath "//h3[@id='_my_section'][text() = 'My Section']", render_string(":fragment:\nMy Section\n~~~~~~~~~~~")
|
357
419
|
end
|
@@ -359,9 +421,9 @@ content
|
|
359
421
|
test "with single line syntax" do
|
360
422
|
assert_xpath "//h3[@id='_my_title'][text() = 'My Title']", render_string(":fragment:\n=== My Title")
|
361
423
|
end
|
362
|
-
end
|
424
|
+
end
|
363
425
|
|
364
|
-
context "level 3" do
|
426
|
+
context "level 3" do
|
365
427
|
test "with multiline syntax" do
|
366
428
|
assert_xpath "//h4[@id='_my_section'][text() = 'My Section']", render_string(":fragment:\nMy Section\n^^^^^^^^^^")
|
367
429
|
end
|
@@ -371,7 +433,7 @@ content
|
|
371
433
|
end
|
372
434
|
end
|
373
435
|
|
374
|
-
context "level 4" do
|
436
|
+
context "level 4" do
|
375
437
|
test "with multiline syntax" do
|
376
438
|
assert_xpath "//h5[@id='_my_section'][text() = 'My Section']", render_string(":fragment:\nMy Section\n++++++++++")
|
377
439
|
end
|
@@ -381,7 +443,7 @@ content
|
|
381
443
|
end
|
382
444
|
end
|
383
445
|
|
384
|
-
context "level 5" do
|
446
|
+
context "level 5" do
|
385
447
|
test "with single line syntax" do
|
386
448
|
assert_xpath "//h6[@id='_my_title'][text() = 'My Title']", render_string(":fragment:\n====== My Title")
|
387
449
|
end
|
@@ -636,14 +698,14 @@ text in standalone
|
|
636
698
|
// end simulated include::[]
|
637
699
|
EOS
|
638
700
|
|
639
|
-
output
|
701
|
+
output = warnings = nil
|
640
702
|
redirect_streams do |out, err|
|
641
703
|
output = render_string input
|
642
|
-
|
704
|
+
warnings = err.string
|
643
705
|
end
|
644
706
|
|
645
|
-
assert !
|
646
|
-
assert_match(/only book doctypes can contain level 0 sections/,
|
707
|
+
assert !warnings.empty?
|
708
|
+
assert_match(/only book doctypes can contain level 0 sections/, warnings)
|
647
709
|
end
|
648
710
|
|
649
711
|
test 'should add level offset to section level' do
|
@@ -673,16 +735,15 @@ Standalone section text.
|
|
673
735
|
Master section text.
|
674
736
|
EOS
|
675
737
|
|
676
|
-
output = nil
|
677
|
-
errors = nil
|
738
|
+
output = warnings = nil
|
678
739
|
redirect_streams do |out, err|
|
679
740
|
output = render_string input
|
680
|
-
|
741
|
+
warnings = err.string
|
681
742
|
end
|
682
743
|
|
683
|
-
assert
|
684
|
-
assert_match(/Master document written by Doc Writer/, output)
|
685
|
-
assert_match(/Standalone document written by Junior Writer/, output)
|
744
|
+
assert warnings.empty?
|
745
|
+
assert_match(/Master document written by Doc Writer/, output)
|
746
|
+
assert_match(/Standalone document written by Junior Writer/, output)
|
686
747
|
assert_xpath '//*[@class="sect1"]/h2[text() = "Standalone Document"]', output, 1
|
687
748
|
assert_xpath '//*[@class="sect2"]/h3[text() = "Section in Standalone"]', output, 1
|
688
749
|
assert_xpath '//*[@class="sect1"]/h2[text() = "Section in Master"]', output, 1
|
@@ -798,7 +859,7 @@ content
|
|
798
859
|
= Title
|
799
860
|
:sectnums:
|
800
861
|
|
801
|
-
== Section_1
|
862
|
+
== Section_1
|
802
863
|
|
803
864
|
text
|
804
865
|
|
@@ -822,7 +883,7 @@ text
|
|
822
883
|
|
823
884
|
text
|
824
885
|
EOS
|
825
|
-
|
886
|
+
|
826
887
|
output = render_string input
|
827
888
|
assert_xpath '//h2[@id="_section_1"][starts-with(text(), "1. ")]', output, 1
|
828
889
|
assert_xpath '//h3[@id="_section_1_1"][starts-with(text(), "1.1. ")]', output, 1
|
@@ -837,7 +898,7 @@ text
|
|
837
898
|
= Title
|
838
899
|
:numbered:
|
839
900
|
|
840
|
-
== Section_1
|
901
|
+
== Section_1
|
841
902
|
|
842
903
|
text
|
843
904
|
|
@@ -861,7 +922,7 @@ text
|
|
861
922
|
|
862
923
|
text
|
863
924
|
EOS
|
864
|
-
|
925
|
+
|
865
926
|
output = render_string input
|
866
927
|
assert_xpath '//h2[@id="_section_1"][starts-with(text(), "1. ")]', output, 1
|
867
928
|
assert_xpath '//h3[@id="_section_1_1"][starts-with(text(), "1.1. ")]', output, 1
|
@@ -1647,6 +1708,34 @@ Abstract content
|
|
1647
1708
|
assert_xpath '/abstract[@id="abstract_title"]', output, 1
|
1648
1709
|
assert_xpath '/abstract[@id="abstract_title"]/title[text()="Abstract Title"]', output, 1
|
1649
1710
|
end
|
1711
|
+
|
1712
|
+
test 'should allow a special section to be nested at arbitrary depth in DocBook output' do
|
1713
|
+
input = <<-EOS
|
1714
|
+
= Document Title
|
1715
|
+
:doctype: book
|
1716
|
+
|
1717
|
+
== Glossaries
|
1718
|
+
|
1719
|
+
[glossary]
|
1720
|
+
=== Glossary A
|
1721
|
+
|
1722
|
+
Glossaries are optional.
|
1723
|
+
Glossaries entries are an example of a style of AsciiDoc labeled lists.
|
1724
|
+
|
1725
|
+
[glossary]
|
1726
|
+
A glossary term::
|
1727
|
+
The corresponding definition.
|
1728
|
+
|
1729
|
+
A second glossary term::
|
1730
|
+
The corresponding definition.
|
1731
|
+
EOS
|
1732
|
+
|
1733
|
+
output = render_string input, :backend => :docbook
|
1734
|
+
assert_xpath '//glossary', output, 1
|
1735
|
+
assert_xpath '//chapter/glossary', output, 1
|
1736
|
+
assert_xpath '//glossary/title[text()="Glossary A"]', output, 1
|
1737
|
+
assert_xpath '//glossary/glossentry', output, 2
|
1738
|
+
end
|
1650
1739
|
end
|
1651
1740
|
|
1652
1741
|
context "heading patterns in blocks" do
|
@@ -2312,6 +2401,25 @@ That's all she wrote!
|
|
2312
2401
|
assert_xpath '//*[@id="header"]//*[@id="toc"]/ul/li/ul/li/a[@href="#_interlude"][text()="Interlude"]', output, 1
|
2313
2402
|
assert_xpath '((//*[@id="header"]//*[@id="toc"]/ul)[1]/li)[3]/a[@href="#_section_three"][text()="Section Three"]', output, 1
|
2314
2403
|
end
|
2404
|
+
|
2405
|
+
test 'should not display a table of contents if document has no sections' do
|
2406
|
+
input_src = <<-EOS
|
2407
|
+
= Document Title
|
2408
|
+
:toc:
|
2409
|
+
|
2410
|
+
toc::[]
|
2411
|
+
|
2412
|
+
This document has no sections.
|
2413
|
+
|
2414
|
+
It only has content.
|
2415
|
+
EOS
|
2416
|
+
|
2417
|
+
['', 'left', 'preamble', 'macro'].each do |placement|
|
2418
|
+
input = input_src.gsub(':toc:', "\\& #{placement}")
|
2419
|
+
output = render_string input
|
2420
|
+
assert_css '#toctitle', output, 0
|
2421
|
+
end
|
2422
|
+
end
|
2315
2423
|
end
|
2316
2424
|
|
2317
2425
|
context 'article doctype' do
|
@@ -2474,8 +2582,7 @@ more part intro
|
|
2474
2582
|
intro
|
2475
2583
|
EOS
|
2476
2584
|
|
2477
|
-
doc = nil
|
2478
|
-
warnings = nil
|
2585
|
+
doc = warnings = nil
|
2479
2586
|
redirect_streams do |out, err|
|
2480
2587
|
doc = document_from_string input
|
2481
2588
|
warnings = err.string
|
@@ -2550,6 +2657,10 @@ Preface subsection content
|
|
2550
2657
|
[partintro]
|
2551
2658
|
Part intro content
|
2552
2659
|
|
2660
|
+
== Chapter 1
|
2661
|
+
|
2662
|
+
content
|
2663
|
+
|
2553
2664
|
[appendix]
|
2554
2665
|
= Appendix
|
2555
2666
|
|
@@ -2560,13 +2671,12 @@ Appendix content
|
|
2560
2671
|
Appendix subsection content
|
2561
2672
|
EOS
|
2562
2673
|
|
2563
|
-
output = nil
|
2564
|
-
errors = nil
|
2674
|
+
output = warnings = nil
|
2565
2675
|
redirect_streams do |out, err|
|
2566
2676
|
output = render_string input, :backend => 'docbook'
|
2567
|
-
|
2677
|
+
warnings = err.string
|
2568
2678
|
end
|
2569
|
-
assert
|
2679
|
+
assert warnings.empty?
|
2570
2680
|
assert_xpath '/book/preface', output, 1
|
2571
2681
|
assert_xpath '/book/preface/section', output, 1
|
2572
2682
|
assert_xpath '/book/part', output, 1
|
data/test/substitutions_test.rb
CHANGED
@@ -12,7 +12,7 @@ context 'Substitutions' do
|
|
12
12
|
test 'apply normal substitutions' do
|
13
13
|
para = block_from_string("[blue]_http://asciidoc.org[AsciiDoc]_ & [red]*Ruby*\n§ Making +++<u>documentation</u>+++ together +\nsince (C) {inception_year}.")
|
14
14
|
para.document.attributes['inception_year'] = '2012'
|
15
|
-
result = para.apply_normal_subs(para.lines)
|
15
|
+
result = para.apply_normal_subs(para.lines)
|
16
16
|
assert_equal %{<em class="blue"><a href="http://asciidoc.org">AsciiDoc</a></em> & <strong class="red">Ruby</strong>\n§ Making <u>documentation</u> together<br>\nsince © 2012.}, result
|
17
17
|
end
|
18
18
|
end
|
@@ -1108,47 +1108,47 @@ EOS
|
|
1108
1108
|
para = block_from_string('kbd:[F3]', :attributes => {'experimental' => ''})
|
1109
1109
|
assert_equal %q{<kbd>F3</kbd>}, para.sub_macros(para.source)
|
1110
1110
|
end
|
1111
|
-
|
1111
|
+
|
1112
1112
|
test 'kbd macro with single key, docbook backend' do
|
1113
1113
|
para = block_from_string('kbd:[F3]', :backend => 'docbook', :attributes => {'experimental' => ''})
|
1114
1114
|
assert_equal %q{<keycap>F3</keycap>}, para.sub_macros(para.source)
|
1115
1115
|
end
|
1116
|
-
|
1116
|
+
|
1117
1117
|
test 'kbd macro with key combination' do
|
1118
1118
|
para = block_from_string('kbd:[Ctrl+Shift+T]', :attributes => {'experimental' => ''})
|
1119
1119
|
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></span>}, para.sub_macros(para.source)
|
1120
1120
|
end
|
1121
|
-
|
1121
|
+
|
1122
1122
|
test 'kbd macro with key combination with spaces' do
|
1123
1123
|
para = block_from_string('kbd:[Ctrl + Shift + T]', :attributes => {'experimental' => ''})
|
1124
1124
|
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></span>}, para.sub_macros(para.source)
|
1125
1125
|
end
|
1126
|
-
|
1126
|
+
|
1127
1127
|
test 'kbd macro with key combination delimited by commas' do
|
1128
1128
|
para = block_from_string('kbd:[Ctrl,Shift,T]', :attributes => {'experimental' => ''})
|
1129
1129
|
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd></span>}, para.sub_macros(para.source)
|
1130
1130
|
end
|
1131
|
-
|
1131
|
+
|
1132
1132
|
test 'kbd macro with key combination containing a plus key no spaces' do
|
1133
1133
|
para = block_from_string('kbd:[Ctrl++]', :attributes => {'experimental' => ''})
|
1134
1134
|
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>+</kbd></span>}, para.sub_macros(para.source)
|
1135
1135
|
end
|
1136
|
-
|
1136
|
+
|
1137
1137
|
test 'kbd macro with key combination delimited by commands containing a comma key' do
|
1138
1138
|
para = block_from_string('kbd:[Ctrl,,]', :attributes => {'experimental' => ''})
|
1139
1139
|
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>,</kbd></span>}, para.sub_macros(para.source)
|
1140
1140
|
end
|
1141
|
-
|
1141
|
+
|
1142
1142
|
test 'kbd macro with key combination containing a plus key with spaces' do
|
1143
1143
|
para = block_from_string('kbd:[Ctrl + +]', :attributes => {'experimental' => ''})
|
1144
1144
|
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>+</kbd></span>}, para.sub_macros(para.source)
|
1145
1145
|
end
|
1146
|
-
|
1146
|
+
|
1147
1147
|
test 'kbd macro with key combination containing escaped bracket' do
|
1148
1148
|
para = block_from_string('kbd:[Ctrl + \]]', :attributes => {'experimental' => ''})
|
1149
1149
|
assert_equal %q{<span class="keyseq"><kbd>Ctrl</kbd>+<kbd>]</kbd></span>}, para.sub_macros(para.source)
|
1150
1150
|
end
|
1151
|
-
|
1151
|
+
|
1152
1152
|
test 'kbd macro with key combination, docbook backend' do
|
1153
1153
|
para = block_from_string('kbd:[Ctrl+Shift+T]', :backend => 'docbook', :attributes => {'experimental' => ''})
|
1154
1154
|
assert_equal %q{<keycombo><keycap>Ctrl</keycap><keycap>Shift</keycap><keycap>T</keycap></keycombo>}, para.sub_macros(para.source)
|
@@ -1329,7 +1329,7 @@ EOS
|
|
1329
1329
|
|
1330
1330
|
test 'complex inline passthrough macro' do
|
1331
1331
|
text_to_escape = %q{[(] <'basic form'> <'logical operator'> <'basic form'> [)]}
|
1332
|
-
para = block_from_string %($$#{text_to_escape}$$)
|
1332
|
+
para = block_from_string %($$#{text_to_escape}$$)
|
1333
1333
|
result = para.extract_passthroughs(para.source)
|
1334
1334
|
assert_equal 1, para.passthroughs.size
|
1335
1335
|
assert_equal text_to_escape, para.passthroughs[0][:text]
|
@@ -1365,10 +1365,18 @@ EOS
|
|
1365
1365
|
assert_equal '\$a < b\$', para.content
|
1366
1366
|
end
|
1367
1367
|
|
1368
|
-
|
1368
|
+
# NOTE this test doesn't work once AsciiMath has been loaded
|
1369
|
+
#test 'should not perform specialcharacters subs on asciimath macro content in docbook backend by default' do
|
1370
|
+
# input = 'asciimath:[a < b]'
|
1371
|
+
# para = block_from_string input, :backend => :docbook
|
1372
|
+
# para.document.converter.instance_variable_set :@asciimath_available, false
|
1373
|
+
# assert_equal '<inlineequation><mathphrase><![CDATA[a < b]]></mathphrase></inlineequation>', para.content
|
1374
|
+
#end
|
1375
|
+
|
1376
|
+
test 'should convert asciimath macro content to MathML when asciimath gem is available' do
|
1369
1377
|
input = 'asciimath:[a < b]'
|
1370
1378
|
para = block_from_string input, :backend => :docbook
|
1371
|
-
assert_equal '
|
1379
|
+
assert_equal '<inlineequation><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML"><mml:mi>a</mml:mi><mml:mo><</mml:mo><mml:mi>b</mml:mi></mml:math></inlineequation>', para.content
|
1372
1380
|
end
|
1373
1381
|
|
1374
1382
|
test 'should honor explicit subslist on asciimath macro' do
|
@@ -1398,7 +1406,7 @@ EOS
|
|
1398
1406
|
test 'should not perform specialcharacters subs on latexmath macro content in docbook backend by default' do
|
1399
1407
|
input = 'latexmath:[a < b]'
|
1400
1408
|
para = block_from_string input, :backend => :docbook
|
1401
|
-
|
1409
|
+
assert_equal '<inlineequation><alt><![CDATA[a < b]]></alt><mathphrase><![CDATA[a < b]]></mathphrase></inlineequation>', para.content
|
1402
1410
|
end
|
1403
1411
|
|
1404
1412
|
test 'should honor explicit subslist on latexmath macro' do
|
@@ -1465,7 +1473,7 @@ EOS
|
|
1465
1473
|
end
|
1466
1474
|
|
1467
1475
|
test 'replaces dashes' do
|
1468
|
-
para = block_from_string %(-- foo foo--bar foo\\--bar foo -- bar foo \\-- bar
|
1476
|
+
para = block_from_string %(-- foo foo--bar foo\\--bar foo -- bar foo \\-- bar
|
1469
1477
|
stuff in between
|
1470
1478
|
-- foo
|
1471
1479
|
stuff in between
|
@@ -1487,7 +1495,7 @@ foo — '
|
|
1487
1495
|
end if ::RUBY_MIN_VERSION_1_9
|
1488
1496
|
|
1489
1497
|
test 'replaces marks' do
|
1490
|
-
para = block_from_string '(C) (R) (TM) \(C) \(R) \(TM)'
|
1498
|
+
para = block_from_string '(C) (R) (TM) \(C) \(R) \(TM)'
|
1491
1499
|
assert_equal '© ® ™ (C) (R) (TM)', para.sub_replacements(para.source)
|
1492
1500
|
end
|
1493
1501
|
|
data/test/tables_test.rb
CHANGED
@@ -16,10 +16,14 @@ context 'Tables' do
|
|
16
16
|
|=======
|
17
17
|
EOS
|
18
18
|
cells = [%w(A B C), %w(a b c), %w(1 2 3)]
|
19
|
-
|
19
|
+
doc = document_from_string input, :header_footer => false
|
20
|
+
table = doc.blocks[0]
|
21
|
+
assert 100, table.columns.map {|col| col.attributes['colpcwidth'] }.reduce(:+)
|
22
|
+
output = doc.convert
|
20
23
|
assert_css 'table', output, 1
|
21
24
|
assert_css 'table.tableblock.frame-all.grid-all.spread', output, 1
|
22
|
-
assert_css 'table > colgroup > col[style*="width: 33%"]', output,
|
25
|
+
assert_css 'table > colgroup > col[style*="width: 33.3333%"]', output, 2
|
26
|
+
assert_css 'table > colgroup > col:last-of-type[style*="width: 33.3334%"]', output, 1
|
23
27
|
assert_css 'table tr', output, 3
|
24
28
|
assert_css 'table > tbody > tr', output, 3
|
25
29
|
assert_css 'table td', output, 9
|
@@ -257,6 +261,35 @@ A | here| a | there
|
|
257
261
|
assert_css 'table > tbody > tr', output, 3
|
258
262
|
end
|
259
263
|
|
264
|
+
test 'cols attribute may include spaces' do
|
265
|
+
input = <<-EOS
|
266
|
+
[cols=" 1, 1 "]
|
267
|
+
|===
|
268
|
+
|one |two |1 |2 |a |b
|
269
|
+
|===
|
270
|
+
EOS
|
271
|
+
output = render_embedded_string input
|
272
|
+
assert_css 'table', output, 1
|
273
|
+
assert_css 'table > colgroup > col', output, 2
|
274
|
+
assert_css 'col[style="width: 50%;"]', output, 2
|
275
|
+
assert_css 'table > tbody > tr', output, 3
|
276
|
+
end
|
277
|
+
|
278
|
+
test 'blank cols attribute should be ignored' do
|
279
|
+
input = <<-EOS
|
280
|
+
[cols=" "]
|
281
|
+
|===
|
282
|
+
|one |two
|
283
|
+
|1 |2 |a |b
|
284
|
+
|===
|
285
|
+
EOS
|
286
|
+
output = render_embedded_string input
|
287
|
+
assert_css 'table', output, 1
|
288
|
+
assert_css 'table > colgroup > col', output, 2
|
289
|
+
assert_css 'col[style="width: 50%;"]', output, 2
|
290
|
+
assert_css 'table > tbody > tr', output, 3
|
291
|
+
end
|
292
|
+
|
260
293
|
test 'empty cols attribute should be ignored' do
|
261
294
|
input = <<-EOS
|
262
295
|
[cols=""]
|
@@ -277,10 +310,10 @@ A | here| a | there
|
|
277
310
|
[frame="topbot",options="header,footer"]
|
278
311
|
|===
|
279
312
|
|Item |Quantity
|
280
|
-
|Item 1 |1
|
281
|
-
|Item 2 |2
|
282
|
-
|Item 3 |3
|
283
|
-
|Total |6
|
313
|
+
|Item 1 |1
|
314
|
+
|Item 2 |2
|
315
|
+
|Item 3 |3
|
316
|
+
|Total |6
|
284
317
|
|===
|
285
318
|
EOS
|
286
319
|
output = render_embedded_string input
|
@@ -302,10 +335,10 @@ A | here| a | there
|
|
302
335
|
[frame="topbot",options="header,footer"]
|
303
336
|
|===
|
304
337
|
|Item |Quantity
|
305
|
-
|Item 1 |1
|
306
|
-
|Item 2 |2
|
307
|
-
|Item 3 |3
|
308
|
-
|Total |6
|
338
|
+
|Item 1 |1
|
339
|
+
|Item 2 |2
|
340
|
+
|Item 3 |3
|
341
|
+
|Total |6
|
309
342
|
|===
|
310
343
|
EOS
|
311
344
|
output = render_embedded_string input, :backend => 'docbook'
|
@@ -489,10 +522,10 @@ I am getting in shape!
|
|
489
522
|
assert_css 'table[style*="width: 80%"]', output, 1
|
490
523
|
assert_xpath '/table/caption[@class="title"][text()="Table 1. Horizontal and vertical source data"]', output, 1
|
491
524
|
assert_css 'table > colgroup > col', output, 4
|
492
|
-
assert_css 'table > colgroup > col:nth-child(1)[@style*="width: 17%"]', output, 1
|
493
|
-
assert_css 'table > colgroup > col:nth-child(2)[@style*="width: 11%"]', output, 1
|
494
|
-
assert_css 'table > colgroup > col:nth-child(3)[@style*="width: 11%"]', output, 1
|
495
|
-
assert_css 'table > colgroup > col:nth-child(4)[@style*="width: 58%"]', output, 1
|
525
|
+
assert_css 'table > colgroup > col:nth-child(1)[@style*="width: 17.647%"]', output, 1
|
526
|
+
assert_css 'table > colgroup > col:nth-child(2)[@style*="width: 11.7647%"]', output, 1
|
527
|
+
assert_css 'table > colgroup > col:nth-child(3)[@style*="width: 11.7647%"]', output, 1
|
528
|
+
assert_css 'table > colgroup > col:nth-child(4)[@style*="width: 58.8236%"]', output, 1
|
496
529
|
assert_css 'table > thead', output, 1
|
497
530
|
assert_css 'table > thead > tr', output, 1
|
498
531
|
assert_css 'table > thead > tr > th', output, 4
|
@@ -538,7 +571,7 @@ d|9 2+>|10
|
|
538
571
|
assert_css 'table > tbody > tr:nth-child(2) > td', output, 3
|
539
572
|
assert_css 'table > tbody > tr:nth-child(3) > td', output, 1
|
540
573
|
assert_css 'table > tbody > tr:nth-child(4) > td', output, 2
|
541
|
-
|
574
|
+
|
542
575
|
assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(1).halign-left.valign-top p em', output, 1
|
543
576
|
assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(2).halign-right.valign-top p strong', output, 1
|
544
577
|
assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(3).halign-center.valign-top p', output, 1
|
@@ -564,7 +597,7 @@ d|9 2+>|10
|
|
564
597
|
|AAA |BBB |CCC
|
565
598
|
|===
|
566
599
|
EOS
|
567
|
-
output = render_embedded_string input
|
600
|
+
output = render_embedded_string input
|
568
601
|
assert_css 'table > tbody > tr:nth-child(1) > td', output, 2
|
569
602
|
assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(1)[colspan="2"]', output, 1
|
570
603
|
assert_css 'table > tbody > tr:nth-child(1) > td:nth-child(2):not([colspan])', output, 1
|
@@ -684,10 +717,10 @@ that I can't know enough...
|
|
684
717
|
that I am always hungrily operating on the margins
|
685
718
|
of a potentially great harvest of future knowledge and wisdom.
|
686
719
|
|
687
|
-
I wouldn't have it any other way.
|
720
|
+
I wouldn't have it any other way.
|
688
721
|
|===
|
689
722
|
EOS
|
690
|
-
output = render_embedded_string input
|
723
|
+
output = render_embedded_string input
|
691
724
|
assert_css 'table', output, 1
|
692
725
|
assert_css 'table > colgroup > col', output, 3
|
693
726
|
assert_css 'table > thead', output, 1
|
@@ -783,7 +816,7 @@ output file name is used.
|
|
783
816
|
table = doc.blocks.first
|
784
817
|
assert !table.nil?
|
785
818
|
tbody = table.rows.body
|
786
|
-
assert_equal 2, tbody.size
|
819
|
+
assert_equal 2, tbody.size
|
787
820
|
body_cell_1_3 = tbody[0][2]
|
788
821
|
assert !body_cell_1_3.inner_document.nil?
|
789
822
|
assert body_cell_1_3.inner_document.nested?
|
@@ -796,7 +829,7 @@ output file name is used.
|
|
796
829
|
assert_css 'table > tbody > tr:nth-child(2) > td:nth-child(3) div.dlist', output, 1
|
797
830
|
end
|
798
831
|
|
799
|
-
test 'preprocessor directive on first line of AsciiDoc cell should be processed' do
|
832
|
+
test 'preprocessor directive on first line of an AsciiDoc table cell should be processed' do
|
800
833
|
input = <<-EOS
|
801
834
|
|===
|
802
835
|
a|include::fixtures/include-file.asciidoc[]
|
@@ -807,7 +840,7 @@ a|include::fixtures/include-file.asciidoc[]
|
|
807
840
|
assert_match(/included content/, output)
|
808
841
|
end
|
809
842
|
|
810
|
-
test 'cross reference link in AsciiDoc
|
843
|
+
test 'cross reference link in an AsciiDoc table cell should resolve to reference in main document' do
|
811
844
|
input = <<-EOS
|
812
845
|
== Some
|
813
846
|
|
@@ -825,7 +858,7 @@ content
|
|
825
858
|
assert_xpath '//a[@href="#_more"][text()="More"]', result, 1
|
826
859
|
end
|
827
860
|
|
828
|
-
test 'footnotes should not be shared between AsciiDoc
|
861
|
+
test 'footnotes should not be shared between an AsciiDoc table cell and the main document' do
|
829
862
|
input = <<-EOS
|
830
863
|
|===
|
831
864
|
a|AsciiDoc footnote:[A lightweight markup language.]
|
@@ -836,6 +869,54 @@ a|AsciiDoc footnote:[A lightweight markup language.]
|
|
836
869
|
assert_css '#_footnote_1', result, 1
|
837
870
|
end
|
838
871
|
|
872
|
+
test 'callout numbers should be globally unique, including AsciiDoc table cells' do
|
873
|
+
input = <<-EOS
|
874
|
+
= Document Title
|
875
|
+
|
876
|
+
== Section 1
|
877
|
+
|
878
|
+
|====
|
879
|
+
a|
|
880
|
+
[source, yaml]
|
881
|
+
----
|
882
|
+
key: value <1>
|
883
|
+
----
|
884
|
+
<1> First callout
|
885
|
+
|====
|
886
|
+
|
887
|
+
== Section 2
|
888
|
+
|
889
|
+
|====
|
890
|
+
a|
|
891
|
+
[source, yaml]
|
892
|
+
----
|
893
|
+
key: value <1>
|
894
|
+
----
|
895
|
+
<1> Second callout
|
896
|
+
|====
|
897
|
+
|
898
|
+
== Section 3
|
899
|
+
|
900
|
+
[source, yaml]
|
901
|
+
----
|
902
|
+
key: value <1>
|
903
|
+
----
|
904
|
+
<1> Third callout
|
905
|
+
EOS
|
906
|
+
|
907
|
+
result = render_string input, :backend => 'docbook'
|
908
|
+
conums = xmlnodes_at_xpath '//co', result
|
909
|
+
assert_equal 3, conums.size
|
910
|
+
['CO1-1', 'CO2-1', 'CO3-1'].each_with_index do |conum, idx|
|
911
|
+
assert_equal conum, conums[idx].attribute('xml:id').value
|
912
|
+
end
|
913
|
+
callouts = xmlnodes_at_xpath '//callout', result
|
914
|
+
assert_equal 3, callouts.size
|
915
|
+
['CO1-1', 'CO2-1', 'CO3-1'].each_with_index do |callout, idx|
|
916
|
+
assert_equal callout, callouts[idx].attribute('arearefs').value
|
917
|
+
end
|
918
|
+
end
|
919
|
+
|
839
920
|
test 'nested table' do
|
840
921
|
input = <<-EOS
|
841
922
|
[cols="1,2a"]
|
@@ -856,7 +937,74 @@ a|AsciiDoc footnote:[A lightweight markup language.]
|
|
856
937
|
assert_css 'table > tbody > tr > td:nth-child(2) table > tbody > tr > td', output, 2
|
857
938
|
end
|
858
939
|
|
859
|
-
test '
|
940
|
+
test 'toc from parent document should not be included in an AsciiDoc table cell' do
|
941
|
+
input = <<-EOS
|
942
|
+
= Document Title
|
943
|
+
:toc:
|
944
|
+
|
945
|
+
== Section A
|
946
|
+
|
947
|
+
|===
|
948
|
+
a|AsciiDoc content
|
949
|
+
|===
|
950
|
+
EOS
|
951
|
+
|
952
|
+
output = render_string input
|
953
|
+
assert_css '.toc', output, 1
|
954
|
+
assert_css 'table .toc', output, 0
|
955
|
+
end
|
956
|
+
|
957
|
+
test 'should be able to enable toc in an AsciiDoc table cell' do
|
958
|
+
input = <<-EOS
|
959
|
+
= Document Title
|
960
|
+
|
961
|
+
== Section A
|
962
|
+
|
963
|
+
|===
|
964
|
+
a|
|
965
|
+
= Subdocument Title
|
966
|
+
:toc:
|
967
|
+
|
968
|
+
== Subdocument Section A
|
969
|
+
|
970
|
+
content
|
971
|
+
|===
|
972
|
+
EOS
|
973
|
+
|
974
|
+
output = render_string input
|
975
|
+
assert_css '.toc', output, 1
|
976
|
+
assert_css 'table .toc', output, 1
|
977
|
+
end
|
978
|
+
|
979
|
+
test 'should be able to enable toc in both outer document and in an AsciiDoc table cell' do
|
980
|
+
input = <<-EOS
|
981
|
+
= Document Title
|
982
|
+
:toc:
|
983
|
+
|
984
|
+
== Section A
|
985
|
+
|
986
|
+
|===
|
987
|
+
a|
|
988
|
+
= Subdocument Title
|
989
|
+
:toc: macro
|
990
|
+
|
991
|
+
[#table-cell-toc]
|
992
|
+
toc::[]
|
993
|
+
|
994
|
+
== Subdocument Section A
|
995
|
+
|
996
|
+
content
|
997
|
+
|===
|
998
|
+
EOS
|
999
|
+
|
1000
|
+
output = render_string input
|
1001
|
+
assert_css '.toc', output, 2
|
1002
|
+
assert_css '#toc', output, 1
|
1003
|
+
assert_css 'table .toc', output, 1
|
1004
|
+
assert_css 'table #table-cell-toc', output, 1
|
1005
|
+
end
|
1006
|
+
|
1007
|
+
test 'document in an AsciiDoc table cell should not see doctitle of parent' do
|
860
1008
|
input = <<-EOS
|
861
1009
|
= Document Title
|
862
1010
|
|
@@ -908,9 +1056,13 @@ sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
|
|
908
1056
|
nobody:x:99:99:Nobody:/:/sbin/nologin
|
909
1057
|
|===
|
910
1058
|
EOS
|
911
|
-
|
1059
|
+
doc = document_from_string input, :header_footer => false
|
1060
|
+
table = doc.blocks[0]
|
1061
|
+
assert 100, table.columns.map {|col| col.attributes['colpcwidth'] }.reduce(:+)
|
1062
|
+
output = doc.convert
|
912
1063
|
assert_css 'table', output, 1
|
913
|
-
assert_css 'table > colgroup > col[style*="width: 14
|
1064
|
+
assert_css 'table > colgroup > col[style*="width: 14.2857"]', output, 6
|
1065
|
+
assert_css 'table > colgroup > col:last-of-type[style*="width: 14.2858%"]', output, 1
|
914
1066
|
assert_css 'table > tbody > tr', output, 6
|
915
1067
|
assert_xpath '//tr[4]/td[5]/p/text()', output, 0
|
916
1068
|
assert_xpath '//tr[3]/td[5]/p[text()="MySQL:Server"]', output, 1
|
@@ -993,7 +1145,7 @@ Year,Make,Model,Description,Price
|
|
993
1145
|
air, moon roof, loaded",4799.00
|
994
1146
|
|===
|
995
1147
|
EOS
|
996
|
-
output = render_embedded_string input
|
1148
|
+
output = render_embedded_string input
|
997
1149
|
assert_css 'table', output, 1
|
998
1150
|
assert_css 'table > colgroup > col[style*="width: 20%"]', output, 5
|
999
1151
|
assert_css 'table > thead > tr', output, 1
|
@@ -1034,7 +1186,7 @@ a;b;c
|
|
1034
1186
|
assert_css 'table > tbody > tr:nth-child(2) > td', output, 3
|
1035
1187
|
end
|
1036
1188
|
|
1037
|
-
test 'custom separator
|
1189
|
+
test 'custom separator for an AsciiDoc table cell' do
|
1038
1190
|
input = <<-EOS
|
1039
1191
|
[cols=2,separator=!]
|
1040
1192
|
|===
|
@@ -1071,7 +1223,7 @@ single cell
|
|
1071
1223
|
[options="breakable"]
|
1072
1224
|
|===
|
1073
1225
|
|Item |Quantity
|
1074
|
-
|Item 1 |1
|
1226
|
+
|Item 1 |1
|
1075
1227
|
|===
|
1076
1228
|
EOS
|
1077
1229
|
output = render_embedded_string input, :backend => 'docbook45'
|
@@ -1084,7 +1236,7 @@ single cell
|
|
1084
1236
|
[options="breakable"]
|
1085
1237
|
|===
|
1086
1238
|
|Item |Quantity
|
1087
|
-
|Item 1 |1
|
1239
|
+
|Item 1 |1
|
1088
1240
|
|===
|
1089
1241
|
EOS
|
1090
1242
|
output = render_embedded_string input, :backend => 'docbook5'
|
@@ -1097,7 +1249,7 @@ single cell
|
|
1097
1249
|
[options="unbreakable"]
|
1098
1250
|
|===
|
1099
1251
|
|Item |Quantity
|
1100
|
-
|Item 1 |1
|
1252
|
+
|Item 1 |1
|
1101
1253
|
|===
|
1102
1254
|
EOS
|
1103
1255
|
output = render_embedded_string input, :backend => 'docbook5'
|
@@ -1110,7 +1262,7 @@ single cell
|
|
1110
1262
|
[options="unbreakable"]
|
1111
1263
|
|===
|
1112
1264
|
|Item |Quantity
|
1113
|
-
|Item 1 |1
|
1265
|
+
|Item 1 |1
|
1114
1266
|
|===
|
1115
1267
|
EOS
|
1116
1268
|
output = render_embedded_string input, :backend => 'docbook45'
|