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/text_test.rb
DELETED
@@ -1,309 +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 "Text" do
|
8
|
-
test "proper encoding to handle utf8 characters in document using html backend" do
|
9
|
-
output = example_document(:encoding).convert
|
10
|
-
assert_xpath '//p', output, 4
|
11
|
-
assert_xpath '//a', output, 1
|
12
|
-
end
|
13
|
-
|
14
|
-
test "proper encoding to handle utf8 characters in embedded document using html backend" do
|
15
|
-
output = example_document(:encoding, :header_footer => false).convert
|
16
|
-
assert_xpath '//p', output, 4
|
17
|
-
assert_xpath '//a', output, 1
|
18
|
-
end
|
19
|
-
|
20
|
-
test "proper encoding to handle utf8 characters in document using docbook45 backend" do
|
21
|
-
output = example_document(:encoding, :attributes => {'backend' => 'docbook45', 'xmlns' => ''}).convert
|
22
|
-
assert_xpath '//xmlns:simpara', output, 4
|
23
|
-
assert_xpath '//xmlns:ulink', output, 1
|
24
|
-
end
|
25
|
-
|
26
|
-
test "proper encoding to handle utf8 characters in embedded document using docbook45 backend" do
|
27
|
-
output = example_document(:encoding, :header_footer => false, :attributes => {'backend' => 'docbook45'}).convert
|
28
|
-
assert_xpath '//simpara', output, 4
|
29
|
-
assert_xpath '//ulink', output, 1
|
30
|
-
end
|
31
|
-
|
32
|
-
# NOTE this test ensures we have the encoding line on block templates too
|
33
|
-
test 'proper encoding to handle utf8 characters in arbitrary block' do
|
34
|
-
input = []
|
35
|
-
input << "[verse]\n"
|
36
|
-
input.concat(File.readlines(sample_doc_path(:encoding)))
|
37
|
-
doc = empty_document
|
38
|
-
reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true
|
39
|
-
block = Asciidoctor::Parser.next_block(reader, doc)
|
40
|
-
assert_xpath '//pre', block.convert.gsub(/^\s*\n/, ''), 1
|
41
|
-
end
|
42
|
-
|
43
|
-
test 'proper encoding to handle utf8 characters from included file' do
|
44
|
-
input = <<-EOS
|
45
|
-
include::fixtures/encoding.asciidoc[tags=romé]
|
46
|
-
EOS
|
47
|
-
doc = empty_safe_document :base_dir => testdir
|
48
|
-
reader = Asciidoctor::PreprocessorReader.new doc, input, nil, :normalize => true
|
49
|
-
block = Asciidoctor::Parser.next_block(reader, doc)
|
50
|
-
output = block.convert
|
51
|
-
assert_css '.paragraph', output, 1
|
52
|
-
end
|
53
|
-
|
54
|
-
test 'escaped text markup' do
|
55
|
-
assert_match(/All your <em>inline<\/em> markup belongs to <strong>us<\/strong>!/,
|
56
|
-
convert_string('All your <em>inline</em> markup belongs to <strong>us</strong>!'))
|
57
|
-
end
|
58
|
-
|
59
|
-
test "line breaks" do
|
60
|
-
assert_xpath "//br", convert_string("Well this is +\njust fine and dandy, isn't it?"), 1
|
61
|
-
end
|
62
|
-
|
63
|
-
test 'single- and double-quoted text' do
|
64
|
-
output = convert_string_to_embedded(%q(``Where?,'' she said, flipping through her copy of `The New Yorker.'), :attributes => {'compat-mode' => ''})
|
65
|
-
assert_match(/“Where\?,”/, output)
|
66
|
-
assert_match(/‘The New Yorker.’/, output)
|
67
|
-
|
68
|
-
output = convert_string_to_embedded(%q("`Where?,`" she said, flipping through her copy of '`The New Yorker.`'))
|
69
|
-
assert_match(/“Where\?,”/, output)
|
70
|
-
assert_match(/‘The New Yorker.’/, output)
|
71
|
-
end
|
72
|
-
|
73
|
-
test 'multiple double-quoted text on a single line' do
|
74
|
-
assert_equal '“Our business is constantly changing” or “We need faster time to market.”',
|
75
|
-
convert_inline_string(%q(``Our business is constantly changing'' or ``We need faster time to market.''), :attributes => {'compat-mode' => ''})
|
76
|
-
assert_equal '“Our business is constantly changing” or “We need faster time to market.”',
|
77
|
-
convert_inline_string(%q("`Our business is constantly changing`" or "`We need faster time to market.`"))
|
78
|
-
end
|
79
|
-
|
80
|
-
test 'horizontal rule' do
|
81
|
-
input = <<-EOS
|
82
|
-
This line is separated by a horizontal rule...
|
83
|
-
|
84
|
-
'''
|
85
|
-
|
86
|
-
...from this line.
|
87
|
-
EOS
|
88
|
-
output = convert_string_to_embedded input
|
89
|
-
assert_xpath "//hr", output, 1
|
90
|
-
assert_xpath "/*[@class='paragraph']", output, 2
|
91
|
-
assert_xpath "(/*[@class='paragraph'])[1]/following-sibling::hr", output, 1
|
92
|
-
assert_xpath "/hr/following-sibling::*[@class='paragraph']", output, 1
|
93
|
-
end
|
94
|
-
|
95
|
-
test 'markdown horizontal rules' do
|
96
|
-
variants = [
|
97
|
-
'---',
|
98
|
-
'- - -',
|
99
|
-
'***',
|
100
|
-
'* * *',
|
101
|
-
'___',
|
102
|
-
'_ _ _'
|
103
|
-
]
|
104
|
-
|
105
|
-
offsets = [
|
106
|
-
'',
|
107
|
-
' ',
|
108
|
-
' ',
|
109
|
-
' '
|
110
|
-
]
|
111
|
-
|
112
|
-
variants.each do |variant|
|
113
|
-
offsets.each do |offset|
|
114
|
-
input = <<-EOS
|
115
|
-
This line is separated by a horizontal rule...
|
116
|
-
|
117
|
-
#{offset}#{variant}
|
118
|
-
|
119
|
-
...from this line.
|
120
|
-
EOS
|
121
|
-
output = convert_string_to_embedded input
|
122
|
-
assert_xpath "//hr", output, 1
|
123
|
-
assert_xpath "/*[@class='paragraph']", output, 2
|
124
|
-
assert_xpath "(/*[@class='paragraph'])[1]/following-sibling::hr", output, 1
|
125
|
-
assert_xpath "/hr/following-sibling::*[@class='paragraph']", output, 1
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
test 'markdown horizontal rules negative case' do
|
131
|
-
|
132
|
-
bad_variants = [
|
133
|
-
'- - - -',
|
134
|
-
'* * * *',
|
135
|
-
'_ _ _ _'
|
136
|
-
]
|
137
|
-
|
138
|
-
good_offsets = [
|
139
|
-
'',
|
140
|
-
' ',
|
141
|
-
' ',
|
142
|
-
' '
|
143
|
-
]
|
144
|
-
|
145
|
-
bad_variants.each do |variant|
|
146
|
-
good_offsets.each do |offset|
|
147
|
-
input = <<-EOS
|
148
|
-
This line is separated by something that is not a horizontal rule...
|
149
|
-
|
150
|
-
#{offset}#{variant}
|
151
|
-
|
152
|
-
...from this line.
|
153
|
-
EOS
|
154
|
-
output = convert_string_to_embedded input
|
155
|
-
assert_xpath '//hr', output, 0
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
good_variants = [
|
160
|
-
'- - -',
|
161
|
-
'* * *',
|
162
|
-
'_ _ _'
|
163
|
-
]
|
164
|
-
|
165
|
-
bad_offsets = [
|
166
|
-
"\t",
|
167
|
-
' '
|
168
|
-
]
|
169
|
-
|
170
|
-
good_variants.each do |variant|
|
171
|
-
bad_offsets.each do |offset|
|
172
|
-
input = <<-EOS
|
173
|
-
This line is separated by something that is not a horizontal rule...
|
174
|
-
|
175
|
-
#{offset}#{variant}
|
176
|
-
|
177
|
-
...from this line.
|
178
|
-
EOS
|
179
|
-
output = convert_string_to_embedded input
|
180
|
-
assert_xpath '//hr', output, 0
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
test "emphasized text using underscore characters" do
|
186
|
-
assert_xpath "//em", convert_string("An _emphatic_ no")
|
187
|
-
end
|
188
|
-
|
189
|
-
test 'emphasized text with single quote using apostrophe characters' do
|
190
|
-
rsquo = decode_char 8217
|
191
|
-
assert_xpath %(//em[text()="Johnny#{rsquo}s"]), convert_string(%q(It's 'Johnny's' phone), :attributes => {'compat-mode' => ''})
|
192
|
-
assert_xpath %(//p[text()="It#{rsquo}s 'Johnny#{rsquo}s' phone"]), convert_string(%q(It's 'Johnny's' phone))
|
193
|
-
end
|
194
|
-
|
195
|
-
test 'emphasized text with escaped single quote using apostrophe characters' do
|
196
|
-
assert_xpath %(//em[text()="Johnny's"]), convert_string(%q(It's 'Johnny\\'s' phone), :attributes => {'compat-mode' => ''})
|
197
|
-
assert_xpath %(//p[text()="It's 'Johnny's' phone"]), convert_string(%q(It\\'s 'Johnny\\'s' phone))
|
198
|
-
end
|
199
|
-
|
200
|
-
test "escaped single quote is restored as single quote" do
|
201
|
-
assert_xpath "//p[contains(text(), \"Let's do it!\")]", convert_string("Let\\'s do it!")
|
202
|
-
end
|
203
|
-
|
204
|
-
test 'unescape escaped single quote emphasis in compat mode only' do
|
205
|
-
assert_xpath %(//p[text()="A 'single quoted string' example"]), convert_string_to_embedded(%(A \\'single quoted string' example), :attributes => {'compat-mode' => ''})
|
206
|
-
assert_xpath %(//p[text()="'single quoted string'"]), convert_string_to_embedded(%(\\'single quoted string'), :attributes => {'compat-mode' => ''})
|
207
|
-
|
208
|
-
assert_xpath %(//p[text()="A \\'single quoted string' example"]), convert_string_to_embedded(%(A \\'single quoted string' example))
|
209
|
-
assert_xpath %(//p[text()="\\'single quoted string'"]), convert_string_to_embedded(%(\\'single quoted string'))
|
210
|
-
end
|
211
|
-
|
212
|
-
test "emphasized text at end of line" do
|
213
|
-
assert_xpath "//em", convert_string("This library is _awesome_")
|
214
|
-
end
|
215
|
-
|
216
|
-
test "emphasized text at beginning of line" do
|
217
|
-
assert_xpath "//em", convert_string("_drop_ it")
|
218
|
-
end
|
219
|
-
|
220
|
-
test "emphasized text across line" do
|
221
|
-
assert_xpath "//em", convert_string("_check it_")
|
222
|
-
end
|
223
|
-
|
224
|
-
test "unquoted text" do
|
225
|
-
refute_match(/#/, convert_string("An #unquoted# word"))
|
226
|
-
end
|
227
|
-
|
228
|
-
test 'backticks and straight quotes in text' do
|
229
|
-
backslash = '\\'
|
230
|
-
assert_equal %q(run <code>foo</code> <em>dog</em>), convert_inline_string(%q(run `foo` 'dog'), :attributes => {'compat-mode' => ''})
|
231
|
-
assert_equal %q(run <code>foo</code> 'dog'), convert_inline_string(%q(run `foo` 'dog'))
|
232
|
-
assert_equal %q(run `foo` 'dog'), convert_inline_string(%(run #{backslash}`foo` 'dog'))
|
233
|
-
assert_equal %q(run ‘foo` 'dog’), convert_inline_string(%q(run '`foo` 'dog`'))
|
234
|
-
assert_equal %q(run '`foo` 'dog`'), convert_inline_string(%(run #{backslash}'`foo` 'dog#{backslash}`'))
|
235
|
-
end
|
236
|
-
|
237
|
-
test 'plus characters inside single plus passthrough' do
|
238
|
-
assert_xpath '//p[text()="+"]', convert_string_to_embedded('+++')
|
239
|
-
assert_xpath '//p[text()="+="]', convert_string_to_embedded('++=+')
|
240
|
-
end
|
241
|
-
|
242
|
-
test 'plus passthrough escapes entity reference' do
|
243
|
-
assert_match(/&#44;/, convert_string_to_embedded('+,+'))
|
244
|
-
assert_match(/one&#44;two/, convert_string_to_embedded('one++,++two'))
|
245
|
-
end
|
246
|
-
|
247
|
-
context "basic styling" do
|
248
|
-
setup do
|
249
|
-
@output = convert_string("A *BOLD* word. An _italic_ word. A `mono` word. ^superscript!^ and some ~subscript~.")
|
250
|
-
end
|
251
|
-
|
252
|
-
test "strong" do
|
253
|
-
assert_xpath "//strong", @output, 1
|
254
|
-
end
|
255
|
-
|
256
|
-
test "italic" do
|
257
|
-
assert_xpath "//em", @output, 1
|
258
|
-
end
|
259
|
-
|
260
|
-
test "monospaced" do
|
261
|
-
assert_xpath "//code", @output, 1
|
262
|
-
end
|
263
|
-
|
264
|
-
test "superscript" do
|
265
|
-
assert_xpath "//sup", @output, 1
|
266
|
-
end
|
267
|
-
|
268
|
-
test "subscript" do
|
269
|
-
assert_xpath "//sub", @output, 1
|
270
|
-
end
|
271
|
-
|
272
|
-
test "passthrough" do
|
273
|
-
assert_xpath "//code", convert_string("This is +passed through+."), 0
|
274
|
-
assert_xpath "//code", convert_string("This is +passed through and monospaced+.", :attributes => {'compat-mode' => ''}), 1
|
275
|
-
end
|
276
|
-
|
277
|
-
test "nested styles" do
|
278
|
-
output = convert_string("Winning *big _time_* in the +city *boyeeee*+.", :attributes => {'compat-mode' => ''})
|
279
|
-
|
280
|
-
assert_xpath "//strong/em", output
|
281
|
-
assert_xpath "//code/strong", output
|
282
|
-
|
283
|
-
output = convert_string("Winning *big _time_* in the `city *boyeeee*`.")
|
284
|
-
|
285
|
-
assert_xpath "//strong/em", output
|
286
|
-
assert_xpath "//code/strong", output
|
287
|
-
end
|
288
|
-
|
289
|
-
test 'unconstrained quotes' do
|
290
|
-
output = convert_string('**B**__I__++M++[role]++M++', :attributes => {'compat-mode' => ''})
|
291
|
-
assert_xpath '//strong', output, 1
|
292
|
-
assert_xpath '//em', output, 1
|
293
|
-
assert_xpath '//code[not(@class)]', output, 1
|
294
|
-
assert_xpath '//code[@class="role"]', output, 1
|
295
|
-
|
296
|
-
output = convert_string('**B**__I__``M``[role]``M``')
|
297
|
-
assert_xpath '//strong', output, 1
|
298
|
-
assert_xpath '//em', output, 1
|
299
|
-
assert_xpath '//code[not(@class)]', output, 1
|
300
|
-
assert_xpath '//code[@class="role"]', output, 1
|
301
|
-
end
|
302
|
-
end
|
303
|
-
|
304
|
-
test 'should format Asian characters as words' do
|
305
|
-
assert_xpath '//strong', (convert_string_to_embedded 'bold *要* bold')
|
306
|
-
assert_xpath '//strong', (convert_string_to_embedded 'bold *素* bold')
|
307
|
-
assert_xpath '//strong', (convert_string_to_embedded 'bold *要素* bold')
|
308
|
-
end
|
309
|
-
end
|