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/links_test.rb
DELETED
@@ -1,855 +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 'Links' do
|
8
|
-
|
9
|
-
test 'qualified url inline with text' do
|
10
|
-
assert_xpath "//a[@href='http://asciidoc.org'][@class='bare'][text() = 'http://asciidoc.org']", convert_string("The AsciiDoc project is located at http://asciidoc.org.")
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'qualified url with role inline with text' do
|
14
|
-
assert_xpath "//a[@href='http://asciidoc.org'][@class='bare project'][text() = 'http://asciidoc.org']", convert_string("The AsciiDoc project is located at http://asciidoc.org[role=project].")
|
15
|
-
end
|
16
|
-
|
17
|
-
test 'qualified http url inline with hide-uri-scheme set' do
|
18
|
-
assert_xpath "//a[@href='http://asciidoc.org'][@class='bare'][text() = 'asciidoc.org']", convert_string("The AsciiDoc project is located at http://asciidoc.org.", :attributes => {'hide-uri-scheme' => ''})
|
19
|
-
end
|
20
|
-
|
21
|
-
test 'qualified file url inline with label' do
|
22
|
-
assert_xpath "//a[@href='file:///home/user/bookmarks.html'][text() = 'My Bookmarks']", convert_string_to_embedded('file:///home/user/bookmarks.html[My Bookmarks]')
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'qualified file url inline with hide-uri-scheme set' do
|
26
|
-
assert_xpath "//a[@href='file:///etc/app.conf'][text() = '/etc/app.conf']", convert_string('Edit the configuration file link:file:///etc/app.conf[]', :attributes => {'hide-uri-scheme' => ''})
|
27
|
-
end
|
28
|
-
|
29
|
-
test 'should not hide bare URI scheme in implicit text of link macro when hide-uri-scheme is set' do
|
30
|
-
{
|
31
|
-
'link:https://[]' => 'https://',
|
32
|
-
'link:ssh://[]' => 'ssh://'
|
33
|
-
}.each do |input, expected|
|
34
|
-
assert_xpath %(/a[text() = "#{expected}"]), (convert_inline_string input, :attributes => { 'hide-uri-scheme' => '' })
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
test 'qualified url with label' do
|
39
|
-
assert_xpath "//a[@href='http://asciidoc.org'][text() = 'AsciiDoc']", convert_string("We're parsing http://asciidoc.org[AsciiDoc] markup")
|
40
|
-
end
|
41
|
-
|
42
|
-
test 'qualified url with label containing escaped right square bracket' do
|
43
|
-
assert_xpath "//a[@href='http://asciidoc.org'][text() = '[Ascii]Doc']", convert_string("We're parsing http://asciidoc.org[[Ascii\\]Doc] markup")
|
44
|
-
end
|
45
|
-
|
46
|
-
test 'qualified url with backslash label' do
|
47
|
-
assert_xpath "//a[@href='https://google.com'][text() = 'Google for \\']", convert_string("I advise you to https://google.com[Google for +\\+]")
|
48
|
-
end
|
49
|
-
|
50
|
-
test 'qualified url with label using link macro' do
|
51
|
-
assert_xpath "//a[@href='http://asciidoc.org'][text() = 'AsciiDoc']", convert_string("We're parsing link:http://asciidoc.org[AsciiDoc] markup")
|
52
|
-
end
|
53
|
-
|
54
|
-
test 'qualified url with role using link macro' do
|
55
|
-
assert_xpath "//a[@href='http://asciidoc.org'][@class='bare project'][text() = 'http://asciidoc.org']", convert_string("We're parsing link:http://asciidoc.org[role=project] markup")
|
56
|
-
end
|
57
|
-
|
58
|
-
test 'qualified url using macro syntax with multi-line label inline with text' do
|
59
|
-
assert_xpath %{//a[@href='http://asciidoc.org'][text() = 'AsciiDoc\nmarkup']}, convert_string("We're parsing link:http://asciidoc.org[AsciiDoc\nmarkup]")
|
60
|
-
end
|
61
|
-
|
62
|
-
test 'qualified url with label containing square brackets using link macro' do
|
63
|
-
str = 'http://example.com[[bracket1\]]'
|
64
|
-
doc = document_from_string str, :header_footer => false, :doctype => 'inline'
|
65
|
-
assert_match '<a href="http://example.com">[bracket1]</a>', doc.convert, 1
|
66
|
-
doc = document_from_string str, :header_footer => false, :backend => 'docbook', :doctype => 'inline'
|
67
|
-
assert_match '<link xl:href="http://example.com">[bracket1]</link>', doc.convert, 1
|
68
|
-
doc = document_from_string str, :header_footer => false, :backend => 'docbook45', :doctype => 'inline'
|
69
|
-
assert_match '<ulink url="http://example.com">[bracket1]</ulink>', doc.convert, 1
|
70
|
-
end
|
71
|
-
|
72
|
-
test 'link macro with empty target' do
|
73
|
-
input = 'Link to link:[this page].'
|
74
|
-
output = convert_string_to_embedded input
|
75
|
-
assert_xpath '//a', output, 1
|
76
|
-
assert_xpath '//a[@href=""]', output, 1
|
77
|
-
end
|
78
|
-
|
79
|
-
test 'should not recognize link macro with double colons' do
|
80
|
-
input = 'The link::http://example.org[example domain] is reserved for tests and documentation.'
|
81
|
-
output = convert_string_to_embedded input
|
82
|
-
assert_includes output, 'link::http://example.org[example domain]'
|
83
|
-
end
|
84
|
-
|
85
|
-
test 'qualified url surrounded by angled brackets' do
|
86
|
-
assert_xpath '//a[@href="http://asciidoc.org"][text()="http://asciidoc.org"]', convert_string('<http://asciidoc.org> is the project page for AsciiDoc.'), 1
|
87
|
-
end
|
88
|
-
|
89
|
-
test 'qualified url surrounded by round brackets' do
|
90
|
-
assert_xpath '//a[@href="http://asciidoc.org"][text()="http://asciidoc.org"]', convert_string('(http://asciidoc.org) is the project page for AsciiDoc.'), 1
|
91
|
-
end
|
92
|
-
|
93
|
-
test 'qualified url with trailing round bracket' do
|
94
|
-
assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', convert_string('Asciidoctor is a Ruby-based AsciiDoc processor (see https://asciidoctor.org)'), 1
|
95
|
-
end
|
96
|
-
|
97
|
-
test 'qualified url with trailing semi-colon' do
|
98
|
-
assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', convert_string('https://asciidoctor.org; where text gets parsed'), 1
|
99
|
-
end
|
100
|
-
|
101
|
-
test 'qualified url with trailing colon' do
|
102
|
-
assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', convert_string('https://asciidoctor.org: where text gets parsed'), 1
|
103
|
-
end
|
104
|
-
|
105
|
-
test 'qualified url in round brackets with trailing colon' do
|
106
|
-
assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', convert_string('(https://asciidoctor.org): where text gets parsed'), 1
|
107
|
-
end
|
108
|
-
|
109
|
-
test 'qualified url with trailing round bracket followed by colon' do
|
110
|
-
result = convert_string_to_embedded '(from https://asciidoctor.org): where text gets parsed'
|
111
|
-
assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', result, 1
|
112
|
-
assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]/preceding-sibling::text()[.="(from "]', result, 1
|
113
|
-
assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]/following-sibling::text()[.="): where text gets parsed"]', result, 1
|
114
|
-
end
|
115
|
-
|
116
|
-
test 'qualified url in round brackets with trailing semi-colon' do
|
117
|
-
assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', convert_string('(https://asciidoctor.org); where text gets parsed'), 1
|
118
|
-
end
|
119
|
-
|
120
|
-
test 'qualified url with trailing round bracket followed by semi-colon' do
|
121
|
-
result = convert_string_to_embedded '(from https://asciidoctor.org); where text gets parsed'
|
122
|
-
assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', result, 1
|
123
|
-
assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]/preceding-sibling::text()[.="(from "]', result, 1
|
124
|
-
assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]/following-sibling::text()[.="); where text gets parsed"]', result, 1
|
125
|
-
end
|
126
|
-
|
127
|
-
test 'URI scheme with trailing characters should not be converted to a link' do
|
128
|
-
input_sources = %w(
|
129
|
-
(https://)
|
130
|
-
http://;
|
131
|
-
file://:
|
132
|
-
<ftp://>
|
133
|
-
)
|
134
|
-
expected_outputs = %w(
|
135
|
-
(https://)
|
136
|
-
http://;
|
137
|
-
file://:
|
138
|
-
<ftp://>
|
139
|
-
)
|
140
|
-
input_sources.each_with_index do |input_source, i|
|
141
|
-
expected_output = expected_outputs[i]
|
142
|
-
actual = block_from_string input_source
|
143
|
-
assert_equal expected_output, actual.content
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
test 'qualified url containing round brackets' do
|
148
|
-
assert_xpath '//a[@href="http://jruby.org/apidocs/org/jruby/Ruby.html#addModule(org.jruby.RubyModule)"][text()="addModule() adds a Ruby module"]', convert_string('http://jruby.org/apidocs/org/jruby/Ruby.html#addModule(org.jruby.RubyModule)[addModule() adds a Ruby module]'), 1
|
149
|
-
end
|
150
|
-
|
151
|
-
test 'qualified url adjacent to text in square brackets' do
|
152
|
-
assert_xpath '//a[@href="http://asciidoc.org"][text()="AsciiDoc"]', convert_string(']http://asciidoc.org[AsciiDoc] project page.'), 1
|
153
|
-
end
|
154
|
-
|
155
|
-
test 'qualified url adjacent to text in round brackets' do
|
156
|
-
assert_xpath '//a[@href="http://asciidoc.org"][text()="AsciiDoc"]', convert_string(')http://asciidoc.org[AsciiDoc] project page.'), 1
|
157
|
-
end
|
158
|
-
|
159
|
-
test 'qualified url following no-break space' do
|
160
|
-
assert_xpath '//a[@href="http://asciidoc.org"][text()="AsciiDoc"]', convert_string(%(#{[0xa0].pack 'U1'}http://asciidoc.org[AsciiDoc] project page.)), 1
|
161
|
-
end if ::RUBY_MIN_VERSION_1_9
|
162
|
-
|
163
|
-
test 'qualified url following smart apostrophe' do
|
164
|
-
output = convert_string_to_embedded("l’http://www.irit.fr[IRIT]")
|
165
|
-
assert_match(/l’<a href=/, output)
|
166
|
-
end
|
167
|
-
|
168
|
-
test 'qualified url using invalid link macro should not create link' do
|
169
|
-
assert_xpath '//a', convert_string('link:http://asciidoc.org is the project page for AsciiDoc.'), 0
|
170
|
-
end
|
171
|
-
|
172
|
-
test 'escaped inline qualified url should not create link' do
|
173
|
-
assert_xpath '//a', convert_string('\http://asciidoc.org is the project page for AsciiDoc.'), 0
|
174
|
-
end
|
175
|
-
|
176
|
-
test 'url in link macro with at (@) sign should not create mailto link' do
|
177
|
-
assert_xpath '//a[@href="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"][text()="subscribe"]', convert_string('http://xircles.codehaus.org/lists/dev@geb.codehaus.org[subscribe]')
|
178
|
-
end
|
179
|
-
|
180
|
-
test 'implicit url with at (@) sign should not create mailto link' do
|
181
|
-
assert_xpath '//a[@href="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"][text()="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"]', convert_string('http://xircles.codehaus.org/lists/dev@geb.codehaus.org')
|
182
|
-
end
|
183
|
-
|
184
|
-
test 'escaped inline qualified url using macro syntax should not create link' do
|
185
|
-
assert_xpath '//a', convert_string('\http://asciidoc.org[AsciiDoc] is the key to good docs.'), 0
|
186
|
-
end
|
187
|
-
|
188
|
-
test 'inline qualified url followed by an endline should not include endline in link' do
|
189
|
-
assert_xpath '//a[@href="https://github.com/asciidoctor"]', convert_string("The source code for Asciidoctor can be found at https://github.com/asciidoctor\nwhich is a GitHub organization."), 1
|
190
|
-
end
|
191
|
-
|
192
|
-
test 'qualified url divided by endline using macro syntax should not create link' do
|
193
|
-
assert_xpath '//a', convert_string("The source code for Asciidoctor can be found at link:https://github.com/asciidoctor\n[]which is a GitHub organization."), 0
|
194
|
-
end
|
195
|
-
|
196
|
-
test 'qualified url containing whitespace using macro syntax should not create link' do
|
197
|
-
assert_xpath '//a', convert_string('I often need to refer to the chapter on link:http://asciidoc.org?q=attribute references[Attribute References].'), 0
|
198
|
-
end
|
199
|
-
|
200
|
-
test 'qualified url containing an encoded space using macro syntax should create a link' do
|
201
|
-
assert_xpath '//a', convert_string('I often need to refer to the chapter on link:http://asciidoc.org?q=attribute%20references[Attribute References].'), 1
|
202
|
-
end
|
203
|
-
|
204
|
-
test 'inline quoted qualified url should not consume surrounding angled brackets' do
|
205
|
-
assert_xpath '//a[@href="https://github.com/asciidoctor"]', convert_string('Asciidoctor GitHub organization: <**https://github.com/asciidoctor**>'), 1
|
206
|
-
end
|
207
|
-
|
208
|
-
test 'link with quoted text should not be separated into attributes when text contains an equal sign' do
|
209
|
-
assert_xpath '//a[@href="http://search.example.com"][text()="Google, Yahoo, Bing = Search Engines"]', convert_string_to_embedded('http://search.example.com["Google, Yahoo, Bing = Search Engines"]'), 1
|
210
|
-
end
|
211
|
-
|
212
|
-
test 'link with quoted text but no equal sign should carry quotes over to output' do
|
213
|
-
assert_xpath %(//a[@href="http://search.example.com"][text()='"Google, Yahoo, Bing"']), convert_string_to_embedded('http://search.example.com["Google, Yahoo, Bing"]'), 1
|
214
|
-
end
|
215
|
-
|
216
|
-
test 'link with comma in text but no equal sign should not be separated into attributes' do
|
217
|
-
assert_xpath '//a[@href="http://search.example.com"][text()="Google, Yahoo, Bing"]', convert_string_to_embedded('http://search.example.com[Google, Yahoo, Bing]'), 1
|
218
|
-
end
|
219
|
-
|
220
|
-
test 'role and window attributes on link are processed' do
|
221
|
-
assert_xpath '//a[@href="http://google.com"][@class="external"][@target="_blank"]', convert_string_to_embedded('http://google.com[Google, role=external, window="_blank"]'), 1
|
222
|
-
end
|
223
|
-
|
224
|
-
test 'link macro with attributes but no text should use URL as text' do
|
225
|
-
url = 'https://fonts.googleapis.com/css?family=Roboto:400,400italic,'
|
226
|
-
assert_xpath %(//a[@href="#{url}"][text()="#{url}"]), convert_string_to_embedded(%(link:#{url}[family=Roboto,weight=400])), 1
|
227
|
-
end
|
228
|
-
|
229
|
-
test 'link macro with attributes but blank text should use URL as text' do
|
230
|
-
url = 'https://fonts.googleapis.com/css?family=Roboto:400,400italic,'
|
231
|
-
assert_xpath %(//a[@href="#{url}"][text()="#{url}"]), convert_string_to_embedded(%(link:#{url}[,family=Roboto,weight=400])), 1
|
232
|
-
end
|
233
|
-
|
234
|
-
test 'link macro with comma but no explicit attributes in text should not parse text' do
|
235
|
-
url = 'https://fonts.googleapis.com/css?family=Roboto:400,400italic,'
|
236
|
-
assert_xpath %(//a[@href="#{url}"][text()="Roboto,400"]), convert_string_to_embedded(%(link:#{url}[Roboto,400])), 1
|
237
|
-
end
|
238
|
-
|
239
|
-
test 'link text that ends in ^ should set link window to _blank' do
|
240
|
-
assert_xpath '//a[@href="http://google.com"][@target="_blank"]', convert_string_to_embedded('http://google.com[Google^]'), 1
|
241
|
-
end
|
242
|
-
|
243
|
-
test 'rel=noopener should be added to a link that targets the _blank window' do
|
244
|
-
assert_xpath '//a[@href="http://google.com"][@target="_blank"][@rel="noopener"]', convert_string_to_embedded('http://google.com[Google^]'), 1
|
245
|
-
end
|
246
|
-
|
247
|
-
test 'rel=noopener should be added to a link that targets a named window when the noopener option is set' do
|
248
|
-
assert_xpath '//a[@href="http://google.com"][@target="name"][@rel="noopener"]', convert_string_to_embedded('http://google.com[Google,window=name,opts=noopener]'), 1
|
249
|
-
end
|
250
|
-
|
251
|
-
test 'rel=noopener should not be added to a link if it does not target a window' do
|
252
|
-
result = convert_string_to_embedded 'http://google.com[Google,opts=noopener]'
|
253
|
-
assert_xpath '//a[@href="http://google.com"]', result, 1
|
254
|
-
assert_xpath '//a[@href="http://google.com"][@rel="noopener"]', result, 0
|
255
|
-
end
|
256
|
-
|
257
|
-
test 'rel=nofollow should be added to a link when the nofollow option is set' do
|
258
|
-
assert_xpath '//a[@href="http://google.com"][@target="name"][@rel="nofollow noopener"]', convert_string_to_embedded('http://google.com[Google,window=name,opts="nofollow,noopener"]'), 1
|
259
|
-
end
|
260
|
-
|
261
|
-
test 'id attribute on link is processed' do
|
262
|
-
assert_xpath '//a[@href="http://google.com"][@id="link-1"]', convert_string_to_embedded('http://google.com[Google, id="link-1"]'), 1
|
263
|
-
end
|
264
|
-
|
265
|
-
test 'title attribute on link is processed' do
|
266
|
-
assert_xpath '//a[@href="http://google.com"][@title="title-1"]', convert_string_to_embedded('http://google.com[Google, title="title-1"]'), 1
|
267
|
-
end
|
268
|
-
|
269
|
-
test 'inline irc link' do
|
270
|
-
assert_xpath '//a[@href="irc://irc.freenode.net"][text()="irc://irc.freenode.net"]', convert_string_to_embedded('irc://irc.freenode.net'), 1
|
271
|
-
end
|
272
|
-
|
273
|
-
test 'inline irc link with text' do
|
274
|
-
assert_xpath '//a[@href="irc://irc.freenode.net"][text()="Freenode IRC"]', convert_string_to_embedded('irc://irc.freenode.net[Freenode IRC]'), 1
|
275
|
-
end
|
276
|
-
|
277
|
-
test 'inline ref' do
|
278
|
-
variations = %w([[tigers]] anchor:tigers[])
|
279
|
-
variations.each do |anchor|
|
280
|
-
doc = document_from_string %(Here you can read about tigers.#{anchor})
|
281
|
-
output = doc.convert
|
282
|
-
assert_equal '[tigers]', doc.catalog[:ids]['tigers']
|
283
|
-
assert_kind_of Asciidoctor::Inline, doc.catalog[:refs]['tigers']
|
284
|
-
assert_nil doc.catalog[:refs]['tigers'].text
|
285
|
-
assert_xpath '//a[@id = "tigers"]', output, 1
|
286
|
-
assert_xpath '//a[@id = "tigers"]/child::text()', output, 0
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
test 'escaped inline ref' do
|
291
|
-
variations = %w([[tigers]] anchor:tigers[])
|
292
|
-
variations.each do |anchor|
|
293
|
-
doc = document_from_string %(Here you can read about tigers.\\#{anchor})
|
294
|
-
output = doc.convert
|
295
|
-
refute doc.catalog[:ids].key?('tigers')
|
296
|
-
refute doc.catalog[:refs].key?('tigers')
|
297
|
-
assert_xpath '//a[@id = "tigers"]', output, 0
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
|
-
test 'inline ref can start with colon' do
|
302
|
-
input = '[[:idname]] text'
|
303
|
-
output = convert_string_to_embedded input
|
304
|
-
assert_xpath '//a[@id = ":idname"]', output, 1
|
305
|
-
end
|
306
|
-
|
307
|
-
test 'inline ref cannot start with digit' do
|
308
|
-
input = '[[1-install]] text'
|
309
|
-
output = convert_string_to_embedded input
|
310
|
-
assert_includes output, '[[1-install]]'
|
311
|
-
assert_xpath '//a[@id = "1-install"]', output, 0
|
312
|
-
end
|
313
|
-
|
314
|
-
test 'inline ref with reftext' do
|
315
|
-
%w([[tigers,Tigers]] anchor:tigers[Tigers]).each do |anchor|
|
316
|
-
doc = document_from_string %(Here you can read about tigers.#{anchor})
|
317
|
-
output = doc.convert
|
318
|
-
assert_equal 'Tigers', doc.catalog[:ids]['tigers']
|
319
|
-
assert_kind_of Asciidoctor::Inline, doc.catalog[:refs]['tigers']
|
320
|
-
assert_equal 'Tigers', doc.catalog[:refs]['tigers'].text
|
321
|
-
assert_xpath '//a[@id = "tigers"]', output, 1
|
322
|
-
assert_xpath '//a[@id = "tigers"]/child::text()', output, 0
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
test 'should encode double quotes in reftext of anchor macro in DocBook output' do
|
327
|
-
input = 'anchor:uncola[the "un"-cola]'
|
328
|
-
result = convert_inline_string input, :backend => :docbook
|
329
|
-
assert_equal '<anchor xml:id="uncola" xreflabel="the "un"-cola"/>', result
|
330
|
-
end
|
331
|
-
|
332
|
-
test 'should substitute attribute references in reftext when registering inline ref' do
|
333
|
-
%w([[tigers,{label-tigers}]] anchor:tigers[{label-tigers}]).each do |anchor|
|
334
|
-
doc = document_from_string %(Here you can read about tigers.#{anchor}), :attributes => { 'label-tigers' => 'Tigers' }
|
335
|
-
doc.convert
|
336
|
-
assert_kind_of Asciidoctor::Inline, doc.catalog[:refs]['tigers']
|
337
|
-
assert_equal 'Tigers', doc.catalog[:refs]['tigers'].text
|
338
|
-
assert_equal 'Tigers', doc.catalog[:ids]['tigers']
|
339
|
-
end
|
340
|
-
end
|
341
|
-
|
342
|
-
test 'inline ref with reftext converted to DocBook' do
|
343
|
-
%w([[tigers,<Tigers>]] anchor:tigers[<Tigers>]).each do |anchor|
|
344
|
-
doc = document_from_string %(Here you can read about tigers.#{anchor}), :backend => :docbook45
|
345
|
-
output = doc.convert :header_footer => false
|
346
|
-
assert_kind_of Asciidoctor::Inline, doc.catalog[:refs]['tigers']
|
347
|
-
assert_equal '<Tigers>', doc.catalog[:refs]['tigers'].text
|
348
|
-
assert_equal '<Tigers>', doc.references[:ids]['tigers']
|
349
|
-
assert_includes output, '<anchor id="tigers" xreflabel="<Tigers>"/>'
|
350
|
-
end
|
351
|
-
end
|
352
|
-
|
353
|
-
test 'does not match bibliography anchor in prose when scanning for inline anchor' do
|
354
|
-
doc = document_from_string 'Use [[[label]]] to assign a label to a bibliography entry.'
|
355
|
-
refute doc.catalog[:ids].key?('label')
|
356
|
-
refute doc.catalog[:refs].key?('label')
|
357
|
-
end
|
358
|
-
|
359
|
-
test 'repeating inline anchor macro with empty reftext' do
|
360
|
-
input = 'anchor:one[] anchor:two[] anchor:three[]'
|
361
|
-
result = convert_inline_string input
|
362
|
-
assert_equal '<a id="one"></a> <a id="two"></a> <a id="three"></a>', result
|
363
|
-
end
|
364
|
-
|
365
|
-
test 'mixed inline anchor macro and anchor shorthand with empty reftext' do
|
366
|
-
input = 'anchor:one[][[two]]anchor:three[][[four]]anchor:five[]'
|
367
|
-
result = convert_inline_string input
|
368
|
-
assert_equal '<a id="one"></a><a id="two"></a><a id="three"></a><a id="four"></a><a id="five"></a>', result
|
369
|
-
end
|
370
|
-
|
371
|
-
test 'assigns xreflabel value for anchor macro without reftext in DocBook output' do
|
372
|
-
input = 'anchor:foo[]'
|
373
|
-
result = convert_inline_string input, :backend => :docbook
|
374
|
-
assert_equal '<anchor xml:id="foo" xreflabel="[foo]"/>', result
|
375
|
-
end
|
376
|
-
|
377
|
-
test 'unescapes square bracket in reftext of anchor macro' do
|
378
|
-
input = 'see <<foo>>
|
379
|
-
|
380
|
-
anchor:foo[b[a\]r]text'
|
381
|
-
result = convert_string_to_embedded input
|
382
|
-
assert_includes result, 'see <a href="#foo">b[a]r</a>'
|
383
|
-
end
|
384
|
-
|
385
|
-
test 'unescapes square bracket in reftext of anchor macro in DocBook output' do
|
386
|
-
input = 'anchor:foo[b[a\]r]'
|
387
|
-
result = convert_inline_string input, :backend => :docbook
|
388
|
-
assert_equal '<anchor xml:id="foo" xreflabel="b[a]r"/>', result
|
389
|
-
end
|
390
|
-
|
391
|
-
test 'xref using angled bracket syntax' do
|
392
|
-
doc = document_from_string '<<tigers>>'
|
393
|
-
doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, '[tigers]', :type => :ref, :target => 'tigers'), '[tigers]']
|
394
|
-
assert_xpath '//a[@href="#tigers"][text() = "[tigers]"]', doc.convert, 1
|
395
|
-
end
|
396
|
-
|
397
|
-
test 'xref using angled bracket syntax with explicit hash' do
|
398
|
-
doc = document_from_string '<<#tigers>>'
|
399
|
-
doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, 'Tigers', :type => :ref, :target => 'tigers'), 'Tigers']
|
400
|
-
assert_xpath '//a[@href="#tigers"][text() = "Tigers"]', doc.convert, 1
|
401
|
-
end
|
402
|
-
|
403
|
-
test 'xref using angled bracket syntax with label' do
|
404
|
-
input = <<-EOS
|
405
|
-
<<tigers,About Tigers>>
|
406
|
-
|
407
|
-
[#tigers]
|
408
|
-
== Tigers
|
409
|
-
EOS
|
410
|
-
assert_xpath '//a[@href="#tigers"][text() = "About Tigers"]', convert_string(input), 1
|
411
|
-
end
|
412
|
-
|
413
|
-
test 'xref using angled bracket syntax with quoted label' do
|
414
|
-
input = <<-EOS
|
415
|
-
<<tigers,"About Tigers">>
|
416
|
-
|
417
|
-
[#tigers]
|
418
|
-
== Tigers
|
419
|
-
EOS
|
420
|
-
assert_xpath %q(//a[@href="#tigers"][text() = '"About Tigers"']), convert_string(input), 1
|
421
|
-
end
|
422
|
-
|
423
|
-
test 'should not interpret path sans extension in xref with angled bracket syntax in compat mode' do
|
424
|
-
using_memory_logger do |logger|
|
425
|
-
doc = document_from_string '<<tigers#>>', :header_footer => false, :attributes => { 'compat-mode' => '' }
|
426
|
-
assert_xpath '//a[@href="#tigers#"][text() = "[tigers#]"]', doc.convert, 1
|
427
|
-
end
|
428
|
-
end
|
429
|
-
|
430
|
-
test 'xref using angled bracket syntax with path sans extension' do
|
431
|
-
doc = document_from_string '<<tigers#>>', :header_footer => false
|
432
|
-
assert_xpath '//a[@href="tigers.html"][text() = "tigers.html"]', doc.convert, 1
|
433
|
-
end
|
434
|
-
|
435
|
-
test 'inter-document xref should not add suffix to path with a non-AsciiDoc extension' do
|
436
|
-
{
|
437
|
-
'using-.net-web-services' => 'Using .NET web services',
|
438
|
-
'../file.pdf' => 'Download the .pdf file'
|
439
|
-
}.each do |path, text|
|
440
|
-
result = convert_string_to_embedded %(<<#{path}#,#{text}>>)
|
441
|
-
assert_xpath %(//a[@href="#{path}"][text() = "#{text}"]), result, 1
|
442
|
-
end
|
443
|
-
end
|
444
|
-
|
445
|
-
test 'inter-document xref should only remove the file extension part if the path contains a period elsewhere' do
|
446
|
-
result = convert_string_to_embedded '<<using-.net-web-services.adoc#,Using .NET web services>>'
|
447
|
-
assert_xpath '//a[@href="using-.net-web-services.html"][text() = "Using .NET web services"]', result, 1
|
448
|
-
end
|
449
|
-
|
450
|
-
test 'xref using angled bracket syntax with path sans extension using docbook backend' do
|
451
|
-
doc = document_from_string '<<tigers#>>', :header_footer => false, :backend => 'docbook'
|
452
|
-
assert_match '<link xl:href="tigers.xml">tigers.xml</link>', doc.convert, 1
|
453
|
-
doc = document_from_string '<<tigers#>>', :header_footer => false, :backend => 'docbook45'
|
454
|
-
assert_match '<ulink url="tigers.xml">tigers.xml</ulink>', doc.convert, 1
|
455
|
-
end
|
456
|
-
|
457
|
-
test 'xref using angled bracket syntax with ancestor path sans extension' do
|
458
|
-
doc = document_from_string '<<../tigers#,tigers>>', :header_footer => false
|
459
|
-
assert_xpath '//a[@href="../tigers.html"][text() = "tigers"]', doc.convert, 1
|
460
|
-
end
|
461
|
-
|
462
|
-
test 'xref using angled bracket syntax with absolute path sans extension' do
|
463
|
-
doc = document_from_string '<</path/to/tigers#,tigers>>', :header_footer => false
|
464
|
-
assert_xpath '//a[@href="/path/to/tigers.html"][text() = "tigers"]', doc.convert, 1
|
465
|
-
end
|
466
|
-
|
467
|
-
test 'xref using angled bracket syntax with path and extension' do
|
468
|
-
using_memory_logger do |logger|
|
469
|
-
doc = document_from_string '<<tigers.adoc>>', :header_footer => false
|
470
|
-
assert_xpath '//a[@href="#tigers.adoc"][text() = "[tigers.adoc]"]', doc.convert, 1
|
471
|
-
end
|
472
|
-
end
|
473
|
-
|
474
|
-
test 'xref using angled bracket syntax with path and extension with hash' do
|
475
|
-
doc = document_from_string '<<tigers.adoc#>>', :header_footer => false
|
476
|
-
assert_xpath '//a[@href="tigers.html"][text() = "tigers.html"]', doc.convert, 1
|
477
|
-
end
|
478
|
-
|
479
|
-
test 'xref using angled bracket syntax with path and extension with fragment' do
|
480
|
-
doc = document_from_string '<<tigers.adoc#id>>', :header_footer => false
|
481
|
-
assert_xpath '//a[@href="tigers.html#id"][text() = "tigers.html"]', doc.convert, 1
|
482
|
-
end
|
483
|
-
|
484
|
-
test 'xref using macro syntax with path and extension in compat mode' do
|
485
|
-
using_memory_logger do |logger|
|
486
|
-
doc = document_from_string 'xref:tigers.adoc[]', :header_footer => false, :attributes => { 'compat-mode' => '' }
|
487
|
-
assert_xpath '//a[@href="#tigers.adoc"][text() = "[tigers.adoc]"]', doc.convert, 1
|
488
|
-
end
|
489
|
-
end
|
490
|
-
|
491
|
-
test 'xref using macro syntax with path and extension' do
|
492
|
-
doc = document_from_string 'xref:tigers.adoc[]', :header_footer => false
|
493
|
-
assert_xpath '//a[@href="tigers.html"][text() = "tigers.html"]', doc.convert, 1
|
494
|
-
end
|
495
|
-
|
496
|
-
test 'xref using angled bracket syntax with path and fragment' do
|
497
|
-
doc = document_from_string '<<tigers#about>>', :header_footer => false
|
498
|
-
assert_xpath '//a[@href="tigers.html#about"][text() = "tigers.html"]', doc.convert, 1
|
499
|
-
end
|
500
|
-
|
501
|
-
test 'xref using angled bracket syntax with path, fragment and text' do
|
502
|
-
doc = document_from_string '<<tigers#about,About Tigers>>', :header_footer => false
|
503
|
-
assert_xpath '//a[@href="tigers.html#about"][text() = "About Tigers"]', doc.convert, 1
|
504
|
-
end
|
505
|
-
|
506
|
-
test 'xref using angled bracket syntax with path and custom relfilesuffix and outfilesuffix' do
|
507
|
-
attributes = {'relfileprefix' => '../', 'outfilesuffix' => '/'}
|
508
|
-
doc = document_from_string '<<tigers#about,About Tigers>>', :header_footer => false, :attributes => attributes
|
509
|
-
assert_xpath '//a[@href="../tigers/#about"][text() = "About Tigers"]', doc.convert, 1
|
510
|
-
end
|
511
|
-
|
512
|
-
test 'xref using angled bracket syntax with path and custom relfilesuffix' do
|
513
|
-
attributes = { 'relfilesuffix' => '/' }
|
514
|
-
doc = document_from_string '<<tigers#about,About Tigers>>', :header_footer => false, :attributes => attributes
|
515
|
-
assert_xpath '//a[@href="tigers/#about"][text() = "About Tigers"]', doc.convert, 1
|
516
|
-
end
|
517
|
-
|
518
|
-
test 'xref using angled bracket syntax with path which has been included in this document' do
|
519
|
-
using_memory_logger do |logger|
|
520
|
-
in_verbose_mode do
|
521
|
-
doc = document_from_string '<<tigers#about,About Tigers>>', :header_footer => false
|
522
|
-
doc.catalog[:includes]['tigers'] = true
|
523
|
-
output = doc.convert
|
524
|
-
assert_xpath '//a[@href="#about"][text() = "About Tigers"]', output, 1
|
525
|
-
assert_message logger, :WARN, 'invalid reference: about'
|
526
|
-
end
|
527
|
-
end
|
528
|
-
end
|
529
|
-
|
530
|
-
test 'xref using angled bracket syntax with nested path which has been included in this document' do
|
531
|
-
using_memory_logger do |logger|
|
532
|
-
in_verbose_mode do
|
533
|
-
doc = document_from_string '<<part1/tigers#about,About Tigers>>', :header_footer => false
|
534
|
-
doc.catalog[:includes]['part1/tigers'] = true
|
535
|
-
output = doc.convert
|
536
|
-
assert_xpath '//a[@href="#about"][text() = "About Tigers"]', output, 1
|
537
|
-
assert_message logger, :WARN, 'invalid reference: about'
|
538
|
-
end
|
539
|
-
end
|
540
|
-
end
|
541
|
-
|
542
|
-
test 'xref using angled bracket syntax inline with text' do
|
543
|
-
input = <<-EOS
|
544
|
-
Want to learn <<tigers,about tigers>>?
|
545
|
-
|
546
|
-
[#tigers]
|
547
|
-
== Tigers
|
548
|
-
EOS
|
549
|
-
assert_xpath '//a[@href="#tigers"][text() = "about tigers"]', convert_string(input), 1
|
550
|
-
end
|
551
|
-
|
552
|
-
test 'xref using angled bracket syntax with multi-line label inline with text' do
|
553
|
-
input = <<-EOS
|
554
|
-
Want to learn <<tigers,about
|
555
|
-
tigers>>?
|
556
|
-
|
557
|
-
[#tigers]
|
558
|
-
== Tigers
|
559
|
-
EOS
|
560
|
-
assert_xpath %{//a[@href="#tigers"][normalize-space(text()) = "about tigers"]}, convert_string(input), 1
|
561
|
-
end
|
562
|
-
|
563
|
-
test 'xref with escaped text' do
|
564
|
-
# when \x0 was used as boundary character for passthrough, it was getting stripped
|
565
|
-
# now using unicode marks as boundary characters, which resolves issue
|
566
|
-
input = <<-EOS
|
567
|
-
See the <<tigers, `+[tigers]+`>> section for details about tigers.
|
568
|
-
|
569
|
-
[#tigers]
|
570
|
-
== Tigers
|
571
|
-
EOS
|
572
|
-
output = convert_string_to_embedded input
|
573
|
-
assert_xpath %(//a[@href="#tigers"]/code[text()="[tigers]"]), output, 1
|
574
|
-
end
|
575
|
-
|
576
|
-
test 'xref with target that begins with attribute reference in title' do
|
577
|
-
['<<{lessonsdir}/lesson-1#,Lesson 1>>', 'xref:{lessonsdir}/lesson-1#[Lesson 1]'].each do |xref|
|
578
|
-
input = <<-EOS
|
579
|
-
:lessonsdir: lessons
|
580
|
-
|
581
|
-
[#lesson-1-listing]
|
582
|
-
== #{xref}
|
583
|
-
|
584
|
-
A summary of the first lesson.
|
585
|
-
EOS
|
586
|
-
|
587
|
-
output = convert_string_to_embedded input
|
588
|
-
assert_xpath '//h2/a[@href="lessons/lesson-1.html"]', output, 1
|
589
|
-
end
|
590
|
-
end
|
591
|
-
|
592
|
-
test 'xref using macro syntax' do
|
593
|
-
doc = document_from_string 'xref:tigers[]'
|
594
|
-
doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, '[tigers]', :type => :ref, :target => 'tigers'), '[tigers]']
|
595
|
-
assert_xpath '//a[@href="#tigers"][text() = "[tigers]"]', doc.convert, 1
|
596
|
-
end
|
597
|
-
|
598
|
-
test 'multiple xref macros with implicit text in single line' do
|
599
|
-
input = <<-EOS
|
600
|
-
This document has two sections, xref:sect-a[] and xref:sect-b[].
|
601
|
-
|
602
|
-
[#sect-a]
|
603
|
-
== Section A
|
604
|
-
|
605
|
-
[#sect-b]
|
606
|
-
== Section B
|
607
|
-
EOS
|
608
|
-
result = convert_string_to_embedded input
|
609
|
-
assert_xpath '//a[@href="#sect-a"][text() = "Section A"]', result, 1
|
610
|
-
assert_xpath '//a[@href="#sect-b"][text() = "Section B"]', result, 1
|
611
|
-
end
|
612
|
-
|
613
|
-
test 'xref using macro syntax with explicit hash' do
|
614
|
-
doc = document_from_string 'xref:#tigers[]'
|
615
|
-
doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, 'Tigers', :type => :ref, :target => 'tigers'), 'Tigers']
|
616
|
-
assert_xpath '//a[@href="#tigers"][text() = "Tigers"]', doc.convert, 1
|
617
|
-
end
|
618
|
-
|
619
|
-
test 'xref using macro syntax with label' do
|
620
|
-
input = <<-EOS
|
621
|
-
xref:tigers[About Tigers]
|
622
|
-
|
623
|
-
[#tigers]
|
624
|
-
== Tigers
|
625
|
-
EOS
|
626
|
-
assert_xpath '//a[@href="#tigers"][text() = "About Tigers"]', convert_string(input), 1
|
627
|
-
end
|
628
|
-
|
629
|
-
test 'xref using macro syntax inline with text' do
|
630
|
-
input = <<-EOS
|
631
|
-
Want to learn xref:tigers[about tigers]?
|
632
|
-
|
633
|
-
[#tigers]
|
634
|
-
== Tigers
|
635
|
-
EOS
|
636
|
-
|
637
|
-
assert_xpath '//a[@href="#tigers"][text() = "about tigers"]', convert_string(input), 1
|
638
|
-
end
|
639
|
-
|
640
|
-
test 'xref using macro syntax with multi-line label inline with text' do
|
641
|
-
input = <<-EOS
|
642
|
-
Want to learn xref:tigers[about
|
643
|
-
tigers]?
|
644
|
-
|
645
|
-
[#tigers]
|
646
|
-
== Tigers
|
647
|
-
EOS
|
648
|
-
assert_xpath %{//a[@href="#tigers"][normalize-space(text()) = "about tigers"]}, convert_string(input), 1
|
649
|
-
end
|
650
|
-
|
651
|
-
test 'xref using macro syntax with text that ends with an escaped closing bracket' do
|
652
|
-
input = <<-EOS
|
653
|
-
xref:tigers[[tigers\\]]
|
654
|
-
|
655
|
-
[#tigers]
|
656
|
-
== Tigers
|
657
|
-
EOS
|
658
|
-
assert_xpath '//a[@href="#tigers"][text() = "[tigers]"]', convert_string_to_embedded(input), 1
|
659
|
-
end
|
660
|
-
|
661
|
-
test 'xref using macro syntax with text that contains an escaped closing bracket' do
|
662
|
-
input = <<-EOS
|
663
|
-
xref:tigers[[tigers\\] are cats]
|
664
|
-
|
665
|
-
[#tigers]
|
666
|
-
== Tigers
|
667
|
-
EOS
|
668
|
-
assert_xpath '//a[@href="#tigers"][text() = "[tigers] are cats"]', convert_string_to_embedded(input), 1
|
669
|
-
end
|
670
|
-
|
671
|
-
test 'unescapes square bracket in reftext used by xref' do
|
672
|
-
input = 'anchor:foo[b[a\]r]about
|
673
|
-
|
674
|
-
see <<foo>>'
|
675
|
-
result = convert_string_to_embedded input
|
676
|
-
assert_xpath '//a[@href="#foo"]', result, 1
|
677
|
-
assert_xpath '//a[@href="#foo"][text()="b[a]r"]', result, 1
|
678
|
-
end
|
679
|
-
|
680
|
-
test 'xref using invalid macro syntax does not create link' do
|
681
|
-
doc = document_from_string 'xref:tigers'
|
682
|
-
doc.register :refs, ['tigers', (Asciidoctor::Inline.new doc, :anchor, 'Tigers', :type => :ref, :target => 'tigers'), 'Tigers']
|
683
|
-
assert_xpath '//a', doc.convert, 0
|
684
|
-
end
|
685
|
-
|
686
|
-
test 'should warn and create link if verbose flag is set and reference is not found' do
|
687
|
-
input = <<-EOS
|
688
|
-
[#foobar]
|
689
|
-
== Foobar
|
690
|
-
|
691
|
-
== Section B
|
692
|
-
|
693
|
-
See <<foobaz>>.
|
694
|
-
EOS
|
695
|
-
using_memory_logger do |logger|
|
696
|
-
in_verbose_mode do
|
697
|
-
output = convert_string_to_embedded input
|
698
|
-
assert_xpath '//a[@href="#foobaz"][text() = "[foobaz]"]', output, 1
|
699
|
-
assert_message logger, :WARN, 'invalid reference: foobaz'
|
700
|
-
end
|
701
|
-
end
|
702
|
-
end
|
703
|
-
|
704
|
-
test 'should warn and create link if verbose flag is set and reference using # notation is not found' do
|
705
|
-
input = <<-EOS
|
706
|
-
[#foobar]
|
707
|
-
== Foobar
|
708
|
-
|
709
|
-
== Section B
|
710
|
-
|
711
|
-
See <<#foobaz>>.
|
712
|
-
EOS
|
713
|
-
using_memory_logger do |logger|
|
714
|
-
in_verbose_mode do
|
715
|
-
output = convert_string_to_embedded input
|
716
|
-
assert_xpath '//a[@href="#foobaz"][text() = "[foobaz]"]', output, 1
|
717
|
-
assert_message logger, :WARN, 'invalid reference: foobaz'
|
718
|
-
end
|
719
|
-
end
|
720
|
-
end
|
721
|
-
|
722
|
-
test 'should produce an internal anchor from an inter-document xref to file included into current file' do
|
723
|
-
input = <<-'EOS'
|
724
|
-
= Book Title
|
725
|
-
:doctype: book
|
726
|
-
|
727
|
-
[#ch1]
|
728
|
-
== Chapter 1
|
729
|
-
|
730
|
-
So it begins.
|
731
|
-
|
732
|
-
Read <<other-chapters.adoc#ch2>> to find out what happens next!
|
733
|
-
|
734
|
-
include::other-chapters.adoc[]
|
735
|
-
EOS
|
736
|
-
|
737
|
-
doc = document_from_string input, :safe => :safe, :base_dir => fixturedir
|
738
|
-
assert doc.catalog[:includes].key?('other-chapters')
|
739
|
-
assert doc.catalog[:includes]['other-chapters']
|
740
|
-
output = doc.convert
|
741
|
-
assert_xpath '//a[@href="#ch2"][text()="Chapter 2"]', output, 1
|
742
|
-
end
|
743
|
-
|
744
|
-
test 'should produce an internal anchor from an inter-document xref to file included entirely into current file using tags' do
|
745
|
-
input = <<-'EOS'
|
746
|
-
= Book Title
|
747
|
-
:doctype: book
|
748
|
-
|
749
|
-
[#ch1]
|
750
|
-
== Chapter 1
|
751
|
-
|
752
|
-
So it begins.
|
753
|
-
|
754
|
-
Read <<other-chapters.adoc#ch2>> to find out what happens next!
|
755
|
-
|
756
|
-
include::other-chapters.adoc[tags=**]
|
757
|
-
EOS
|
758
|
-
|
759
|
-
output = convert_string_to_embedded input, :safe => :safe, :base_dir => fixturedir
|
760
|
-
assert_xpath '//a[@href="#ch2"][text()="Chapter 2"]', output, 1
|
761
|
-
end
|
762
|
-
|
763
|
-
test 'should not produce an internal anchor for inter-document xref to file partially included into current file' do
|
764
|
-
input = <<-'EOS'
|
765
|
-
= Book Title
|
766
|
-
:doctype: book
|
767
|
-
|
768
|
-
[#ch1]
|
769
|
-
== Chapter 1
|
770
|
-
|
771
|
-
So it begins.
|
772
|
-
|
773
|
-
Read <<other-chapters.adoc#ch2,the next chapter>> to find out what happens next!
|
774
|
-
|
775
|
-
include::other-chapters.adoc[tags=ch2]
|
776
|
-
EOS
|
777
|
-
|
778
|
-
doc = document_from_string input, :safe => :safe, :base_dir => fixturedir
|
779
|
-
assert doc.catalog[:includes].key?('other-chapters')
|
780
|
-
refute doc.catalog[:includes]['other-chapters']
|
781
|
-
output = doc.convert
|
782
|
-
assert_xpath '//a[@href="other-chapters.html#ch2"][text()="the next chapter"]', output, 1
|
783
|
-
end
|
784
|
-
|
785
|
-
test 'should warn and create link if debug mode is enabled, inter-document xref points to current doc, and reference not found' do
|
786
|
-
input = <<-EOS
|
787
|
-
[#foobar]
|
788
|
-
== Foobar
|
789
|
-
|
790
|
-
== Section B
|
791
|
-
|
792
|
-
See <<test.adoc#foobaz>>.
|
793
|
-
EOS
|
794
|
-
using_memory_logger do |logger|
|
795
|
-
in_verbose_mode do
|
796
|
-
output = convert_string_to_embedded input, :attributes => { 'docname' => 'test' }
|
797
|
-
assert_xpath '//a[@href="#foobaz"][text() = "[foobaz]"]', output, 1
|
798
|
-
assert_message logger, :WARN, 'invalid reference: foobaz'
|
799
|
-
end
|
800
|
-
end
|
801
|
-
end
|
802
|
-
|
803
|
-
test 'should produce an internal anchor for inter-document xref to file outside of base directory' do
|
804
|
-
input = <<-EOS
|
805
|
-
= Document Title
|
806
|
-
|
807
|
-
See <<../section-a.adoc#section-a>>.
|
808
|
-
|
809
|
-
include::../section-a.adoc[]
|
810
|
-
EOS
|
811
|
-
|
812
|
-
doc = document_from_string input, :safe => :unsafe, :base_dir => (File.join fixturedir, 'subdir')
|
813
|
-
assert_includes doc.catalog[:includes], '../section-a'
|
814
|
-
output = doc.convert :header_footer => false
|
815
|
-
assert_xpath '//a[@href="#section-a"][text()="Section A"]', output, 1
|
816
|
-
end
|
817
|
-
|
818
|
-
test 'xref uses title of target as label for forward and backward references in html output' do
|
819
|
-
input = <<-EOS
|
820
|
-
== Section A
|
821
|
-
|
822
|
-
<<_section_b>>
|
823
|
-
|
824
|
-
== Section B
|
825
|
-
|
826
|
-
<<_section_a>>
|
827
|
-
EOS
|
828
|
-
|
829
|
-
output = convert_string_to_embedded input
|
830
|
-
assert_xpath '//h2[@id="_section_a"][text()="Section A"]', output, 1
|
831
|
-
assert_xpath '//a[@href="#_section_a"][text()="Section A"]', output, 1
|
832
|
-
assert_xpath '//h2[@id="_section_b"][text()="Section B"]', output, 1
|
833
|
-
assert_xpath '//a[@href="#_section_b"][text()="Section B"]', output, 1
|
834
|
-
end
|
835
|
-
|
836
|
-
test 'anchor creates reference' do
|
837
|
-
doc = document_from_string "[[tigers]]Tigers roam here."
|
838
|
-
assert_equal({'tigers' => '[tigers]'}, doc.catalog[:ids])
|
839
|
-
end
|
840
|
-
|
841
|
-
test 'anchor with label creates reference' do
|
842
|
-
doc = document_from_string "[[tigers,Tigers]]Tigers roam here."
|
843
|
-
assert_equal({'tigers' => 'Tigers'}, doc.catalog[:ids])
|
844
|
-
end
|
845
|
-
|
846
|
-
test 'anchor with quoted label creates reference with quoted label text' do
|
847
|
-
doc = document_from_string %([[tigers,"Tigers roam here"]]Tigers roam here.)
|
848
|
-
assert_equal({'tigers' => '"Tigers roam here"'}, doc.catalog[:ids])
|
849
|
-
end
|
850
|
-
|
851
|
-
test 'anchor with label containing a comma creates reference' do
|
852
|
-
doc = document_from_string %([[tigers,Tigers, scary tigers, roam here]]Tigers roam here.)
|
853
|
-
assert_equal({'tigers' => 'Tigers, scary tigers, roam here'}, doc.catalog[:ids])
|
854
|
-
end
|
855
|
-
end
|