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/lists_test.rb
CHANGED
@@ -185,7 +185,7 @@ Bar
|
|
185
185
|
|
186
186
|
output = render_embedded_string input
|
187
187
|
assert_css 'ul ul', output, 1
|
188
|
-
|
188
|
+
refute_includes output, '* Foo'
|
189
189
|
end
|
190
190
|
|
191
191
|
test 'a list item for a different list terminates non-indented paragraph for text of list item' do
|
@@ -205,9 +205,9 @@ term:: def
|
|
205
205
|
|
206
206
|
output = render_embedded_string input
|
207
207
|
assert_css 'ul ol', output, 1
|
208
|
-
|
208
|
+
refute_includes output, '* Foo'
|
209
209
|
assert_css 'ul dl', output, 1
|
210
|
-
|
210
|
+
refute_includes output, 'term:: def'
|
211
211
|
end
|
212
212
|
|
213
213
|
test 'an indented wrapped line is unindented and folded into text of list item' do
|
@@ -255,7 +255,7 @@ second wrapped line
|
|
255
255
|
|
256
256
|
output = render_embedded_string input
|
257
257
|
assert_css 'ul ul', output, 1
|
258
|
-
|
258
|
+
refute_includes output, '* Foo'
|
259
259
|
end
|
260
260
|
|
261
261
|
test 'a list item that starts with a sequence of list markers characters should not match a nested list' do
|
@@ -287,9 +287,9 @@ term:: def
|
|
287
287
|
|
288
288
|
output = render_embedded_string input
|
289
289
|
assert_css 'ul ol', output, 1
|
290
|
-
|
290
|
+
refute_includes output, '* Foo'
|
291
291
|
assert_css 'ul dl', output, 1
|
292
|
-
|
292
|
+
refute_includes output, 'term:: def'
|
293
293
|
end
|
294
294
|
|
295
295
|
test "a literal paragraph offset by blank lines in list content is appended as a literal block" do
|
@@ -355,6 +355,48 @@ NOTE: This is a note.
|
|
355
355
|
assert_xpath '//ul/li/*[@class="admonitionblock note"]//td[@class="content"][normalize-space(text())="This is a note."]', output, 1
|
356
356
|
end
|
357
357
|
|
358
|
+
test 'paragraph-like blocks attached to an ancestory list item by a list continuation should produce blocks' do
|
359
|
+
input = <<-EOS
|
360
|
+
* parent
|
361
|
+
** child
|
362
|
+
|
363
|
+
+
|
364
|
+
NOTE: This is a note.
|
365
|
+
|
366
|
+
* another parent
|
367
|
+
** another child
|
368
|
+
|
369
|
+
+
|
370
|
+
'''
|
371
|
+
EOS
|
372
|
+
|
373
|
+
output = render_embedded_string input
|
374
|
+
assert_css 'ul ul .admonitionblock.note', output, 0
|
375
|
+
assert_xpath '(//ul)[1]/li/*[@class="admonitionblock note"]', output, 1
|
376
|
+
assert_css 'ul ul hr', output, 0
|
377
|
+
assert_xpath '(//ul)[1]/li/hr', output, 1
|
378
|
+
end
|
379
|
+
|
380
|
+
test 'should continue to parse blocks attached by a list continuation after block is dropped' do
|
381
|
+
input = <<-EOS
|
382
|
+
* item
|
383
|
+
+
|
384
|
+
paragraph
|
385
|
+
+
|
386
|
+
[comment]
|
387
|
+
comment
|
388
|
+
+
|
389
|
+
====
|
390
|
+
example
|
391
|
+
====
|
392
|
+
'''
|
393
|
+
EOS
|
394
|
+
|
395
|
+
output = render_embedded_string input
|
396
|
+
assert_css 'ul > li > .paragraph', output, 1
|
397
|
+
assert_css 'ul > li > .exampleblock', output, 1
|
398
|
+
end
|
399
|
+
|
358
400
|
test 'appends line as paragraph if attached by continuation following line comment' do
|
359
401
|
input = <<-EOS
|
360
402
|
- list item 1
|
@@ -637,7 +679,7 @@ item
|
|
637
679
|
assert_css 'ul', output, 1
|
638
680
|
assert_css 'ul > li', output, 2
|
639
681
|
assert_css 'h2', output, 0
|
640
|
-
|
682
|
+
assert_includes output, '== Not a section'
|
641
683
|
assert_xpath %((//li)[2]/p[text() = "second\n== Not a section"]), output, 1
|
642
684
|
end
|
643
685
|
end
|
@@ -700,6 +742,26 @@ B. And it ends here.
|
|
700
742
|
assert_xpath '//ol', output, 1
|
701
743
|
assert_xpath '//ol/li', output, 2
|
702
744
|
end
|
745
|
+
|
746
|
+
test 'should discover anchor at start of list item text and register it as a reference' do
|
747
|
+
input = <<-EOS
|
748
|
+
The highest peak in the Front Range is <<grays-peak>>, which tops <<mount-evans>> by just a few feet.
|
749
|
+
|
750
|
+
* [[mount-evans,Mount Evans]]At 14,271 feet, Mount Evans is the highest summit of the Chicago Peaks in the Front Range of the Rocky Mountains.
|
751
|
+
* [[grays-peak,Grays Peak]]
|
752
|
+
Grays Peak rises to 14,278 feet, making it the highest summit in the Front Range of the Rocky Mountains.
|
753
|
+
* Longs Peak is a 14,259-foot high, prominent mountain summit in the northern Front Range of the Rocky Mountains.
|
754
|
+
* Pikes Peak is the highest summit of the southern Front Range of the Rocky Mountains at 14,115 feet.
|
755
|
+
EOS
|
756
|
+
|
757
|
+
doc = document_from_string input
|
758
|
+
refs = doc.catalog[:refs]
|
759
|
+
assert refs.key?('mount-evans')
|
760
|
+
assert refs.key?('grays-peak')
|
761
|
+
output = doc.convert :header_footer => false
|
762
|
+
assert_xpath '(//p)[1]/a[@href="#grays-peak"][text()="Grays Peak"]', output, 1
|
763
|
+
assert_xpath '(//p)[1]/a[@href="#mount-evans"][text()="Mount Evans"]', output, 1
|
764
|
+
end
|
703
765
|
end
|
704
766
|
|
705
767
|
context "Nested lists" do
|
@@ -1540,6 +1602,23 @@ Item one, paragraph two
|
|
1540
1602
|
end
|
1541
1603
|
=end
|
1542
1604
|
|
1605
|
+
test 'should warn if unterminated block is detected in list item' do
|
1606
|
+
input = <<-EOS
|
1607
|
+
* item
|
1608
|
+
+
|
1609
|
+
====
|
1610
|
+
example
|
1611
|
+
* swallowed item
|
1612
|
+
EOS
|
1613
|
+
|
1614
|
+
using_memory_logger do |logger|
|
1615
|
+
output = render_embedded_string input
|
1616
|
+
assert_xpath '//ul/li', output, 1
|
1617
|
+
assert_xpath '//ul/li/*[@class="exampleblock"]', output, 1
|
1618
|
+
assert_xpath %(//p[text()="example\n* swallowed item"]), output, 1
|
1619
|
+
assert_message logger, :WARN, '<stdin>: line 3: unterminated example block', Hash
|
1620
|
+
end
|
1621
|
+
end
|
1543
1622
|
end
|
1544
1623
|
end
|
1545
1624
|
|
@@ -1764,6 +1843,30 @@ List
|
|
1764
1843
|
assert_xpath '(//orderedlist)[@startingnumber = "7"]', output, 1
|
1765
1844
|
end
|
1766
1845
|
end
|
1846
|
+
|
1847
|
+
test 'should warn if explicit uppercase roman numerals in list are out of sequence' do
|
1848
|
+
input = <<-EOS
|
1849
|
+
I) one
|
1850
|
+
III) three
|
1851
|
+
EOS
|
1852
|
+
using_memory_logger do |logger|
|
1853
|
+
output = render_embedded_string input
|
1854
|
+
assert_xpath '//ol/li', output, 2
|
1855
|
+
assert_message logger, :WARN, '<stdin>: line 2: list item index: expected II, got III', Hash
|
1856
|
+
end
|
1857
|
+
end
|
1858
|
+
|
1859
|
+
test 'should warn if explicit lowercase roman numerals in list are out of sequence' do
|
1860
|
+
input = <<-EOS
|
1861
|
+
i) one
|
1862
|
+
iii) three
|
1863
|
+
EOS
|
1864
|
+
using_memory_logger do |logger|
|
1865
|
+
output = render_embedded_string input
|
1866
|
+
assert_xpath '//ol/li', output, 2
|
1867
|
+
assert_message logger, :WARN, '<stdin>: line 2: list item index: expected ii, got iii', Hash
|
1868
|
+
end
|
1869
|
+
end
|
1767
1870
|
end
|
1768
1871
|
|
1769
1872
|
context "Description lists (:dlist)" do
|
@@ -1783,6 +1886,21 @@ term2:: def2
|
|
1783
1886
|
assert_xpath '(//dl/dt)[2]/following-sibling::dd/p[text() = "def2"]', output, 1
|
1784
1887
|
end
|
1785
1888
|
|
1889
|
+
test 'should parse sibling items using same rules' do
|
1890
|
+
input = <<-EOS
|
1891
|
+
term1;; ;; def1
|
1892
|
+
term2;; ;; def2
|
1893
|
+
EOS
|
1894
|
+
output = render_string input
|
1895
|
+
assert_xpath '//dl', output, 1
|
1896
|
+
assert_xpath '//dl/dt', output, 2
|
1897
|
+
assert_xpath '//dl/dt/following-sibling::dd', output, 2
|
1898
|
+
assert_xpath '(//dl/dt)[1][normalize-space(text()) = "term1"]', output, 1
|
1899
|
+
assert_xpath '(//dl/dt)[1]/following-sibling::dd/p[text() = ";; def1"]', output, 1
|
1900
|
+
assert_xpath '(//dl/dt)[2][normalize-space(text()) = "term2"]', output, 1
|
1901
|
+
assert_xpath '(//dl/dt)[2]/following-sibling::dd/p[text() = ";; def2"]', output, 1
|
1902
|
+
end
|
1903
|
+
|
1786
1904
|
test "single-line indented adjacent elements" do
|
1787
1905
|
input = <<-EOS
|
1788
1906
|
term1:: def1
|
@@ -2046,16 +2164,24 @@ def2
|
|
2046
2164
|
assert_xpath '(//dl/dt)[2]/following-sibling::dd/p[text() = "def2"]', output, 1
|
2047
2165
|
end
|
2048
2166
|
|
2049
|
-
test
|
2167
|
+
test 'should discover anchor at start of description term text and register it as a reference' do
|
2050
2168
|
input = <<-EOS
|
2051
|
-
|
2052
|
-
|
2169
|
+
The highest peak in the Front Range is <<grays-peak>>, which tops <<mount-evans>> by just a few feet.
|
2170
|
+
|
2171
|
+
[[mount-evans,Mount Evans]]Mount Evans:: 14,271 feet
|
2172
|
+
[[grays-peak]]Grays Peak:: 14,278 feet
|
2053
2173
|
EOS
|
2054
|
-
|
2174
|
+
doc = document_from_string input
|
2175
|
+
refs = doc.catalog[:refs]
|
2176
|
+
assert refs.key?('mount-evans')
|
2177
|
+
assert refs.key?('grays-peak')
|
2178
|
+
output = doc.convert :header_footer => false
|
2179
|
+
assert_xpath '(//p)[1]/a[@href="#grays-peak"][text()="Grays Peak"]', output, 1
|
2180
|
+
assert_xpath '(//p)[1]/a[@href="#mount-evans"][text()="Mount Evans"]', output, 1
|
2055
2181
|
assert_xpath '//dl', output, 1
|
2056
2182
|
assert_xpath '//dl/dt', output, 2
|
2057
|
-
assert_xpath '(//dl/dt)[1]/a[@id
|
2058
|
-
assert_xpath '(//dl/dt)[2]/a[@id
|
2183
|
+
assert_xpath '(//dl/dt)[1]/a[@id="mount-evans"]', output, 1
|
2184
|
+
assert_xpath '(//dl/dt)[2]/a[@id="grays-peak"]', output, 1
|
2059
2185
|
end
|
2060
2186
|
|
2061
2187
|
test "missing space before term does not produce description list" do
|
@@ -2327,6 +2453,18 @@ A term::::: a description
|
|
2327
2453
|
assert_xpath '//dt[text()="A term:"]', output, 1
|
2328
2454
|
assert_xpath '//dd/p[text()="a description"]', output, 1
|
2329
2455
|
end
|
2456
|
+
|
2457
|
+
test 'text method of dd node should return nil if dd node only contains blocks' do
|
2458
|
+
input = <<-EOS
|
2459
|
+
term::
|
2460
|
+
+
|
2461
|
+
paragraph
|
2462
|
+
EOS
|
2463
|
+
|
2464
|
+
doc = document_from_string input
|
2465
|
+
dd = doc.blocks[0].items[0][1]
|
2466
|
+
assert_nil dd.text
|
2467
|
+
end
|
2330
2468
|
end
|
2331
2469
|
|
2332
2470
|
context "Nested lists" do
|
@@ -2774,6 +2912,23 @@ last question::
|
|
2774
2912
|
assert_css 'bibliodiv > bibliomixed:nth-child(2) > bibliomisc > anchor[xreflabel="[walsh-muellner]"]', output, 1
|
2775
2913
|
end
|
2776
2914
|
|
2915
|
+
test 'should warn if a bibliography ID is already in use' do
|
2916
|
+
input = <<-EOS
|
2917
|
+
[bibliography]
|
2918
|
+
* [[[Fowler]]] Fowler M. _Analysis Patterns: Reusable Object Models_.
|
2919
|
+
Addison-Wesley. 1997.
|
2920
|
+
* [[[Fowler]]] Fowler M. _Analysis Patterns: Reusable Object Models_.
|
2921
|
+
Addison-Wesley. 1997.
|
2922
|
+
EOS
|
2923
|
+
using_memory_logger do |logger|
|
2924
|
+
output = render_embedded_string input
|
2925
|
+
assert_css '.ulist.bibliography', output, 1
|
2926
|
+
assert_css '.ulist.bibliography ul li:nth-child(1) p a#Fowler', output, 1
|
2927
|
+
assert_css '.ulist.bibliography ul li:nth-child(2) p a#Fowler', output, 1
|
2928
|
+
assert_message logger, :WARN, '<stdin>: line 4: id assigned to bibliography anchor already in use: Fowler', Hash
|
2929
|
+
end
|
2930
|
+
end
|
2931
|
+
|
2777
2932
|
test 'should automatically add bibliography style to top-level lists in bibliography section' do
|
2778
2933
|
input = <<-EOS
|
2779
2934
|
[bibliography]
|
@@ -3448,7 +3603,7 @@ not a term::: def
|
|
3448
3603
|
assert_css '.dlist > dl > dt', output, 1
|
3449
3604
|
assert_css '.dlist > dl > dd', output, 1
|
3450
3605
|
assert_css '.dlist > dl > dd > .paragraph', output, 1
|
3451
|
-
|
3606
|
+
assert_includes output, 'not a term::: def'
|
3452
3607
|
end
|
3453
3608
|
|
3454
3609
|
# FIXME pending
|
@@ -3465,7 +3620,7 @@ not a term:: def
|
|
3465
3620
|
assert_css '.dlist > dl > dt', output, 1
|
3466
3621
|
assert_css '.dlist > dl > dd', output, 1
|
3467
3622
|
assert_css '.dlist > dl > dd > .paragraph', output, 1
|
3468
|
-
|
3623
|
+
assert_includes output, 'not a term:: def'
|
3469
3624
|
end
|
3470
3625
|
=end
|
3471
3626
|
|
@@ -3482,7 +3637,7 @@ not a term::: def
|
|
3482
3637
|
assert_css '.dlist > dl > dt', output, 1
|
3483
3638
|
assert_css '.dlist > dl > dd', output, 1
|
3484
3639
|
assert_css '.dlist > dl > dd > .quoteblock', output, 1
|
3485
|
-
|
3640
|
+
assert_includes output, 'not a term::: def'
|
3486
3641
|
end
|
3487
3642
|
|
3488
3643
|
test 'appends line as paragraph if attached by continuation following blank line and line comment when term has no inline description' do
|
@@ -3906,7 +4061,7 @@ context 'Callout lists' do
|
|
3906
4061
|
----
|
3907
4062
|
require 'asciidoctor' # <1>
|
3908
4063
|
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
3909
|
-
puts doc.
|
4064
|
+
puts doc.convert # <3>
|
3910
4065
|
----
|
3911
4066
|
<1> Describe the first line
|
3912
4067
|
<2> Describe the second line
|
@@ -3930,7 +4085,7 @@ puts doc.render # <3>
|
|
3930
4085
|
----
|
3931
4086
|
require 'asciidoctor' # <1>
|
3932
4087
|
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
3933
|
-
puts doc.
|
4088
|
+
puts doc.convert # <3>
|
3934
4089
|
----
|
3935
4090
|
|
3936
4091
|
Paragraph.
|
@@ -3958,7 +4113,7 @@ Paragraph.
|
|
3958
4113
|
----
|
3959
4114
|
require 'asciidoctor' # <1>
|
3960
4115
|
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
3961
|
-
puts doc.
|
4116
|
+
puts doc.convert # <2>
|
3962
4117
|
----
|
3963
4118
|
<1> Import the library
|
3964
4119
|
<2> Where the magic happens
|
@@ -3980,7 +4135,7 @@ puts doc.render # <2>
|
|
3980
4135
|
----
|
3981
4136
|
require 'asciidoctor' # <2>
|
3982
4137
|
doc = Asciidoctor::Document.new('Hello, World!') # <3>
|
3983
|
-
puts doc.
|
4138
|
+
puts doc.convert # <1>
|
3984
4139
|
----
|
3985
4140
|
<1> Describe the first line
|
3986
4141
|
<2> Describe the second line
|
@@ -4010,7 +4165,7 @@ require 'asciidoctor' # <1>
|
|
4010
4165
|
[source, ruby]
|
4011
4166
|
----
|
4012
4167
|
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
4013
|
-
puts doc.
|
4168
|
+
puts doc.convert # <3>
|
4014
4169
|
----
|
4015
4170
|
|
4016
4171
|
<1> Describe the first line
|
@@ -4042,7 +4197,7 @@ require 'asciidoctor' # <1>
|
|
4042
4197
|
[source, ruby]
|
4043
4198
|
----
|
4044
4199
|
doc = Asciidoctor::Document.new('Hello, World!') # <1>
|
4045
|
-
puts doc.
|
4200
|
+
puts doc.convert # <2>
|
4046
4201
|
----
|
4047
4202
|
<1> Describe the second line
|
4048
4203
|
<2> Describe the third line
|
@@ -4068,7 +4223,7 @@ puts doc.render # <2>
|
|
4068
4223
|
----
|
4069
4224
|
require 'asciidoctor' # <1>
|
4070
4225
|
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
4071
|
-
puts doc.
|
4226
|
+
puts doc.convert # <3>
|
4072
4227
|
----
|
4073
4228
|
<1> Imports the library
|
4074
4229
|
as a RubyGem
|
@@ -4093,7 +4248,7 @@ You can write this to file rather than printing to stdout.
|
|
4093
4248
|
----
|
4094
4249
|
require 'asciidoctor' # <1>
|
4095
4250
|
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
4096
|
-
puts doc.
|
4251
|
+
puts doc.convert # <3>
|
4097
4252
|
----
|
4098
4253
|
<1> Imports the library
|
4099
4254
|
as a RubyGem
|
@@ -4142,7 +4297,7 @@ puts "The syntax <1> at the end of the line makes a code callout"
|
|
4142
4297
|
----
|
4143
4298
|
require 'asciidoctor' <1>
|
4144
4299
|
doc = Asciidoctor.load('Hello, World!') # <2> <3> <4>
|
4145
|
-
puts doc.
|
4300
|
+
puts doc.convert <5><6>
|
4146
4301
|
exit 0
|
4147
4302
|
----
|
4148
4303
|
<1> Require library
|
@@ -4195,11 +4350,13 @@ foo::
|
|
4195
4350
|
|
4196
4351
|
<1> Not pointing to a callout
|
4197
4352
|
EOS
|
4198
|
-
|
4199
|
-
|
4200
|
-
|
4201
|
-
|
4202
|
-
|
4353
|
+
using_memory_logger do |logger|
|
4354
|
+
output = render_embedded_string input
|
4355
|
+
assert_xpath '//dl//b', output, 0
|
4356
|
+
assert_xpath '//dl/dd/p[text()="bar <1>"]', output, 1
|
4357
|
+
assert_xpath '//ol/li/p[text()="Not pointing to a callout"]', output, 1
|
4358
|
+
assert_message logger, :WARN, '<stdin>: line 4: no callout found for <1>', Hash
|
4359
|
+
end
|
4203
4360
|
end
|
4204
4361
|
|
4205
4362
|
test 'should not recognize callouts in an indented outline list paragraph' do
|
@@ -4209,11 +4366,13 @@ foo::
|
|
4209
4366
|
|
4210
4367
|
<1> Not pointing to a callout
|
4211
4368
|
EOS
|
4212
|
-
|
4213
|
-
|
4214
|
-
|
4215
|
-
|
4216
|
-
|
4369
|
+
using_memory_logger do |logger|
|
4370
|
+
output = render_embedded_string input
|
4371
|
+
assert_xpath '//ul//b', output, 0
|
4372
|
+
assert_xpath %(//ul/li/p[text()="foo\nbar <1>"]), output, 1
|
4373
|
+
assert_xpath '//ol/li/p[text()="Not pointing to a callout"]', output, 1
|
4374
|
+
assert_message logger, :WARN, '<stdin>: line 4: no callout found for <1>', Hash
|
4375
|
+
end
|
4217
4376
|
end
|
4218
4377
|
|
4219
4378
|
test 'should warn if numbers in callout list are out of sequence' do
|
@@ -4227,10 +4386,14 @@ foo::
|
|
4227
4386
|
Beans are fun.
|
4228
4387
|
<3> An actual bean.
|
4229
4388
|
EOS
|
4230
|
-
|
4231
|
-
|
4232
|
-
|
4233
|
-
|
4389
|
+
using_memory_logger do |logger|
|
4390
|
+
output = render_embedded_string input
|
4391
|
+
assert_xpath '//ol/li', output, 2
|
4392
|
+
assert_messages logger, [
|
4393
|
+
[:WARN, '<stdin>: line 8: callout list item index: expected 2, got 3', Hash],
|
4394
|
+
[:WARN, '<stdin>: line 8: no callout found for <2>', Hash]
|
4395
|
+
]
|
4396
|
+
end
|
4234
4397
|
end
|
4235
4398
|
|
4236
4399
|
test 'should remove line comment chars that precedes callout number' do
|
@@ -4312,7 +4475,7 @@ Violets are blue <2>
|
|
4312
4475
|
----
|
4313
4476
|
require 'asciidoctor' # <1>
|
4314
4477
|
doc = Asciidoctor::Document.new('Hello, World!') # <2>
|
4315
|
-
puts doc.
|
4478
|
+
puts doc.convert # <3>
|
4316
4479
|
----
|
4317
4480
|
<1> Describe the first line
|
4318
4481
|
<2> Describe the second line
|
@@ -4335,7 +4498,7 @@ puts doc.render # <3>
|
|
4335
4498
|
----
|
4336
4499
|
require 'asciidoctor' # <1>
|
4337
4500
|
doc = Asciidoctor::Document.new('Hello, World!') #<2>
|
4338
|
-
puts doc.
|
4501
|
+
puts doc.convert #<3>
|
4339
4502
|
----
|
4340
4503
|
<1> Describe the first line
|
4341
4504
|
<2> Describe the second line
|
@@ -4367,7 +4530,17 @@ context 'Checklists' do
|
|
4367
4530
|
- plain
|
4368
4531
|
EOS
|
4369
4532
|
|
4370
|
-
|
4533
|
+
doc = document_from_string input
|
4534
|
+
checklist = doc.blocks[0]
|
4535
|
+
assert checklist.option?('checklist')
|
4536
|
+
#assert_equal 'checklist', checklist.attributes['options']
|
4537
|
+
assert checklist.items[0].attr?('checkbox')
|
4538
|
+
refute checklist.items[0].attr?('checked')
|
4539
|
+
assert checklist.items[1].attr?('checkbox')
|
4540
|
+
assert checklist.items[1].attr?('checked')
|
4541
|
+
refute checklist.items[4].attr?('checkbox')
|
4542
|
+
|
4543
|
+
output = doc.convert :header_footer => false
|
4371
4544
|
assert_css '.ulist.checklist', output, 1
|
4372
4545
|
assert_xpath %((/*[@class="ulist checklist"]/ul/li)[1]/p[text()="#{decode_char 10063} todo"]), output, 1
|
4373
4546
|
assert_xpath %((/*[@class="ulist checklist"]/ul/li)[2]/p[text()="#{decode_char 10003} done"]), output, 1
|
@@ -4394,12 +4567,17 @@ context 'Checklists' do
|
|
4394
4567
|
input = <<-EOS
|
4395
4568
|
:icons: font
|
4396
4569
|
|
4397
|
-
[
|
4570
|
+
[%interactive]
|
4398
4571
|
- [ ] todo
|
4399
4572
|
- [x] done
|
4400
4573
|
EOS
|
4401
4574
|
|
4402
|
-
|
4575
|
+
doc = document_from_string input
|
4576
|
+
checklist = doc.blocks[0]
|
4577
|
+
assert checklist.option?('checklist')
|
4578
|
+
assert checklist.option?('interactive')
|
4579
|
+
|
4580
|
+
output = doc.convert :header_footer => false
|
4403
4581
|
assert_css '.ulist.checklist', output, 1
|
4404
4582
|
assert_css '.ulist.checklist li input[type="checkbox"]', output, 2
|
4405
4583
|
assert_css '.ulist.checklist li input[type="checkbox"][disabled]', output, 0
|
@@ -4417,7 +4595,7 @@ context 'Lists model' do
|
|
4417
4595
|
|
4418
4596
|
doc = document_from_string input
|
4419
4597
|
list = doc.blocks.first
|
4420
|
-
|
4598
|
+
assert_kind_of Asciidoctor::List, list
|
4421
4599
|
items = list.items
|
4422
4600
|
assert_equal 3, items.size
|
4423
4601
|
assert_equal list.items, list.content
|
@@ -4556,4 +4734,24 @@ listing block in list item 1
|
|
4556
4734
|
assert_equal '`three`', list.items[2].text
|
4557
4735
|
assert_equal '<mark>four</mark>', list.items[3].text
|
4558
4736
|
end
|
4737
|
+
|
4738
|
+
test 'should set lineno to line number in source where list starts' do
|
4739
|
+
input = <<-EOS
|
4740
|
+
* bullet 1
|
4741
|
+
** bullet 1.1
|
4742
|
+
*** bullet 1.1.1
|
4743
|
+
* bullet 2
|
4744
|
+
EOS
|
4745
|
+
doc = document_from_string input, :sourcemap => true
|
4746
|
+
lists = doc.find_by :context => :ulist
|
4747
|
+
assert_equal 1, lists[0].lineno
|
4748
|
+
assert_equal 2, lists[1].lineno
|
4749
|
+
assert_equal 3, lists[2].lineno
|
4750
|
+
|
4751
|
+
list_items = doc.find_by :context => :list_item
|
4752
|
+
assert_equal 1, list_items[0].lineno
|
4753
|
+
assert_equal 2, list_items[1].lineno
|
4754
|
+
assert_equal 3, list_items[2].lineno
|
4755
|
+
assert_equal 4, list_items[3].lineno
|
4756
|
+
end
|
4559
4757
|
end
|