asciidoctor 1.5.8 → 2.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +11 -0
- data/CHANGELOG.adoc +628 -45
- data/LICENSE +2 -1
- data/README-de.adoc +28 -38
- data/README-fr.adoc +30 -43
- data/README-jp.adoc +255 -201
- data/README-zh_CN.adoc +40 -44
- data/README.adoc +170 -143
- data/asciidoctor.gemspec +22 -34
- data/bin/asciidoctor +5 -4
- data/data/locale/attributes-ar.adoc +4 -3
- data/data/locale/attributes-be.adoc +23 -0
- data/data/locale/attributes-bg.adoc +4 -3
- data/data/locale/attributes-ca.adoc +6 -5
- data/data/locale/attributes-cs.adoc +4 -3
- data/data/locale/attributes-da.adoc +6 -5
- data/data/locale/attributes-de.adoc +6 -5
- data/data/locale/attributes-en.adoc +4 -4
- data/data/locale/attributes-es.adoc +6 -5
- data/data/locale/attributes-fa.adoc +4 -3
- data/data/locale/attributes-fi.adoc +4 -3
- data/data/locale/attributes-fr.adoc +8 -7
- data/data/locale/attributes-hu.adoc +4 -3
- data/data/locale/attributes-id.adoc +4 -3
- data/data/locale/attributes-it.adoc +6 -5
- data/data/locale/attributes-ja.adoc +4 -3
- data/data/locale/{attributes-kr.adoc → attributes-ko.adoc} +4 -3
- data/data/locale/attributes-nb.adoc +4 -3
- data/data/locale/attributes-nl.adoc +6 -5
- data/data/locale/attributes-nn.adoc +4 -3
- data/data/locale/attributes-pl.adoc +8 -7
- data/data/locale/attributes-pt.adoc +6 -5
- data/data/locale/attributes-pt_BR.adoc +6 -5
- data/data/locale/attributes-ro.adoc +4 -3
- data/data/locale/attributes-ru.adoc +6 -5
- data/data/locale/attributes-sr.adoc +4 -4
- data/data/locale/attributes-sr_Latn.adoc +4 -4
- data/data/locale/attributes-sv.adoc +4 -4
- data/data/locale/attributes-th.adoc +23 -0
- data/data/locale/attributes-tr.adoc +4 -3
- data/data/locale/attributes-uk.adoc +6 -5
- data/data/locale/attributes-vi.adoc +23 -0
- data/data/locale/attributes-zh_CN.adoc +4 -3
- data/data/locale/attributes-zh_TW.adoc +4 -3
- data/data/reference/syntax.adoc +296 -0
- data/data/stylesheets/asciidoctor-default.css +120 -114
- data/data/stylesheets/coderay-asciidoctor.css +15 -17
- data/lib/asciidoctor/abstract_block.rb +146 -140
- data/lib/asciidoctor/abstract_node.rb +152 -170
- data/lib/asciidoctor/attribute_list.rb +77 -89
- data/lib/asciidoctor/block.rb +29 -28
- data/lib/asciidoctor/callouts.rb +4 -2
- data/lib/asciidoctor/cli/invoker.rb +20 -24
- data/lib/asciidoctor/cli/options.rb +107 -96
- data/lib/asciidoctor/cli.rb +3 -2
- data/lib/asciidoctor/convert.rb +199 -0
- data/lib/asciidoctor/converter/composite.rb +40 -48
- data/lib/asciidoctor/converter/docbook5.rb +627 -644
- data/lib/asciidoctor/converter/html5.rb +1053 -951
- data/lib/asciidoctor/converter/manpage.rb +581 -532
- data/lib/asciidoctor/converter/template.rb +232 -271
- data/lib/asciidoctor/converter.rb +370 -185
- data/lib/asciidoctor/core_ext/float/truncate.rb +20 -0
- data/lib/asciidoctor/core_ext/hash/merge.rb +8 -0
- data/lib/asciidoctor/core_ext/match_data/names.rb +7 -0
- data/lib/asciidoctor/core_ext/nil_or_empty.rb +1 -0
- data/lib/asciidoctor/core_ext/regexp/is_match.rb +4 -2
- data/lib/asciidoctor/core_ext.rb +8 -17
- data/lib/asciidoctor/document.rb +503 -461
- data/lib/asciidoctor/extensions.rb +127 -174
- data/lib/asciidoctor/helpers.rb +184 -107
- data/lib/asciidoctor/inline.rb +9 -12
- data/lib/asciidoctor/list.rb +11 -29
- data/lib/asciidoctor/load.rb +119 -0
- data/lib/asciidoctor/logging.rb +22 -17
- data/lib/asciidoctor/parser.rb +673 -719
- data/lib/asciidoctor/path_resolver.rb +48 -33
- data/lib/asciidoctor/reader.rb +383 -338
- data/lib/asciidoctor/rouge_ext.rb +39 -0
- data/lib/asciidoctor/rx.rb +723 -0
- data/lib/asciidoctor/section.rb +17 -16
- data/lib/asciidoctor/stylesheets.rb +19 -37
- data/lib/asciidoctor/substitutors.rb +926 -1022
- data/lib/asciidoctor/syntax_highlighter/coderay.rb +88 -0
- data/lib/asciidoctor/syntax_highlighter/highlightjs.rb +34 -0
- data/lib/asciidoctor/syntax_highlighter/html_pipeline.rb +10 -0
- data/lib/asciidoctor/syntax_highlighter/prettify.rb +30 -0
- data/lib/asciidoctor/syntax_highlighter/pygments.rb +157 -0
- data/lib/asciidoctor/syntax_highlighter/rouge.rb +143 -0
- data/lib/asciidoctor/syntax_highlighter.rb +253 -0
- data/lib/asciidoctor/table.rb +152 -114
- data/lib/asciidoctor/timings.rb +7 -5
- data/lib/asciidoctor/version.rb +2 -1
- data/lib/asciidoctor/writer.rb +30 -0
- data/lib/asciidoctor.rb +266 -1340
- data/man/asciidoctor.1 +49 -47
- data/man/asciidoctor.adoc +54 -45
- metadata +50 -245
- data/CONTRIBUTING.adoc +0 -185
- data/Gemfile +0 -60
- data/Rakefile +0 -129
- data/bin/asciidoctor-safe +0 -15
- data/features/open_block.feature +0 -92
- data/features/pass_block.feature +0 -66
- data/features/step_definitions.rb +0 -49
- data/features/text_formatting.feature +0 -57
- data/features/xref.feature +0 -1039
- data/lib/asciidoctor/converter/base.rb +0 -59
- data/lib/asciidoctor/converter/docbook45.rb +0 -93
- data/lib/asciidoctor/converter/factory.rb +0 -226
- data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/concurrent/hash.rb +0 -5
- data/lib/asciidoctor/core_ext/1.8.7/hash/key.rb +0 -4
- data/lib/asciidoctor/core_ext/1.8.7/io/binread.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/io/write.rb +0 -5
- data/lib/asciidoctor/core_ext/1.8.7/string/chr.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/string/limit_bytesize.rb +0 -29
- data/lib/asciidoctor/core_ext/1.8.7/symbol/empty.rb +0 -6
- data/lib/asciidoctor/core_ext/1.8.7/symbol/length.rb +0 -6
- data/lib/asciidoctor/core_ext/string/limit_bytesize.rb +0 -10
- data/test/api_test.rb +0 -1240
- data/test/attribute_list_test.rb +0 -242
- data/test/attributes_test.rb +0 -1623
- data/test/blocks_test.rb +0 -3870
- data/test/converter_test.rb +0 -470
- data/test/document_test.rb +0 -1853
- data/test/extensions_test.rb +0 -1560
- data/test/fixtures/asciidoc_index.txt +0 -521
- data/test/fixtures/basic-docinfo-footer.html +0 -6
- data/test/fixtures/basic-docinfo-footer.xml +0 -8
- data/test/fixtures/basic-docinfo.html +0 -1
- data/test/fixtures/basic-docinfo.xml +0 -4
- data/test/fixtures/basic.asciidoc +0 -5
- data/test/fixtures/chapter-a.adoc +0 -3
- data/test/fixtures/child-include.adoc +0 -5
- data/test/fixtures/circle.svg +0 -9
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +0 -6
- data/test/fixtures/custom-backends/haml/docbook45/block_paragraph.xml.haml +0 -6
- data/test/fixtures/custom-backends/haml/html5/block_paragraph.html.haml +0 -3
- data/test/fixtures/custom-backends/haml/html5/block_sidebar.html.haml +0 -5
- data/test/fixtures/custom-backends/haml/html5-tweaks/block_paragraph.html.haml +0 -1
- data/test/fixtures/custom-backends/slim/docbook45/block_paragraph.xml.slim +0 -6
- data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +0 -3
- data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +0 -5
- data/test/fixtures/custom-docinfodir/basic-docinfo.html +0 -1
- data/test/fixtures/custom-docinfodir/docinfo.html +0 -1
- data/test/fixtures/docinfo-footer.html +0 -1
- data/test/fixtures/docinfo-footer.xml +0 -9
- data/test/fixtures/docinfo.html +0 -1
- data/test/fixtures/docinfo.xml +0 -3
- data/test/fixtures/doctime-localtime.adoc +0 -2
- data/test/fixtures/dot.gif +0 -0
- data/test/fixtures/encoding.asciidoc +0 -13
- data/test/fixtures/file-with-missing-include.adoc +0 -1
- data/test/fixtures/grandchild-include.adoc +0 -3
- data/test/fixtures/hello-asciidoctor.pdf +0 -69
- data/test/fixtures/include-file.asciidoc +0 -24
- data/test/fixtures/include-file.jsx +0 -8
- data/test/fixtures/include-file.ml +0 -3
- data/test/fixtures/include-file.xml +0 -5
- data/test/fixtures/lists.adoc +0 -96
- data/test/fixtures/master.adoc +0 -5
- data/test/fixtures/mismatched-end-tag.adoc +0 -7
- data/test/fixtures/other-chapters.adoc +0 -11
- data/test/fixtures/outer-include.adoc +0 -5
- data/test/fixtures/parent-include-restricted.adoc +0 -5
- data/test/fixtures/parent-include.adoc +0 -5
- data/test/fixtures/sample.asciidoc +0 -30
- data/test/fixtures/section-a.adoc +0 -4
- data/test/fixtures/stylesheets/custom.css +0 -3
- data/test/fixtures/subdir/index.adoc +0 -3
- data/test/fixtures/subdir/inner-include.adoc +0 -3
- data/test/fixtures/subdir/middle-include.adoc +0 -5
- data/test/fixtures/subs-docinfo.html +0 -2
- data/test/fixtures/subs.adoc +0 -6
- data/test/fixtures/tagged-class-enclosed.rb +0 -25
- data/test/fixtures/tagged-class.rb +0 -23
- data/test/fixtures/tip.gif +0 -0
- data/test/fixtures/unclosed-tag.adoc +0 -3
- data/test/fixtures/unexpected-end-tag.adoc +0 -4
- data/test/invoker_test.rb +0 -745
- data/test/links_test.rb +0 -855
- data/test/lists_test.rb +0 -5151
- data/test/logger_test.rb +0 -211
- data/test/manpage_test.rb +0 -660
- data/test/options_test.rb +0 -262
- data/test/paragraphs_test.rb +0 -562
- data/test/parser_test.rb +0 -742
- data/test/paths_test.rb +0 -395
- data/test/preamble_test.rb +0 -173
- data/test/reader_test.rb +0 -2161
- data/test/sections_test.rb +0 -3575
- data/test/substitutions_test.rb +0 -2066
- data/test/tables_test.rb +0 -2036
- data/test/test_helper.rb +0 -447
- data/test/text_test.rb +0 -309
data/test/paragraphs_test.rb
DELETED
@@ -1,562 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
unless defined? ASCIIDOCTOR_PROJECT_DIR
|
3
|
-
$: << File.dirname(__FILE__); $:.uniq!
|
4
|
-
require 'test_helper'
|
5
|
-
end
|
6
|
-
|
7
|
-
context 'Paragraphs' do
|
8
|
-
context 'Normal' do
|
9
|
-
test 'should treat plain text separated by blank lines as paragraphs' do
|
10
|
-
input = <<-EOS
|
11
|
-
Plain text for the win!
|
12
|
-
|
13
|
-
Yep. Text. Plain and simple.
|
14
|
-
EOS
|
15
|
-
output = convert_string_to_embedded input
|
16
|
-
assert_css 'p', output, 2
|
17
|
-
assert_xpath '(//p)[1][text() = "Plain text for the win!"]', output, 1
|
18
|
-
assert_xpath '(//p)[2][text() = "Yep. Text. Plain and simple."]', output, 1
|
19
|
-
end
|
20
|
-
|
21
|
-
test 'should associate block title with paragraph' do
|
22
|
-
input = <<-EOS
|
23
|
-
.Titled
|
24
|
-
Paragraph.
|
25
|
-
|
26
|
-
Winning.
|
27
|
-
EOS
|
28
|
-
output = convert_string_to_embedded input
|
29
|
-
|
30
|
-
assert_css 'p', output, 2
|
31
|
-
assert_xpath '(//p)[1]/preceding-sibling::*[@class = "title"]', output, 1
|
32
|
-
assert_xpath '(//p)[1]/preceding-sibling::*[@class = "title"][text() = "Titled"]', output, 1
|
33
|
-
assert_xpath '(//p)[2]/preceding-sibling::*[@class = "title"]', output, 0
|
34
|
-
end
|
35
|
-
|
36
|
-
test 'no duplicate block before next section' do
|
37
|
-
input = <<-EOS
|
38
|
-
= Title
|
39
|
-
|
40
|
-
Preamble
|
41
|
-
|
42
|
-
== First Section
|
43
|
-
|
44
|
-
Paragraph 1
|
45
|
-
|
46
|
-
Paragraph 2
|
47
|
-
|
48
|
-
== Second Section
|
49
|
-
|
50
|
-
Last words
|
51
|
-
EOS
|
52
|
-
|
53
|
-
output = convert_string input
|
54
|
-
assert_xpath '//p[text() = "Paragraph 2"]', output, 1
|
55
|
-
end
|
56
|
-
|
57
|
-
test 'does not treat wrapped line as a list item' do
|
58
|
-
input = <<-EOS
|
59
|
-
paragraph
|
60
|
-
. wrapped line
|
61
|
-
EOS
|
62
|
-
|
63
|
-
output = convert_string_to_embedded input
|
64
|
-
assert_css 'p', output, 1
|
65
|
-
assert_xpath %(//p[text()="paragraph\n. wrapped line"]), output, 1
|
66
|
-
end
|
67
|
-
|
68
|
-
test 'does not treat wrapped line as a block title' do
|
69
|
-
input = <<-EOS
|
70
|
-
paragraph
|
71
|
-
.wrapped line
|
72
|
-
EOS
|
73
|
-
|
74
|
-
output = convert_string_to_embedded input
|
75
|
-
assert_css 'p', output, 1
|
76
|
-
assert_xpath %(//p[text()="paragraph\n.wrapped line"]), output, 1
|
77
|
-
end
|
78
|
-
|
79
|
-
test 'interprets normal paragraph style as normal paragraph' do
|
80
|
-
input = <<-EOS
|
81
|
-
[normal]
|
82
|
-
Normal paragraph.
|
83
|
-
Nothing special.
|
84
|
-
EOS
|
85
|
-
|
86
|
-
output = convert_string_to_embedded input
|
87
|
-
assert_css 'p', output, 1
|
88
|
-
end
|
89
|
-
|
90
|
-
test 'removes indentation from literal paragraph marked as normal' do
|
91
|
-
input = <<-EOS
|
92
|
-
[normal]
|
93
|
-
Normal paragraph.
|
94
|
-
Nothing special.
|
95
|
-
Last line.
|
96
|
-
EOS
|
97
|
-
|
98
|
-
output = convert_string_to_embedded input
|
99
|
-
assert_css 'p', output, 1
|
100
|
-
assert_xpath %(//p[text()="Normal paragraph.\n Nothing special.\nLast line."]), output, 1
|
101
|
-
end
|
102
|
-
|
103
|
-
test 'normal paragraph terminates at block attribute list' do
|
104
|
-
input = <<-EOS
|
105
|
-
normal text
|
106
|
-
[literal]
|
107
|
-
literal text
|
108
|
-
EOS
|
109
|
-
output = convert_string_to_embedded input
|
110
|
-
assert_css '.paragraph:root', output, 1
|
111
|
-
assert_css '.literalblock:root', output, 1
|
112
|
-
end
|
113
|
-
|
114
|
-
test 'normal paragraph terminates at block delimiter' do
|
115
|
-
input = <<-EOS
|
116
|
-
normal text
|
117
|
-
--
|
118
|
-
text in open block
|
119
|
-
--
|
120
|
-
EOS
|
121
|
-
output = convert_string_to_embedded input
|
122
|
-
assert_css '.paragraph:root', output, 1
|
123
|
-
assert_css '.openblock:root', output, 1
|
124
|
-
end
|
125
|
-
|
126
|
-
test 'normal paragraph terminates at list continuation' do
|
127
|
-
input = <<-EOS
|
128
|
-
normal text
|
129
|
-
+
|
130
|
-
EOS
|
131
|
-
output = convert_string_to_embedded input
|
132
|
-
assert_css '.paragraph:root', output, 2
|
133
|
-
assert_xpath %((/*[@class="paragraph"])[1]/p[text() = "normal text"]), output, 1
|
134
|
-
assert_xpath %((/*[@class="paragraph"])[2]/p[text() = "+"]), output, 1
|
135
|
-
end
|
136
|
-
|
137
|
-
test 'normal style turns literal paragraph into normal paragraph' do
|
138
|
-
input = <<-EOS
|
139
|
-
[normal]
|
140
|
-
normal paragraph,
|
141
|
-
despite the leading indent
|
142
|
-
EOS
|
143
|
-
|
144
|
-
output = convert_string_to_embedded input
|
145
|
-
assert_css '.paragraph:root > p', output, 1
|
146
|
-
end
|
147
|
-
|
148
|
-
test 'expands index term macros in DocBook backend' do
|
149
|
-
input = <<-EOS
|
150
|
-
Here is an index entry for ((tigers)).
|
151
|
-
indexterm:[Big cats,Tigers,Siberian Tiger]
|
152
|
-
Here is an index entry for indexterm2:[Linux].
|
153
|
-
(((Operating Systems,Linux,Fedora)))
|
154
|
-
Note that multi-entry terms generate separate index entries.
|
155
|
-
EOS
|
156
|
-
|
157
|
-
output = convert_string_to_embedded input, :attributes => {'backend' => 'docbook45'}
|
158
|
-
assert_xpath '/simpara', output, 1
|
159
|
-
term1 = xmlnodes_at_xpath '(//indexterm)[1]', output, 1
|
160
|
-
assert_equal '<indexterm><primary>tigers</primary></indexterm>', term1.to_s
|
161
|
-
assert term1.next.content.start_with?('tigers')
|
162
|
-
|
163
|
-
term2 = xmlnodes_at_xpath '(//indexterm)[2]', output, 1
|
164
|
-
term2_elements = term2.elements
|
165
|
-
assert_equal 3, term2_elements.size
|
166
|
-
assert_equal '<primary>Big cats</primary>', term2_elements[0].to_s
|
167
|
-
assert_equal '<secondary>Tigers</secondary>', term2_elements[1].to_s
|
168
|
-
assert_equal '<tertiary>Siberian Tiger</tertiary>', term2_elements[2].to_s
|
169
|
-
|
170
|
-
term3 = xmlnodes_at_xpath '(//indexterm)[3]', output, 1
|
171
|
-
term3_elements = term3.elements
|
172
|
-
assert_equal 2, term3_elements.size
|
173
|
-
assert_equal '<primary>Tigers</primary>', term3_elements[0].to_s
|
174
|
-
assert_equal '<secondary>Siberian Tiger</secondary>', term3_elements[1].to_s
|
175
|
-
|
176
|
-
term4 = xmlnodes_at_xpath '(//indexterm)[4]', output, 1
|
177
|
-
term4_elements = term4.elements
|
178
|
-
assert_equal 1, term4_elements.size
|
179
|
-
assert_equal '<primary>Siberian Tiger</primary>', term4_elements[0].to_s
|
180
|
-
|
181
|
-
term5 = xmlnodes_at_xpath '(//indexterm)[5]', output, 1
|
182
|
-
assert_equal '<indexterm><primary>Linux</primary></indexterm>', term5.to_s
|
183
|
-
assert term5.next.content.start_with?('Linux')
|
184
|
-
|
185
|
-
assert_xpath '(//indexterm)[6]/*', output, 3
|
186
|
-
assert_xpath '(//indexterm)[7]/*', output, 2
|
187
|
-
assert_xpath '(//indexterm)[8]/*', output, 1
|
188
|
-
end
|
189
|
-
|
190
|
-
test 'normal paragraph should honor explicit subs list' do
|
191
|
-
input = <<-EOS
|
192
|
-
[subs="specialcharacters"]
|
193
|
-
*<Hey Jude>*
|
194
|
-
EOS
|
195
|
-
|
196
|
-
output = convert_string_to_embedded input
|
197
|
-
assert_includes output, '*<Hey Jude>*'
|
198
|
-
end
|
199
|
-
|
200
|
-
test 'normal paragraph should honor specialchars shorthand' do
|
201
|
-
input = <<-EOS
|
202
|
-
[subs="specialchars"]
|
203
|
-
*<Hey Jude>*
|
204
|
-
EOS
|
205
|
-
|
206
|
-
output = convert_string_to_embedded input
|
207
|
-
assert_includes output, '*<Hey Jude>*'
|
208
|
-
end
|
209
|
-
|
210
|
-
test 'should add a hardbreak at end of each line when hardbreaks option is set' do
|
211
|
-
input = <<-EOS
|
212
|
-
[%hardbreaks]
|
213
|
-
read
|
214
|
-
my
|
215
|
-
lips
|
216
|
-
EOS
|
217
|
-
|
218
|
-
output = convert_string_to_embedded input
|
219
|
-
assert_css 'br', output, 2
|
220
|
-
assert_xpath '//p', output, 1
|
221
|
-
assert_includes output, "<p>read<br>\nmy<br>\nlips</p>"
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
context 'Literal' do
|
226
|
-
test 'single-line literal paragraphs' do
|
227
|
-
input = <<-EOS
|
228
|
-
LITERALS
|
229
|
-
|
230
|
-
ARE LITERALLY
|
231
|
-
|
232
|
-
AWESOME!
|
233
|
-
EOS
|
234
|
-
output = convert_string_to_embedded input
|
235
|
-
assert_xpath '//pre', output, 3
|
236
|
-
end
|
237
|
-
|
238
|
-
test 'multi-line literal paragraph' do
|
239
|
-
input = <<-EOS
|
240
|
-
Install instructions:
|
241
|
-
|
242
|
-
yum install ruby rubygems
|
243
|
-
gem install asciidoctor
|
244
|
-
|
245
|
-
You're good to go!
|
246
|
-
EOS
|
247
|
-
output = convert_string_to_embedded input
|
248
|
-
assert_xpath '//pre', output, 1
|
249
|
-
# indentation should be trimmed from literal block
|
250
|
-
assert_xpath %(//pre[text() = "yum install ruby rubygems\ngem install asciidoctor"]), output, 1
|
251
|
-
end
|
252
|
-
|
253
|
-
test 'literal paragraph' do
|
254
|
-
input = <<-EOS
|
255
|
-
[literal]
|
256
|
-
this text is literally literal
|
257
|
-
EOS
|
258
|
-
output = convert_string_to_embedded input
|
259
|
-
assert_xpath %(/*[@class="literalblock"]//pre[text()="this text is literally literal"]), output, 1
|
260
|
-
end
|
261
|
-
|
262
|
-
test 'should read content below literal style verbatim' do
|
263
|
-
input = <<-EOS
|
264
|
-
[literal]
|
265
|
-
image::not-an-image-block[]
|
266
|
-
EOS
|
267
|
-
output = convert_string_to_embedded input
|
268
|
-
assert_xpath %(/*[@class="literalblock"]//pre[text()="image::not-an-image-block[]"]), output, 1
|
269
|
-
assert_css 'img', output, 0
|
270
|
-
end
|
271
|
-
|
272
|
-
test 'listing paragraph' do
|
273
|
-
input = <<-EOS
|
274
|
-
[listing]
|
275
|
-
this text is a listing
|
276
|
-
EOS
|
277
|
-
output = convert_string_to_embedded input
|
278
|
-
assert_xpath %(/*[@class="listingblock"]//pre[text()="this text is a listing"]), output, 1
|
279
|
-
end
|
280
|
-
|
281
|
-
test 'source paragraph' do
|
282
|
-
input = <<-EOS
|
283
|
-
[source]
|
284
|
-
use the source, luke!
|
285
|
-
EOS
|
286
|
-
output = convert_string_to_embedded input
|
287
|
-
assert_xpath %(/*[@class="listingblock"]//pre[@class="highlight"]/code[text()="use the source, luke!"]), output, 1
|
288
|
-
end
|
289
|
-
|
290
|
-
test 'source code paragraph with language' do
|
291
|
-
input = <<-EOS
|
292
|
-
[source, perl]
|
293
|
-
die 'zomg perl sucks';
|
294
|
-
EOS
|
295
|
-
output = convert_string_to_embedded input
|
296
|
-
assert_xpath %(/*[@class="listingblock"]//pre[@class="highlight"]/code[@class="language-perl"][@data-lang="perl"][text()="die 'zomg perl sucks';"]), output, 1
|
297
|
-
end
|
298
|
-
|
299
|
-
test 'literal paragraph terminates at block attribute list' do
|
300
|
-
input = <<-EOS
|
301
|
-
literal text
|
302
|
-
[normal]
|
303
|
-
normal text
|
304
|
-
EOS
|
305
|
-
output = convert_string_to_embedded input
|
306
|
-
assert_xpath %(/*[@class="literalblock"]), output, 1
|
307
|
-
assert_xpath %(/*[@class="paragraph"]), output, 1
|
308
|
-
end
|
309
|
-
|
310
|
-
test 'literal paragraph terminates at block delimiter' do
|
311
|
-
input = <<-EOS
|
312
|
-
literal text
|
313
|
-
--
|
314
|
-
normal text
|
315
|
-
--
|
316
|
-
EOS
|
317
|
-
output = convert_string_to_embedded input
|
318
|
-
assert_xpath %(/*[@class="literalblock"]), output, 1
|
319
|
-
assert_xpath %(/*[@class="openblock"]), output, 1
|
320
|
-
end
|
321
|
-
|
322
|
-
test 'literal paragraph terminates at list continuation' do
|
323
|
-
input = <<-EOS
|
324
|
-
literal text
|
325
|
-
+
|
326
|
-
EOS
|
327
|
-
output = convert_string_to_embedded input
|
328
|
-
assert_xpath %(/*[@class="literalblock"]), output, 1
|
329
|
-
assert_xpath %(/*[@class="literalblock"]//pre[text() = "literal text"]), output, 1
|
330
|
-
assert_xpath %(/*[@class="paragraph"]), output, 1
|
331
|
-
assert_xpath %(/*[@class="paragraph"]/p[text() = "+"]), output, 1
|
332
|
-
end
|
333
|
-
end
|
334
|
-
|
335
|
-
context 'Quote' do
|
336
|
-
test "single-line quote paragraph" do
|
337
|
-
input = <<-EOS
|
338
|
-
[quote]
|
339
|
-
Famous quote.
|
340
|
-
EOS
|
341
|
-
output = convert_string input
|
342
|
-
assert_xpath '//*[@class = "quoteblock"]', output, 1
|
343
|
-
assert_xpath '//*[@class = "quoteblock"]//p', output, 0
|
344
|
-
assert_xpath '//*[@class = "quoteblock"]//*[contains(text(), "Famous quote.")]', output, 1
|
345
|
-
end
|
346
|
-
|
347
|
-
test 'quote paragraph terminates at list continuation' do
|
348
|
-
input = <<-EOS
|
349
|
-
[quote]
|
350
|
-
A famouse quote.
|
351
|
-
+
|
352
|
-
EOS
|
353
|
-
output = convert_string_to_embedded input
|
354
|
-
assert_css '.quoteblock:root', output, 1
|
355
|
-
assert_css '.paragraph:root', output, 1
|
356
|
-
assert_xpath %(/*[@class="paragraph"]/p[text() = "+"]), output, 1
|
357
|
-
end
|
358
|
-
|
359
|
-
test "verse paragraph" do
|
360
|
-
output = convert_string("[verse]\nFamous verse.")
|
361
|
-
assert_xpath '//*[@class = "verseblock"]', output, 1
|
362
|
-
assert_xpath '//*[@class = "verseblock"]/pre', output, 1
|
363
|
-
assert_xpath '//*[@class = "verseblock"]//p', output, 0
|
364
|
-
assert_xpath '//*[@class = "verseblock"]/pre[normalize-space(text()) = "Famous verse."]', output, 1
|
365
|
-
end
|
366
|
-
|
367
|
-
test 'should perform normal subs on a verse paragraph' do
|
368
|
-
input = <<-EOS
|
369
|
-
[verse]
|
370
|
-
_GET /groups/link:#group-id[\{group-id\}]_
|
371
|
-
EOS
|
372
|
-
|
373
|
-
output = convert_string_to_embedded input
|
374
|
-
assert_includes output, '<pre class="content"><em>GET /groups/<a href="#group-id">{group-id}</a></em></pre>'
|
375
|
-
end
|
376
|
-
|
377
|
-
test 'quote paragraph should honor explicit subs list' do
|
378
|
-
input = <<-EOS
|
379
|
-
[subs="specialcharacters"]
|
380
|
-
[quote]
|
381
|
-
*Hey Jude*
|
382
|
-
EOS
|
383
|
-
|
384
|
-
output = convert_string_to_embedded input
|
385
|
-
assert_includes output, '*Hey Jude*'
|
386
|
-
end
|
387
|
-
end
|
388
|
-
|
389
|
-
context "special" do
|
390
|
-
test "note multiline syntax" do
|
391
|
-
Asciidoctor::ADMONITION_STYLES.each do |style|
|
392
|
-
assert_xpath "//div[@class='admonitionblock #{style.downcase}']", convert_string("[#{style}]\nThis is a winner.")
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
test "note block syntax" do
|
397
|
-
Asciidoctor::ADMONITION_STYLES.each do |style|
|
398
|
-
assert_xpath "//div[@class='admonitionblock #{style.downcase}']", convert_string("[#{style}]\n====\nThis is a winner.\n====")
|
399
|
-
end
|
400
|
-
end
|
401
|
-
|
402
|
-
test "note inline syntax" do
|
403
|
-
Asciidoctor::ADMONITION_STYLES.each do |style|
|
404
|
-
assert_xpath "//div[@class='admonitionblock #{style.downcase}']", convert_string("#{style}: This is important, fool!")
|
405
|
-
end
|
406
|
-
end
|
407
|
-
|
408
|
-
test "sidebar block" do
|
409
|
-
input = <<-EOS
|
410
|
-
== Section
|
411
|
-
|
412
|
-
.Sidebar
|
413
|
-
****
|
414
|
-
Content goes here
|
415
|
-
****
|
416
|
-
EOS
|
417
|
-
result = convert_string(input)
|
418
|
-
assert_xpath "//*[@class='sidebarblock']//p", result, 1
|
419
|
-
end
|
420
|
-
|
421
|
-
test 'should process preprocessor conditional in paragrpah content' do
|
422
|
-
input = <<-EOS
|
423
|
-
ifdef::asciidoctor-version[]
|
424
|
-
[sidebar]
|
425
|
-
First line of sidebar.
|
426
|
-
ifdef::backend[The backend is {backend}.]
|
427
|
-
Last line of sidebar.
|
428
|
-
endif::[]
|
429
|
-
EOS
|
430
|
-
|
431
|
-
result = convert_string_to_embedded input
|
432
|
-
assert_equal %(<div class="sidebarblock">
|
433
|
-
<div class="content">
|
434
|
-
First line of sidebar.
|
435
|
-
The backend is html5.
|
436
|
-
Last line of sidebar.
|
437
|
-
</div>
|
438
|
-
</div>), result
|
439
|
-
end
|
440
|
-
|
441
|
-
context 'Styled Paragraphs' do
|
442
|
-
test 'should wrap text in simpara for styled paragraphs when converted to DocBook' do
|
443
|
-
input = <<-EOS
|
444
|
-
= Book
|
445
|
-
:doctype: book
|
446
|
-
|
447
|
-
[preface]
|
448
|
-
= About this book
|
449
|
-
|
450
|
-
[abstract]
|
451
|
-
An abstract for the book.
|
452
|
-
|
453
|
-
= Part 1
|
454
|
-
|
455
|
-
[partintro]
|
456
|
-
An intro to this part.
|
457
|
-
|
458
|
-
== Chapter 1
|
459
|
-
|
460
|
-
[sidebar]
|
461
|
-
Just a side note.
|
462
|
-
|
463
|
-
[example]
|
464
|
-
As you can see here.
|
465
|
-
|
466
|
-
[quote]
|
467
|
-
Wise words from a wise person.
|
468
|
-
|
469
|
-
[open]
|
470
|
-
Make it what you want.
|
471
|
-
EOS
|
472
|
-
|
473
|
-
output = convert_string input, :backend => 'docbook'
|
474
|
-
assert_css 'abstract > simpara', output, 1
|
475
|
-
assert_css 'partintro > simpara', output, 1
|
476
|
-
assert_css 'sidebar > simpara', output, 1
|
477
|
-
assert_css 'informalexample > simpara', output, 1
|
478
|
-
assert_css 'blockquote > simpara', output, 1
|
479
|
-
assert_css 'chapter > simpara', output, 1
|
480
|
-
end
|
481
|
-
|
482
|
-
test 'should convert open paragraph to open block' do
|
483
|
-
input = <<-EOS
|
484
|
-
[open]
|
485
|
-
Make it what you want.
|
486
|
-
EOS
|
487
|
-
|
488
|
-
output = convert_string_to_embedded input
|
489
|
-
assert_css '.openblock', output, 1
|
490
|
-
assert_css '.openblock p', output, 0
|
491
|
-
end
|
492
|
-
|
493
|
-
test 'should wrap text in simpara for styled paragraphs with title when converted to DocBook' do
|
494
|
-
input = <<-EOS
|
495
|
-
= Book
|
496
|
-
:doctype: book
|
497
|
-
|
498
|
-
[preface]
|
499
|
-
= About this book
|
500
|
-
|
501
|
-
[abstract]
|
502
|
-
.Abstract title
|
503
|
-
An abstract for the book.
|
504
|
-
|
505
|
-
= Part 1
|
506
|
-
|
507
|
-
[partintro]
|
508
|
-
.Part intro title
|
509
|
-
An intro to this part.
|
510
|
-
|
511
|
-
== Chapter 1
|
512
|
-
|
513
|
-
[sidebar]
|
514
|
-
.Sidebar title
|
515
|
-
Just a side note.
|
516
|
-
|
517
|
-
[example]
|
518
|
-
.Example title
|
519
|
-
As you can see here.
|
520
|
-
|
521
|
-
[quote]
|
522
|
-
.Quote title
|
523
|
-
Wise words from a wise person.
|
524
|
-
EOS
|
525
|
-
|
526
|
-
output = convert_string input, :backend => 'docbook'
|
527
|
-
assert_css 'abstract > title', output, 1
|
528
|
-
assert_xpath '//abstract/title[text() = "Abstract title"]', output, 1
|
529
|
-
assert_css 'abstract > title + simpara', output, 1
|
530
|
-
assert_css 'partintro > title', output, 1
|
531
|
-
assert_xpath '//partintro/title[text() = "Part intro title"]', output, 1
|
532
|
-
assert_css 'partintro > title + simpara', output, 1
|
533
|
-
assert_css 'sidebar > title', output, 1
|
534
|
-
assert_xpath '//sidebar/title[text() = "Sidebar title"]', output, 1
|
535
|
-
assert_css 'sidebar > title + simpara', output, 1
|
536
|
-
assert_css 'example > title', output, 1
|
537
|
-
assert_xpath '//example/title[text() = "Example title"]', output, 1
|
538
|
-
assert_css 'example > title + simpara', output, 1
|
539
|
-
assert_css 'blockquote > title', output, 1
|
540
|
-
assert_xpath '//blockquote/title[text() = "Quote title"]', output, 1
|
541
|
-
assert_css 'blockquote > title + simpara', output, 1
|
542
|
-
end
|
543
|
-
end
|
544
|
-
|
545
|
-
context 'Inline doctype' do
|
546
|
-
test 'should only format and output text in first paragraph when doctype is inline' do
|
547
|
-
input = "http://asciidoc.org[AsciiDoc] is a _lightweight_ markup language...\n\nignored"
|
548
|
-
output = convert_string input, :doctype => 'inline'
|
549
|
-
assert_equal '<a href="http://asciidoc.org">AsciiDoc</a> is a <em>lightweight</em> markup language…​', output
|
550
|
-
end
|
551
|
-
|
552
|
-
test 'should output nil and warn if first block is not a paragraph' do
|
553
|
-
input = '* bullet'
|
554
|
-
using_memory_logger do |logger|
|
555
|
-
output = convert_string input, :doctype => 'inline'
|
556
|
-
assert_nil output
|
557
|
-
assert_message logger, :WARN, '~no inline candidate'
|
558
|
-
end
|
559
|
-
end
|
560
|
-
end
|
561
|
-
end
|
562
|
-
end
|