asciidoctor 0.1.4 → 1.5.0
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 +209 -25
- data/{LICENSE → LICENSE.adoc} +4 -3
- data/README.adoc +392 -395
- data/Rakefile +94 -137
- data/benchmark/benchmark.rb +127 -0
- data/benchmark/sample-data/mdbasics.adoc +334 -0
- data/bin/asciidoctor +5 -8
- data/bin/asciidoctor-safe +4 -8
- data/compat/asciidoc.conf +78 -11
- data/compat/font-awesome-3-compat.css +397 -0
- data/data/stylesheets/asciidoctor-default.css +399 -0
- data/data/stylesheets/coderay-asciidoctor.css +89 -0
- data/features/open_block.feature +92 -0
- data/features/pass_block.feature +66 -0
- data/features/step_definitions.rb +42 -0
- data/features/text_formatting.feature +55 -0
- data/features/xref.feature +116 -0
- data/lib/asciidoctor.rb +1155 -605
- data/lib/asciidoctor/abstract_block.rb +157 -71
- data/lib/asciidoctor/abstract_node.rb +150 -93
- data/lib/asciidoctor/attribute_list.rb +85 -90
- data/lib/asciidoctor/block.rb +51 -24
- data/lib/asciidoctor/callouts.rb +4 -7
- data/lib/asciidoctor/cli.rb +3 -0
- data/lib/asciidoctor/cli/invoker.rb +86 -76
- data/lib/asciidoctor/cli/options.rb +111 -61
- data/lib/asciidoctor/converter.rb +232 -0
- data/lib/asciidoctor/converter/base.rb +58 -0
- data/lib/asciidoctor/converter/composite.rb +66 -0
- data/lib/asciidoctor/converter/docbook45.rb +94 -0
- data/lib/asciidoctor/converter/docbook5.rb +684 -0
- data/lib/asciidoctor/converter/factory.rb +225 -0
- data/lib/asciidoctor/converter/html5.rb +1081 -0
- data/lib/asciidoctor/converter/template.rb +296 -0
- data/lib/asciidoctor/core_ext.rb +7 -0
- data/lib/asciidoctor/core_ext/object/nil_or_empty.rb +23 -0
- data/lib/asciidoctor/core_ext/string/chr.rb +6 -0
- data/lib/asciidoctor/core_ext/symbol/length.rb +6 -0
- data/lib/asciidoctor/document.rb +590 -304
- data/lib/asciidoctor/extensions.rb +1100 -308
- data/lib/asciidoctor/helpers.rb +109 -46
- data/lib/asciidoctor/inline.rb +16 -9
- data/lib/asciidoctor/list.rb +23 -15
- data/lib/asciidoctor/opal_ext.rb +4 -0
- data/lib/asciidoctor/opal_ext/comparable.rb +38 -0
- data/lib/asciidoctor/opal_ext/dir.rb +13 -0
- data/lib/asciidoctor/opal_ext/error.rb +2 -0
- data/lib/asciidoctor/opal_ext/file.rb +125 -0
- data/lib/asciidoctor/{lexer.rb → parser.rb} +646 -455
- data/lib/asciidoctor/path_resolver.rb +141 -77
- data/lib/asciidoctor/reader.rb +257 -187
- data/lib/asciidoctor/section.rb +12 -16
- data/lib/asciidoctor/stylesheets.rb +91 -0
- data/lib/asciidoctor/substitutors.rb +1548 -0
- data/lib/asciidoctor/table.rb +73 -57
- data/lib/asciidoctor/timings.rb +39 -0
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +22 -14
- data/man/asciidoctor.adoc +18 -10
- data/test/attributes_test.rb +314 -14
- data/test/blocks_test.rb +763 -118
- data/test/converter_test.rb +352 -0
- data/test/document_test.rb +518 -199
- data/test/extensions_test.rb +273 -103
- data/test/fixtures/asciidoc_index.txt +27 -13
- data/test/fixtures/basic-docinfo.xml +1 -1
- data/test/fixtures/chapter-a.adoc +3 -0
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +6 -0
- data/test/fixtures/docinfo.xml +1 -1
- data/test/fixtures/include-file.asciidoc +2 -0
- data/test/fixtures/master.adoc +5 -0
- data/test/invoker_test.rb +173 -61
- data/test/links_test.rb +97 -21
- data/test/lists_test.rb +181 -22
- data/test/options_test.rb +86 -2
- data/test/paragraphs_test.rb +47 -5
- data/test/{lexer_test.rb → parser_test.rb} +128 -57
- data/test/paths_test.rb +36 -1
- data/test/preamble_test.rb +25 -17
- data/test/reader_test.rb +404 -249
- data/test/sections_test.rb +623 -58
- data/test/substitutions_test.rb +609 -132
- data/test/tables_test.rb +198 -24
- data/test/test_helper.rb +101 -31
- data/test/text_test.rb +88 -31
- metadata +160 -64
- data/Gemfile +0 -12
- data/Guardfile +0 -18
- data/asciidoctor.gemspec +0 -143
- data/lib/asciidoctor/backends/_stylesheets.rb +0 -466
- data/lib/asciidoctor/backends/base_template.rb +0 -114
- data/lib/asciidoctor/backends/docbook45.rb +0 -774
- data/lib/asciidoctor/backends/docbook5.rb +0 -103
- data/lib/asciidoctor/backends/html5.rb +0 -1214
- data/lib/asciidoctor/renderer.rb +0 -259
- data/lib/asciidoctor/substituters.rb +0 -1083
- data/test/fixtures/asciidoc.txt +0 -105
- data/test/fixtures/ascshort.txt +0 -32
- data/test/fixtures/list_elements.asciidoc +0 -10
- data/test/renderer_test.rb +0 -162
data/test/links_test.rb
CHANGED
@@ -1,9 +1,25 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
unless defined? ASCIIDOCTOR_PROJECT_DIR
|
3
|
+
$: << File.dirname(__FILE__); $:.uniq!
|
4
|
+
require 'test_helper'
|
5
|
+
end
|
2
6
|
|
3
7
|
context 'Links' do
|
4
8
|
|
5
9
|
test 'qualified url inline with text' do
|
6
|
-
assert_xpath "//a[@href='http://asciidoc.org'][text() = 'http://asciidoc.org']", render_string("The AsciiDoc project is located at http://asciidoc.org.")
|
10
|
+
assert_xpath "//a[@href='http://asciidoc.org'][@class='bare'][text() = 'http://asciidoc.org']", render_string("The AsciiDoc project is located at http://asciidoc.org.")
|
11
|
+
end
|
12
|
+
|
13
|
+
test 'qualified http url inline with hide-uri-scheme set' do
|
14
|
+
assert_xpath "//a[@href='http://asciidoc.org'][@class='bare'][text() = 'asciidoc.org']", render_string("The AsciiDoc project is located at http://asciidoc.org.", :attributes => {'hide-uri-scheme' => ''})
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'qualified file url inline with label' do
|
18
|
+
assert_xpath "//a[@href='file:///home/user/bookmarks.html'][text() = 'My Bookmarks']", render_embedded_string('file:///home/user/bookmarks.html[My Bookmarks]')
|
19
|
+
end
|
20
|
+
|
21
|
+
test 'qualified file url inline with hide-uri-scheme set' do
|
22
|
+
assert_xpath "//a[@href='file:///etc/app.conf'][text() = '/etc/app.conf']", render_string('Edit the configuration file link:file:///etc/app.conf[]', :attributes => {'hide-uri-scheme' => ''})
|
7
23
|
end
|
8
24
|
|
9
25
|
test 'qualified url with label' do
|
@@ -30,6 +46,22 @@ context 'Links' do
|
|
30
46
|
assert_xpath '//a[@href="http://asciidoc.org"][text()="http://asciidoc.org"]', render_string('(http://asciidoc.org) is the project page for AsciiDoc.'), 1
|
31
47
|
end
|
32
48
|
|
49
|
+
test 'qualified url with trailing round bracket' do
|
50
|
+
assert_xpath '//a[@href="http://asciidoctor.org"][text()="http://asciidoctor.org"]', render_string('Asciidoctor is a Ruby-based AsciiDoc processor (see http://asciidoctor.org)'), 1
|
51
|
+
end
|
52
|
+
|
53
|
+
test 'qualified url with trailing semi-colon' do
|
54
|
+
assert_xpath '//a[@href="http://asciidoctor.org"][text()="http://asciidoctor.org"]', render_string('http://asciidoctor.org; where text gets parsed'), 1
|
55
|
+
end
|
56
|
+
|
57
|
+
test 'qualified url with trailing colon' do
|
58
|
+
assert_xpath '//a[@href="http://asciidoctor.org"][text()="http://asciidoctor.org"]', render_string('http://asciidoctor.org: where text gets parsed'), 1
|
59
|
+
end
|
60
|
+
|
61
|
+
test 'qualified url in round brackets with trailing colon' do
|
62
|
+
assert_xpath '//a[@href="http://asciidoctor.org"][text()="http://asciidoctor.org"]', render_string('(http://asciidoctor.org): where text gets parsed'), 1
|
63
|
+
end
|
64
|
+
|
33
65
|
test 'qualified url containing round brackets' do
|
34
66
|
assert_xpath '//a[@href="http://jruby.org/apidocs/org/jruby/Ruby.html#addModule(org.jruby.RubyModule)"][text()="addModule() adds a Ruby module"]', render_string('http://jruby.org/apidocs/org/jruby/Ruby.html#addModule(org.jruby.RubyModule)[addModule() adds a Ruby module]'), 1
|
35
67
|
end
|
@@ -42,6 +74,11 @@ context 'Links' do
|
|
42
74
|
assert_xpath '//a[@href="http://asciidoc.org"][text()="AsciiDoc"]', render_string(')http://asciidoc.org[AsciiDoc] project page.'), 1
|
43
75
|
end
|
44
76
|
|
77
|
+
test 'qualified url following smart apostrophe' do
|
78
|
+
output = render_embedded_string("l’http://www.irit.fr[IRIT]")
|
79
|
+
assert_match(/l’<a href=/, output)
|
80
|
+
end
|
81
|
+
|
45
82
|
test 'qualified url using invalid link macro should not create link' do
|
46
83
|
assert_xpath '//a', render_string('link:http://asciidoc.org is the project page for AsciiDoc.'), 0
|
47
84
|
end
|
@@ -50,6 +87,14 @@ context 'Links' do
|
|
50
87
|
assert_xpath '//a', render_string('\http://asciidoc.org is the project page for AsciiDoc.'), 0
|
51
88
|
end
|
52
89
|
|
90
|
+
test 'url in link macro with at (@) sign should not create mailto link' do
|
91
|
+
assert_xpath '//a[@href="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"][text()="subscribe"]', render_string('http://xircles.codehaus.org/lists/dev@geb.codehaus.org[subscribe]')
|
92
|
+
end
|
93
|
+
|
94
|
+
test 'implicit url with at (@) sign should not create mailto link' do
|
95
|
+
assert_xpath '//a[@href="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"][text()="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"]', render_string('http://xircles.codehaus.org/lists/dev@geb.codehaus.org')
|
96
|
+
end
|
97
|
+
|
53
98
|
test 'escaped inline qualified url using macro syntax should not create link' do
|
54
99
|
assert_xpath '//a', render_string('\http://asciidoc.org[AsciiDoc] is the key to good docs.'), 0
|
55
100
|
end
|
@@ -75,7 +120,11 @@ context 'Links' do
|
|
75
120
|
end
|
76
121
|
|
77
122
|
test 'link with quoted text should not be separated into attributes when linkattrs is set' do
|
78
|
-
assert_xpath '//a[@href="http://search.example.com"][text()="Google, Yahoo, Bing"]', render_embedded_string('http://search.example.com["Google, Yahoo, Bing"]', :attributes => {'linkattrs' => ''}), 1
|
123
|
+
assert_xpath '//a[@href="http://search.example.com"][text()="Google, Yahoo, Bing = Search Engines"]', render_embedded_string('http://search.example.com["Google, Yahoo, Bing = Search Engines"]', :attributes => {'linkattrs' => ''}), 1
|
124
|
+
end
|
125
|
+
|
126
|
+
test 'link with comma in text but no equal sign should not be separated into attributes when linkattrs is set' do
|
127
|
+
assert_xpath '//a[@href="http://search.example.com"][text()="Google, Yahoo, Bing"]', render_embedded_string('http://search.example.com[Google, Yahoo, Bing]', :attributes => {'linkattrs' => ''}), 1
|
79
128
|
end
|
80
129
|
|
81
130
|
test 'role and window attributes on link are processed when linkattrs is set' do
|
@@ -86,6 +135,14 @@ context 'Links' do
|
|
86
135
|
assert_xpath '//a[@href="http://google.com"][@target="_blank"]', render_embedded_string('http://google.com[Google^]'), 1
|
87
136
|
end
|
88
137
|
|
138
|
+
test 'id attribute on link are processed when linkattrs is set' do
|
139
|
+
assert_xpath '//a[@href="http://google.com"][@id="link-1"]', render_embedded_string('http://google.com[Google, id="link-1"]', :attributes => {'linkattrs' => ''}), 1
|
140
|
+
end
|
141
|
+
|
142
|
+
test 'title attribute on link are processed when linkattrs is set' do
|
143
|
+
assert_xpath '//a[@href="http://google.com"][@title="title-1"]', render_embedded_string('http://google.com[Google, title="title-1"]', :attributes => {'linkattrs' => ''}), 1
|
144
|
+
end
|
145
|
+
|
89
146
|
test 'inline irc link' do
|
90
147
|
assert_xpath '//a[@href="irc://irc.freenode.net"][text()="irc://irc.freenode.net"]', render_embedded_string('irc://irc.freenode.net'), 1
|
91
148
|
end
|
@@ -95,26 +152,35 @@ context 'Links' do
|
|
95
152
|
end
|
96
153
|
|
97
154
|
test 'inline ref' do
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
155
|
+
variations = %w([[tigers]] anchor:tigers[])
|
156
|
+
variations.each do |anchor|
|
157
|
+
doc = document_from_string %(Here you can read about tigers.#{anchor})
|
158
|
+
output = doc.render
|
159
|
+
assert_equal '[tigers]', doc.references[:ids]['tigers']
|
160
|
+
assert_xpath '//a[@id = "tigers"]', output, 1
|
161
|
+
assert_xpath '//a[@id = "tigers"]/child::text()', output, 0
|
162
|
+
end
|
103
163
|
end
|
104
164
|
|
105
165
|
test 'inline ref with reftext' do
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
166
|
+
variations = %w([[tigers,Tigers]] anchor:tigers[Tigers])
|
167
|
+
variations.each do |anchor|
|
168
|
+
doc = document_from_string %(Here you can read about tigers.#{anchor})
|
169
|
+
output = doc.render
|
170
|
+
assert_equal 'Tigers', doc.references[:ids]['tigers']
|
171
|
+
assert_xpath '//a[@id = "tigers"]', output, 1
|
172
|
+
assert_xpath '//a[@id = "tigers"]/child::text()', output, 0
|
173
|
+
end
|
111
174
|
end
|
112
175
|
|
113
176
|
test 'escaped inline ref' do
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
177
|
+
variations = %w([[tigers]] anchor:tigers[])
|
178
|
+
variations.each do |anchor|
|
179
|
+
doc = document_from_string %(Here you can read about tigers.\\#{anchor})
|
180
|
+
output = doc.render
|
181
|
+
assert !doc.references[:ids].has_key?('tigers')
|
182
|
+
assert_xpath '//a[@id = "tigers"]', output, 0
|
183
|
+
end
|
118
184
|
end
|
119
185
|
|
120
186
|
test 'xref using angled bracket syntax' do
|
@@ -151,6 +217,12 @@ context 'Links' do
|
|
151
217
|
assert_xpath '//a[@href="tigers.html#about"][text() = "About Tigers"]', doc.render, 1
|
152
218
|
end
|
153
219
|
|
220
|
+
test 'xref using angled bracket syntax with path and custom relfilesuffix and outfilesuffix' do
|
221
|
+
attributes = {'relfileprefix' => '../', 'outfilesuffix' => '/'}
|
222
|
+
doc = document_from_string '<<tigers#about,About Tigers>>', :header_footer => false, :attributes => attributes
|
223
|
+
assert_xpath '//a[@href="../tigers/#about"][text() = "About Tigers"]', doc.render, 1
|
224
|
+
end
|
225
|
+
|
154
226
|
test 'xref using angled bracket syntax with path which has been included in this document' do
|
155
227
|
doc = document_from_string '<<tigers#about,About Tigers>>', :header_footer => false
|
156
228
|
doc.references[:includes] << 'tigers'
|
@@ -173,7 +245,7 @@ context 'Links' do
|
|
173
245
|
|
174
246
|
test 'xref with escaped text' do
|
175
247
|
# when \x0 was used as boundary character for passthrough, it was getting stripped
|
176
|
-
# now using
|
248
|
+
# now using unicode marks as boundary characters, which resolves issue
|
177
249
|
input = 'See the <<tigers , `[tigers]`>> section for data about tigers'
|
178
250
|
output = render_embedded_string input
|
179
251
|
assert_xpath %(//a[@href="#tigers"]/code[text()="[tigers]"]), output, 1
|
@@ -236,9 +308,13 @@ context 'Links' do
|
|
236
308
|
assert_equal({'tigers' => 'Tigers'}, doc.references[:ids])
|
237
309
|
end
|
238
310
|
|
239
|
-
test 'anchor with quoted label creates reference' do
|
240
|
-
doc = document_from_string %([[
|
241
|
-
assert_equal({'tigers' => "Tigers roam here"}, doc.references[:ids])
|
311
|
+
test 'anchor with quoted label creates reference with quoted label text' do
|
312
|
+
doc = document_from_string %([[tigers,"Tigers roam here"]]Tigers roam here.)
|
313
|
+
assert_equal({'tigers' => '"Tigers roam here"'}, doc.references[:ids])
|
242
314
|
end
|
243
315
|
|
316
|
+
test 'anchor with label containing a comma creates reference' do
|
317
|
+
doc = document_from_string %([[tigers,Tigers, scary tigers, roam here]]Tigers roam here.)
|
318
|
+
assert_equal({'tigers' => 'Tigers, scary tigers, roam here'}, doc.references[:ids])
|
319
|
+
end
|
244
320
|
end
|
data/test/lists_test.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
unless defined? ASCIIDOCTOR_PROJECT_DIR
|
3
|
+
$: << File.dirname(__FILE__); $:.uniq!
|
4
|
+
require 'test_helper'
|
5
|
+
end
|
2
6
|
|
3
7
|
context "Bulleted lists (:ulist)" do
|
4
8
|
context "Simple lists" do
|
@@ -622,7 +626,7 @@ List
|
|
622
626
|
====
|
623
627
|
|
624
628
|
- I am *strong*.
|
625
|
-
- I am
|
629
|
+
- I am _stressed_.
|
626
630
|
- I am `flexible`.
|
627
631
|
EOS
|
628
632
|
output = render_string input
|
@@ -639,7 +643,7 @@ List
|
|
639
643
|
====
|
640
644
|
:foo: bar
|
641
645
|
|
642
|
-
- side a {
|
646
|
+
- side a {vbar} side b
|
643
647
|
- Take me to a {foo}.
|
644
648
|
EOS
|
645
649
|
output = render_string input
|
@@ -944,7 +948,8 @@ List
|
|
944
948
|
literal
|
945
949
|
....
|
946
950
|
EOS
|
947
|
-
|
951
|
+
# use render_string so we can match all ulists easier
|
952
|
+
output = render_string input
|
948
953
|
assert_xpath '//*[@class="ulist"]/ul', output, 2
|
949
954
|
assert_xpath '(//*[@class="ulist"])[1]/following-sibling::*[@class="literalblock"]', output, 1
|
950
955
|
assert_xpath '(//*[@class="ulist"])[1]/following-sibling::*[@class="literalblock"]/*[@class="title"]', output, 1
|
@@ -1028,7 +1033,7 @@ Item one, literal block
|
|
1028
1033
|
assert_xpath '(//ul/li[1]/p/following-sibling::*)[1][@class = "literalblock"]', output, 1
|
1029
1034
|
end
|
1030
1035
|
|
1031
|
-
test
|
1036
|
+
test 'adjacent list continuation line attaches following block with block attributes' do
|
1032
1037
|
input = <<-EOS
|
1033
1038
|
Lists
|
1034
1039
|
=====
|
@@ -1051,7 +1056,7 @@ Lists
|
|
1051
1056
|
assert_xpath '//ul/li[1]/p', output, 1
|
1052
1057
|
assert_xpath '(//ul/li[1]/p/following-sibling::*)[1][@id="beck"][@class = "listingblock"]', output, 1
|
1053
1058
|
assert_xpath '(//ul/li[1]/p/following-sibling::*)[1][@id="beck"]/div[@class="title"][starts-with(text(),"Read")]', output, 1
|
1054
|
-
assert_xpath '(//ul/li[1]/p/following-sibling::*)[1][@id="beck"]//code[@
|
1059
|
+
assert_xpath '(//ul/li[1]/p/following-sibling::*)[1][@id="beck"]//code[@data-lang="ruby"][starts-with(text(),"5.times")]', output, 1
|
1055
1060
|
end
|
1056
1061
|
|
1057
1062
|
test 'trailing block attribute line attached by continuation should not create block' do
|
@@ -1399,6 +1404,71 @@ bullet 1 paragraph
|
|
1399
1404
|
assert_xpath '(((//ul)[1]/li)[1]/div[@class="ulist"]/ul/li/div[@class="ulist"]/ul/li/*)[2]/self::div[@class="openblock"]', output, 1
|
1400
1405
|
end
|
1401
1406
|
|
1407
|
+
test 'indented outline list item with different marker offset by a blank line should be recognized as a nested list' do
|
1408
|
+
input = <<-EOS
|
1409
|
+
* item 1
|
1410
|
+
|
1411
|
+
. item 1.1
|
1412
|
+
+
|
1413
|
+
attached paragraph
|
1414
|
+
|
1415
|
+
. item 1.2
|
1416
|
+
+
|
1417
|
+
attached paragraph
|
1418
|
+
|
1419
|
+
* item 2
|
1420
|
+
EOS
|
1421
|
+
|
1422
|
+
output = render_embedded_string input
|
1423
|
+
|
1424
|
+
assert_css 'ul', output, 1
|
1425
|
+
assert_css 'ol', output, 1
|
1426
|
+
assert_css 'ul ol', output, 1
|
1427
|
+
assert_css 'ul > li', output, 2
|
1428
|
+
assert_xpath '((//ul/li)[1]/*)', output, 2
|
1429
|
+
assert_xpath '((//ul/li)[1]/*)[1]/self::p', output, 1
|
1430
|
+
assert_xpath '((//ul/li)[1]/*)[2]/self::div/ol', output, 1
|
1431
|
+
assert_xpath '((//ul/li)[1]/*)[2]/self::div/ol/li', output, 2
|
1432
|
+
(1..2).each do |idx|
|
1433
|
+
assert_xpath "(((//ul/li)[1]/*)[2]/self::div/ol/li)[#{idx}]/*", output, 2
|
1434
|
+
assert_xpath "((((//ul/li)[1]/*)[2]/self::div/ol/li)[#{idx}]/*)[1]/self::p", output, 1
|
1435
|
+
assert_xpath "((((//ul/li)[1]/*)[2]/self::div/ol/li)[#{idx}]/*)[2]/self::div[@class=\"paragraph\"]", output, 1
|
1436
|
+
end
|
1437
|
+
end
|
1438
|
+
|
1439
|
+
test 'indented labeled list item inside outline list item offset by a blank line should be recognized as a nested list' do
|
1440
|
+
input = <<-EOS
|
1441
|
+
* item 1
|
1442
|
+
|
1443
|
+
term a:: definition a
|
1444
|
+
+
|
1445
|
+
attached paragraph
|
1446
|
+
|
1447
|
+
term b:: definition b
|
1448
|
+
+
|
1449
|
+
attached paragraph
|
1450
|
+
|
1451
|
+
* item 2
|
1452
|
+
EOS
|
1453
|
+
|
1454
|
+
output = render_embedded_string input
|
1455
|
+
|
1456
|
+
assert_css 'ul', output, 1
|
1457
|
+
assert_css 'dl', output, 1
|
1458
|
+
assert_css 'ul dl', output, 1
|
1459
|
+
assert_css 'ul > li', output, 2
|
1460
|
+
assert_xpath '((//ul/li)[1]/*)', output, 2
|
1461
|
+
assert_xpath '((//ul/li)[1]/*)[1]/self::p', output, 1
|
1462
|
+
assert_xpath '((//ul/li)[1]/*)[2]/self::div/dl', output, 1
|
1463
|
+
assert_xpath '((//ul/li)[1]/*)[2]/self::div/dl/dt', output, 2
|
1464
|
+
assert_xpath '((//ul/li)[1]/*)[2]/self::div/dl/dd', output, 2
|
1465
|
+
(1..2).each do |idx|
|
1466
|
+
assert_xpath "(((//ul/li)[1]/*)[2]/self::div/dl/dd)[#{idx}]/*", output, 2
|
1467
|
+
assert_xpath "((((//ul/li)[1]/*)[2]/self::div/dl/dd)[#{idx}]/*)[1]/self::p", output, 1
|
1468
|
+
assert_xpath "((((//ul/li)[1]/*)[2]/self::div/dl/dd)[#{idx}]/*)[2]/self::div[@class=\"paragraph\"]", output, 1
|
1469
|
+
end
|
1470
|
+
end
|
1471
|
+
|
1402
1472
|
# NOTE this is not consistent w/ AsciiDoc output, but this is some screwy input anyway
|
1403
1473
|
=begin
|
1404
1474
|
test "consecutive list continuation lines are folded" do
|
@@ -1606,10 +1676,40 @@ List
|
|
1606
1676
|
assert_xpath '(//ol)[1]/li', output, 2
|
1607
1677
|
assert_xpath '(//ol)[2]/li', output, 1
|
1608
1678
|
end
|
1679
|
+
|
1680
|
+
test 'should use start number in docbook4.5 backend' do
|
1681
|
+
input = <<-EOS
|
1682
|
+
== List
|
1683
|
+
|
1684
|
+
[start=7]
|
1685
|
+
. item 7
|
1686
|
+
. item 8
|
1687
|
+
EOS
|
1688
|
+
|
1689
|
+
output = render_embedded_string input, :backend => 'docbook45'
|
1690
|
+
assert_xpath '//orderedlist', output, 1
|
1691
|
+
assert_xpath '(//orderedlist)/listitem', output, 2
|
1692
|
+
assert_xpath '(//orderedlist/listitem)[1][@override = "7"]', output, 1
|
1693
|
+
end
|
1694
|
+
|
1695
|
+
test 'should use start number in docbook5 backend' do
|
1696
|
+
input = <<-EOS
|
1697
|
+
== List
|
1698
|
+
|
1699
|
+
[start=7]
|
1700
|
+
. item 7
|
1701
|
+
. item 8
|
1702
|
+
EOS
|
1703
|
+
|
1704
|
+
output = render_embedded_string input, :backend => 'docbook5'
|
1705
|
+
assert_xpath '//orderedlist', output, 1
|
1706
|
+
assert_xpath '(//orderedlist)/listitem', output, 2
|
1707
|
+
assert_xpath '(//orderedlist)[@startingnumber = "7"]', output, 1
|
1708
|
+
end
|
1609
1709
|
end
|
1610
1710
|
end
|
1611
1711
|
|
1612
|
-
context "
|
1712
|
+
context "Description lists (:dlist)" do
|
1613
1713
|
context "Simple lists" do
|
1614
1714
|
test "single-line adjacent elements" do
|
1615
1715
|
input = <<-EOS
|
@@ -2382,8 +2482,23 @@ term:: def
|
|
2382
2482
|
assert_css 'table', output, 1
|
2383
2483
|
assert_css 'table > colgroup', output, 1
|
2384
2484
|
assert_css 'table > colgroup > col', output, 2
|
2385
|
-
assert_xpath '(//table/colgroup/col)[1][@style="width:25%;"]', output, 1
|
2386
|
-
assert_xpath '(//table/colgroup/col)[2][@style="width:75%;"]', output, 1
|
2485
|
+
assert_xpath '(//table/colgroup/col)[1][@style="width: 25%;"]', output, 1
|
2486
|
+
assert_xpath '(//table/colgroup/col)[2][@style="width: 75%;"]', output, 1
|
2487
|
+
end
|
2488
|
+
|
2489
|
+
test 'should set col widths of item and label in docbook if specified' do
|
2490
|
+
input = <<-EOS
|
2491
|
+
[horizontal]
|
2492
|
+
[labelwidth="25", itemwidth="75"]
|
2493
|
+
term:: def
|
2494
|
+
EOS
|
2495
|
+
|
2496
|
+
output = render_embedded_string input, :backend => 'docbook'
|
2497
|
+
assert_css 'informaltable', output, 1
|
2498
|
+
assert_css 'informaltable > tgroup', output, 1
|
2499
|
+
assert_css 'informaltable > tgroup > colspec', output, 2
|
2500
|
+
assert_xpath '(/informaltable/tgroup/colspec)[1][@colwidth="25*"]', output, 1
|
2501
|
+
assert_xpath '(/informaltable/tgroup/colspec)[2][@colwidth="75*"]', output, 1
|
2387
2502
|
end
|
2388
2503
|
|
2389
2504
|
test 'should add strong class to label if strong option is set' do
|
@@ -2459,6 +2574,8 @@ Question 1::
|
|
2459
2574
|
Answer 1.
|
2460
2575
|
Question 2::
|
2461
2576
|
Answer 2.
|
2577
|
+
+
|
2578
|
+
NOTE: A note about Answer 2.
|
2462
2579
|
EOS
|
2463
2580
|
output = render_embedded_string input
|
2464
2581
|
assert_css '.qlist.qanda', output, 1
|
@@ -2471,6 +2588,7 @@ Question 2::
|
|
2471
2588
|
assert_css ".qanda > ol > li:nth-child(#{idx}) > p:last-child > *", output, 0
|
2472
2589
|
assert_xpath "/*[@class = 'qlist qanda']/ol/li[#{idx}]/p[2][normalize-space(text()) = 'Answer #{idx}.']", output, 1
|
2473
2590
|
end
|
2591
|
+
assert_xpath "/*[@class = 'qlist qanda']/ol/li[2]/p[2]/following-sibling::div[@class='admonitionblock note']", output, 1
|
2474
2592
|
end
|
2475
2593
|
|
2476
2594
|
test 'should render qanda list in DocBook with proper semantics' do
|
@@ -2480,6 +2598,8 @@ Question 1::
|
|
2480
2598
|
Answer 1.
|
2481
2599
|
Question 2::
|
2482
2600
|
Answer 2.
|
2601
|
+
+
|
2602
|
+
NOTE: A note about Answer 2.
|
2483
2603
|
EOS
|
2484
2604
|
output = render_embedded_string input, :backend => 'docbook'
|
2485
2605
|
assert_css 'qandaset', output, 1
|
@@ -2492,6 +2612,7 @@ Question 2::
|
|
2492
2612
|
assert_css "qandaset > qandaentry:nth-child(#{idx}) > answer > simpara", output, 1
|
2493
2613
|
assert_xpath "/qandaset/qandaentry[#{idx}]/answer/simpara[normalize-space(text()) = 'Answer #{idx}.']", output, 1
|
2494
2614
|
end
|
2615
|
+
assert_xpath "/qandaset/qandaentry[2]/answer/simpara/following-sibling::note", output, 1
|
2495
2616
|
end
|
2496
2617
|
|
2497
2618
|
test 'consecutive questions should share same question element in docbook' do
|
@@ -2531,10 +2652,29 @@ last question::
|
|
2531
2652
|
text = xmlnodes_at_xpath '(//a)[1]/following-sibling::text()', output, 1
|
2532
2653
|
assert text.text.start_with?('[taoup] ')
|
2533
2654
|
end
|
2655
|
+
|
2656
|
+
test 'should render bibliography list with proper semantics to DocBook' do
|
2657
|
+
input = <<-EOS
|
2658
|
+
[bibliography]
|
2659
|
+
- [[[taoup]]] Eric Steven Raymond. 'The Art of Unix
|
2660
|
+
Programming'. Addison-Wesley. ISBN 0-13-142901-9.
|
2661
|
+
- [[[walsh-muellner]]] Norman Walsh & Leonard Muellner.
|
2662
|
+
'DocBook - The Definitive Guide'. O'Reilly & Associates. 1999.
|
2663
|
+
ISBN 1-56592-580-7.
|
2664
|
+
EOS
|
2665
|
+
output = render_embedded_string input, :backend => 'docbook'
|
2666
|
+
assert_css 'bibliodiv', output, 1
|
2667
|
+
assert_css 'bibliodiv > bibliomixed', output, 2
|
2668
|
+
assert_css 'bibliodiv > bibliomixed > bibliomisc', output, 2
|
2669
|
+
assert_css 'bibliodiv > bibliomixed:nth-child(1) > bibliomisc > anchor', output, 1
|
2670
|
+
assert_css 'bibliodiv > bibliomixed:nth-child(1) > bibliomisc > anchor[xreflabel="[taoup]"]', output, 1
|
2671
|
+
assert_css 'bibliodiv > bibliomixed:nth-child(2) > bibliomisc > anchor', output, 1
|
2672
|
+
assert_css 'bibliodiv > bibliomixed:nth-child(2) > bibliomisc > anchor[xreflabel="[walsh-muellner]"]', output, 1
|
2673
|
+
end
|
2534
2674
|
end
|
2535
2675
|
end
|
2536
2676
|
|
2537
|
-
context '
|
2677
|
+
context 'Description lists redux' do
|
2538
2678
|
|
2539
2679
|
context 'Label without text on same line' do
|
2540
2680
|
|
@@ -2674,7 +2814,7 @@ term1::
|
|
2674
2814
|
output = render_embedded_string input
|
2675
2815
|
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2676
2816
|
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2677
|
-
assert_xpath %(//*[@class="dlist"]//dd/p
|
2817
|
+
assert_xpath %(//*[@class="dlist"]//dd/p[text()="'''"]), output, 1
|
2678
2818
|
end
|
2679
2819
|
|
2680
2820
|
test 'folds text that looks like ruler offset by blank line and line comment' do
|
@@ -2690,7 +2830,7 @@ term1::
|
|
2690
2830
|
output = render_embedded_string input
|
2691
2831
|
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2692
2832
|
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2693
|
-
assert_xpath %(//*[@class="dlist"]//dd/p
|
2833
|
+
assert_xpath %(//*[@class="dlist"]//dd/p[text()="'''"]), output, 1
|
2694
2834
|
end
|
2695
2835
|
|
2696
2836
|
test 'folds text that looks like ruler and the line following it offset by blank line' do
|
@@ -2706,8 +2846,7 @@ continued
|
|
2706
2846
|
output = render_embedded_string input
|
2707
2847
|
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2708
2848
|
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2709
|
-
assert_xpath %(//*[@class="dlist"]//dd/p
|
2710
|
-
assert_xpath %(//*[@class="dlist"]//dd/p[normalize-space(text())="continued"]), output, 1
|
2849
|
+
assert_xpath %(//*[@class="dlist"]//dd/p[normalize-space(text())="''' continued"]), output, 1
|
2711
2850
|
end
|
2712
2851
|
|
2713
2852
|
test 'folds text that looks like title offset by blank line' do
|
@@ -2755,6 +2894,22 @@ NOTE: def1
|
|
2755
2894
|
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2756
2895
|
assert_xpath '//*[@class="dlist"]//dd/p[text()="NOTE: def1"]', output, 1
|
2757
2896
|
end
|
2897
|
+
|
2898
|
+
test 'folds text that looks like section title offset by blank line' do
|
2899
|
+
input = <<-EOS
|
2900
|
+
== Lists
|
2901
|
+
|
2902
|
+
term1::
|
2903
|
+
|
2904
|
+
== Another Section
|
2905
|
+
EOS
|
2906
|
+
|
2907
|
+
output = render_embedded_string input
|
2908
|
+
assert_xpath '//*[@class="dlist"]/dl', output, 1
|
2909
|
+
assert_xpath '//*[@class="dlist"]//dd', output, 1
|
2910
|
+
assert_xpath '//*[@class="dlist"]//dd/p[text()="== Another Section"]', output, 1
|
2911
|
+
assert_xpath '//h2', output, 1
|
2912
|
+
end
|
2758
2913
|
|
2759
2914
|
test 'folds text of first literal line offset by blank line appends subsequent literals offset by blank line as blocks' do
|
2760
2915
|
input = <<-EOS
|
@@ -3775,9 +3930,9 @@ exit 0
|
|
3775
3930
|
EOS
|
3776
3931
|
output = render_embedded_string input
|
3777
3932
|
assert_xpath '//code/b', output, 6
|
3778
|
-
assert_match(/ <b>\(1\)<\/b>$/, output)
|
3779
|
-
assert_match(/ <b>\(2\)<\/b> <b>\(3\)<\/b> <b>\(4\)<\/b>$/, output)
|
3780
|
-
assert_match(/ <b>\(5\)<\/b><b>\(6\)<\/b>$/, output)
|
3933
|
+
assert_match(/ <b class="conum">\(1\)<\/b>$/, output)
|
3934
|
+
assert_match(/ <b class="conum">\(2\)<\/b> <b class="conum">\(3\)<\/b> <b class="conum">\(4\)<\/b>$/, output)
|
3935
|
+
assert_match(/ <b class="conum">\(5\)<\/b><b class="conum">\(6\)<\/b>$/, output)
|
3781
3936
|
end
|
3782
3937
|
|
3783
3938
|
test 'should allow XML comment-style callouts' do
|
@@ -3938,14 +4093,18 @@ context 'Checklists' do
|
|
3938
4093
|
input = <<-EOS
|
3939
4094
|
- [ ] todo
|
3940
4095
|
- [x] done
|
4096
|
+
- [ ] another todo
|
4097
|
+
- [*] another done
|
3941
4098
|
- plain
|
3942
4099
|
EOS
|
3943
4100
|
|
3944
4101
|
output = render_embedded_string input
|
3945
4102
|
assert_css '.ulist.checklist', output, 1
|
3946
|
-
|
3947
|
-
|
3948
|
-
assert_xpath
|
4103
|
+
assert_xpath %((/*[@class="ulist checklist"]/ul/li)[1]/p[text()="#{expand_entity 10063} todo"]), output, 1
|
4104
|
+
assert_xpath %((/*[@class="ulist checklist"]/ul/li)[2]/p[text()="#{expand_entity 10003} done"]), output, 1
|
4105
|
+
assert_xpath %((/*[@class="ulist checklist"]/ul/li)[3]/p[text()="#{expand_entity 10063} another todo"]), output, 1
|
4106
|
+
assert_xpath %((/*[@class="ulist checklist"]/ul/li)[4]/p[text()="#{expand_entity 10003} another done"]), output, 1
|
4107
|
+
assert_xpath '(/*[@class="ulist checklist"]/ul/li)[5]/p[text()="plain"]', output, 1
|
3949
4108
|
end
|
3950
4109
|
|
3951
4110
|
test 'should create checklist with font icons if at least one item has checkbox syntax and icons attribute is font' do
|
@@ -3957,8 +4116,8 @@ context 'Checklists' do
|
|
3957
4116
|
|
3958
4117
|
output = render_embedded_string input, :attributes => {'icons' => 'font'}
|
3959
4118
|
assert_css '.ulist.checklist', output, 1
|
3960
|
-
assert_css '.ulist.checklist li i.
|
3961
|
-
assert_css '.ulist.checklist li i.
|
4119
|
+
assert_css '.ulist.checklist li i.fa-check-square-o', output, 1
|
4120
|
+
assert_css '.ulist.checklist li i.fa-square-o', output, 1
|
3962
4121
|
assert_xpath '(/*[@class="ulist checklist"]/ul/li)[3]/p[text()="plain"]', output, 1
|
3963
4122
|
end
|
3964
4123
|
|