asciidoctor 1.5.8 → 2.0.0.rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +162 -17
- data/LICENSE +1 -1
- data/README-de.adoc +12 -13
- data/README-fr.adoc +11 -12
- data/README-jp.adoc +11 -12
- data/README-zh_CN.adoc +12 -13
- data/README.adoc +6 -7
- data/asciidoctor.gemspec +19 -24
- data/bin/asciidoctor +5 -4
- data/data/reference/syntax.adoc +283 -0
- data/data/stylesheets/asciidoctor-default.css +56 -52
- data/data/stylesheets/coderay-asciidoctor.css +7 -9
- data/lib/asciidoctor.rb +171 -232
- data/lib/asciidoctor/abstract_block.rb +96 -105
- data/lib/asciidoctor/abstract_node.rb +118 -139
- data/lib/asciidoctor/attribute_list.rb +10 -14
- data/lib/asciidoctor/block.rb +20 -19
- data/lib/asciidoctor/callouts.rb +4 -2
- data/lib/asciidoctor/cli.rb +3 -2
- data/lib/asciidoctor/cli/invoker.rb +14 -21
- data/lib/asciidoctor/cli/options.rb +64 -54
- data/lib/asciidoctor/converter.rb +357 -185
- data/lib/asciidoctor/converter/composite.rb +40 -48
- data/lib/asciidoctor/converter/docbook5.rb +604 -640
- data/lib/asciidoctor/converter/html5.rb +949 -963
- data/lib/asciidoctor/converter/manpage.rb +569 -548
- data/lib/asciidoctor/converter/template.rb +231 -272
- data/lib/asciidoctor/core_ext.rb +5 -18
- data/lib/asciidoctor/core_ext/float/truncate.rb +19 -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/document.rb +399 -377
- data/lib/asciidoctor/extensions.rb +72 -140
- data/lib/asciidoctor/helpers.rb +122 -83
- data/lib/asciidoctor/inline.rb +5 -1
- data/lib/asciidoctor/list.rb +13 -11
- data/lib/asciidoctor/logging.rb +17 -16
- data/lib/asciidoctor/parser.rb +390 -423
- data/lib/asciidoctor/path_resolver.rb +10 -5
- data/lib/asciidoctor/reader.rb +286 -263
- data/lib/asciidoctor/rouge_ext.rb +39 -0
- data/lib/asciidoctor/section.rb +9 -8
- data/lib/asciidoctor/stylesheets.rb +19 -37
- data/lib/asciidoctor/substitutors.rb +364 -509
- data/lib/asciidoctor/syntax_highlighter.rb +238 -0
- data/lib/asciidoctor/syntax_highlighter/coderay.rb +87 -0
- data/lib/asciidoctor/syntax_highlighter/highlightjs.rb +26 -0
- data/lib/asciidoctor/syntax_highlighter/html_pipeline.rb +10 -0
- data/lib/asciidoctor/syntax_highlighter/prettify.rb +27 -0
- data/lib/asciidoctor/syntax_highlighter/pygments.rb +149 -0
- data/lib/asciidoctor/syntax_highlighter/rouge.rb +129 -0
- data/lib/asciidoctor/table.rb +73 -66
- data/lib/asciidoctor/timings.rb +4 -2
- data/lib/asciidoctor/version.rb +2 -1
- data/lib/asciidoctor/writer.rb +30 -0
- data/man/asciidoctor.1 +19 -15
- data/man/asciidoctor.adoc +14 -12
- metadata +69 -216
- 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-tweaks/block_paragraph.html.haml +0 -1
- 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/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/parser_test.rb
DELETED
@@ -1,742 +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 "Parser" do
|
8
|
-
|
9
|
-
test "is_section_title?" do
|
10
|
-
assert Asciidoctor::Parser.is_section_title?('AsciiDoc Home Page', '==================')
|
11
|
-
assert Asciidoctor::Parser.is_section_title?('=== AsciiDoc Home Page')
|
12
|
-
end
|
13
|
-
|
14
|
-
test 'sanitize attribute name' do
|
15
|
-
assert_equal 'foobar', Asciidoctor::Parser.sanitize_attribute_name("Foo Bar")
|
16
|
-
assert_equal 'foo', Asciidoctor::Parser.sanitize_attribute_name("foo")
|
17
|
-
assert_equal 'foo3-bar', Asciidoctor::Parser.sanitize_attribute_name("Foo 3^ # - Bar[")
|
18
|
-
end
|
19
|
-
|
20
|
-
test 'store attribute with value' do
|
21
|
-
attr_name, attr_value = Asciidoctor::Parser.store_attribute 'foo', 'bar'
|
22
|
-
assert_equal 'foo', attr_name
|
23
|
-
assert_equal 'bar', attr_value
|
24
|
-
end
|
25
|
-
|
26
|
-
test 'store attribute with negated value' do
|
27
|
-
{ 'foo!' => nil, '!foo' => nil, 'foo' => nil }.each do |name, value|
|
28
|
-
attr_name, attr_value = Asciidoctor::Parser.store_attribute name, value
|
29
|
-
assert_equal name.sub('!', ''), attr_name
|
30
|
-
assert_nil attr_value
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
test 'store accessible attribute on document with value' do
|
35
|
-
doc = empty_document
|
36
|
-
doc.set_attribute 'foo', 'baz'
|
37
|
-
attrs = {}
|
38
|
-
attr_name, attr_value = Asciidoctor::Parser.store_attribute 'foo', 'bar', doc, attrs
|
39
|
-
assert_equal 'foo', attr_name
|
40
|
-
assert_equal 'bar', attr_value
|
41
|
-
assert_equal 'bar', (doc.attr 'foo')
|
42
|
-
assert attrs.key?(:attribute_entries)
|
43
|
-
assert_equal 1, attrs[:attribute_entries].size
|
44
|
-
assert_equal 'foo', attrs[:attribute_entries][0].name
|
45
|
-
assert_equal 'bar', attrs[:attribute_entries][0].value
|
46
|
-
end
|
47
|
-
|
48
|
-
test 'store accessible attribute on document with value that contains attribute reference' do
|
49
|
-
doc = empty_document
|
50
|
-
doc.set_attribute 'foo', 'baz'
|
51
|
-
doc.set_attribute 'release', 'ultramega'
|
52
|
-
attrs = {}
|
53
|
-
attr_name, attr_value = Asciidoctor::Parser.store_attribute 'foo', '{release}', doc, attrs
|
54
|
-
assert_equal 'foo', attr_name
|
55
|
-
assert_equal 'ultramega', attr_value
|
56
|
-
assert_equal 'ultramega', (doc.attr 'foo')
|
57
|
-
assert attrs.key?(:attribute_entries)
|
58
|
-
assert_equal 1, attrs[:attribute_entries].size
|
59
|
-
assert_equal 'foo', attrs[:attribute_entries][0].name
|
60
|
-
assert_equal 'ultramega', attrs[:attribute_entries][0].value
|
61
|
-
end
|
62
|
-
|
63
|
-
test 'store inaccessible attribute on document with value' do
|
64
|
-
doc = empty_document :attributes => { 'foo' => 'baz' }
|
65
|
-
attrs = {}
|
66
|
-
attr_name, attr_value = Asciidoctor::Parser.store_attribute 'foo', 'bar', doc, attrs
|
67
|
-
assert_equal 'foo', attr_name
|
68
|
-
assert_equal 'bar', attr_value
|
69
|
-
assert_equal 'baz', (doc.attr 'foo')
|
70
|
-
refute attrs.key?(:attribute_entries)
|
71
|
-
end
|
72
|
-
|
73
|
-
test 'store accessible attribute on document with negated value' do
|
74
|
-
{ 'foo!' => nil, '!foo' => nil, 'foo' => nil }.each do |name, value|
|
75
|
-
doc = empty_document
|
76
|
-
doc.set_attribute 'foo', 'baz'
|
77
|
-
attrs = {}
|
78
|
-
attr_name, attr_value = Asciidoctor::Parser.store_attribute name, value, doc, attrs
|
79
|
-
assert_equal name.sub('!', ''), attr_name
|
80
|
-
assert_nil attr_value
|
81
|
-
assert attrs.key?(:attribute_entries)
|
82
|
-
assert_equal 1, attrs[:attribute_entries].size
|
83
|
-
assert_equal 'foo', attrs[:attribute_entries][0].name
|
84
|
-
assert_nil attrs[:attribute_entries][0].value
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
test 'store inaccessible attribute on document with negated value' do
|
89
|
-
{ 'foo!' => nil, '!foo' => nil, 'foo' => nil }.each do |name, value|
|
90
|
-
doc = empty_document :attributes => { 'foo' => 'baz' }
|
91
|
-
attrs = {}
|
92
|
-
attr_name, attr_value = Asciidoctor::Parser.store_attribute name, value, doc, attrs
|
93
|
-
assert_equal name.sub('!', ''), attr_name
|
94
|
-
assert_nil attr_value
|
95
|
-
refute attrs.key?(:attribute_entries)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
test 'parse style attribute with id and role' do
|
100
|
-
attributes = {1 => 'style#id.role'}
|
101
|
-
style = Asciidoctor::Parser.parse_style_attribute(attributes)
|
102
|
-
assert_equal 'style', style
|
103
|
-
assert_equal 'style', attributes['style']
|
104
|
-
assert_equal 'id', attributes['id']
|
105
|
-
assert_equal 'role', attributes['role']
|
106
|
-
assert_equal 'style#id.role', attributes[1]
|
107
|
-
end
|
108
|
-
|
109
|
-
test 'parse style attribute with style, role, id and option' do
|
110
|
-
attributes = {1 => 'style.role#id%fragment'}
|
111
|
-
style = Asciidoctor::Parser.parse_style_attribute(attributes)
|
112
|
-
assert_equal 'style', style
|
113
|
-
assert_equal 'style', attributes['style']
|
114
|
-
assert_equal 'id', attributes['id']
|
115
|
-
assert_equal 'role', attributes['role']
|
116
|
-
assert_equal '', attributes['fragment-option']
|
117
|
-
assert_equal 'fragment', attributes['options']
|
118
|
-
assert_equal 'style.role#id%fragment', attributes[1]
|
119
|
-
end
|
120
|
-
|
121
|
-
test 'parse style attribute with style, id and multiple roles' do
|
122
|
-
attributes = {1 => 'style#id.role1.role2'}
|
123
|
-
style = Asciidoctor::Parser.parse_style_attribute(attributes)
|
124
|
-
assert_equal 'style', style
|
125
|
-
assert_equal 'style', attributes['style']
|
126
|
-
assert_equal 'id', attributes['id']
|
127
|
-
assert_equal 'role1 role2', attributes['role']
|
128
|
-
assert_equal 'style#id.role1.role2', attributes[1]
|
129
|
-
end
|
130
|
-
|
131
|
-
test 'parse style attribute with style, multiple roles and id' do
|
132
|
-
attributes = {1 => 'style.role1.role2#id'}
|
133
|
-
style = Asciidoctor::Parser.parse_style_attribute(attributes)
|
134
|
-
assert_equal 'style', style
|
135
|
-
assert_equal 'style', attributes['style']
|
136
|
-
assert_equal 'id', attributes['id']
|
137
|
-
assert_equal 'role1 role2', attributes['role']
|
138
|
-
assert_equal 'style.role1.role2#id', attributes[1]
|
139
|
-
end
|
140
|
-
|
141
|
-
test 'parse style attribute with positional and original style' do
|
142
|
-
attributes = {1 => 'new_style', 'style' => 'original_style'}
|
143
|
-
style = Asciidoctor::Parser.parse_style_attribute(attributes)
|
144
|
-
assert_equal 'new_style', style
|
145
|
-
assert_equal 'new_style', attributes['style']
|
146
|
-
assert_equal 'new_style', attributes[1]
|
147
|
-
end
|
148
|
-
|
149
|
-
test 'parse style attribute with id and role only' do
|
150
|
-
attributes = {1 => '#id.role'}
|
151
|
-
style = Asciidoctor::Parser.parse_style_attribute(attributes)
|
152
|
-
assert_nil style
|
153
|
-
assert_equal 'id', attributes['id']
|
154
|
-
assert_equal 'role', attributes['role']
|
155
|
-
assert_equal '#id.role', attributes[1]
|
156
|
-
end
|
157
|
-
|
158
|
-
test 'parse empty style attribute' do
|
159
|
-
attributes = {1 => nil}
|
160
|
-
style = Asciidoctor::Parser.parse_style_attribute(attributes)
|
161
|
-
assert_nil style
|
162
|
-
assert_nil attributes['id']
|
163
|
-
assert_nil attributes['role']
|
164
|
-
assert_nil attributes[1]
|
165
|
-
end
|
166
|
-
|
167
|
-
test 'parse style attribute with option should preserve existing options' do
|
168
|
-
attributes = {1 => '%header', 'options' => 'footer', 'footer-option' => ''}
|
169
|
-
style = Asciidoctor::Parser.parse_style_attribute(attributes)
|
170
|
-
assert_nil style
|
171
|
-
assert_equal 'footer,header', attributes['options']
|
172
|
-
assert_equal '', attributes['header-option']
|
173
|
-
assert_equal '', attributes['footer-option']
|
174
|
-
end
|
175
|
-
|
176
|
-
test "parse author first" do
|
177
|
-
metadata, _ = parse_header_metadata 'Stuart'
|
178
|
-
assert_equal 5, metadata.size
|
179
|
-
assert_equal 1, metadata['authorcount']
|
180
|
-
assert_equal metadata['author'], metadata['authors']
|
181
|
-
assert_equal 'Stuart', metadata['firstname']
|
182
|
-
assert_equal 'S', metadata['authorinitials']
|
183
|
-
end
|
184
|
-
|
185
|
-
test "parse author first last" do
|
186
|
-
metadata, _ = parse_header_metadata 'Yukihiro Matsumoto'
|
187
|
-
assert_equal 6, metadata.size
|
188
|
-
assert_equal 1, metadata['authorcount']
|
189
|
-
assert_equal 'Yukihiro Matsumoto', metadata['author']
|
190
|
-
assert_equal metadata['author'], metadata['authors']
|
191
|
-
assert_equal 'Yukihiro', metadata['firstname']
|
192
|
-
assert_equal 'Matsumoto', metadata['lastname']
|
193
|
-
assert_equal 'YM', metadata['authorinitials']
|
194
|
-
end
|
195
|
-
|
196
|
-
test "parse author first middle last" do
|
197
|
-
metadata, _ = parse_header_metadata 'David Heinemeier Hansson'
|
198
|
-
assert_equal 7, metadata.size
|
199
|
-
assert_equal 1, metadata['authorcount']
|
200
|
-
assert_equal 'David Heinemeier Hansson', metadata['author']
|
201
|
-
assert_equal metadata['author'], metadata['authors']
|
202
|
-
assert_equal 'David', metadata['firstname']
|
203
|
-
assert_equal 'Heinemeier', metadata['middlename']
|
204
|
-
assert_equal 'Hansson', metadata['lastname']
|
205
|
-
assert_equal 'DHH', metadata['authorinitials']
|
206
|
-
end
|
207
|
-
|
208
|
-
test "parse author first middle last email" do
|
209
|
-
metadata, _ = parse_header_metadata 'David Heinemeier Hansson <rails@ruby-lang.org>'
|
210
|
-
assert_equal 8, metadata.size
|
211
|
-
assert_equal 1, metadata['authorcount']
|
212
|
-
assert_equal 'David Heinemeier Hansson', metadata['author']
|
213
|
-
assert_equal metadata['author'], metadata['authors']
|
214
|
-
assert_equal 'David', metadata['firstname']
|
215
|
-
assert_equal 'Heinemeier', metadata['middlename']
|
216
|
-
assert_equal 'Hansson', metadata['lastname']
|
217
|
-
assert_equal 'rails@ruby-lang.org', metadata['email']
|
218
|
-
assert_equal 'DHH', metadata['authorinitials']
|
219
|
-
end
|
220
|
-
|
221
|
-
test "parse author first email" do
|
222
|
-
metadata, _ = parse_header_metadata 'Stuart <founder@asciidoc.org>'
|
223
|
-
assert_equal 6, metadata.size
|
224
|
-
assert_equal 1, metadata['authorcount']
|
225
|
-
assert_equal 'Stuart', metadata['author']
|
226
|
-
assert_equal metadata['author'], metadata['authors']
|
227
|
-
assert_equal 'Stuart', metadata['firstname']
|
228
|
-
assert_equal 'founder@asciidoc.org', metadata['email']
|
229
|
-
assert_equal 'S', metadata['authorinitials']
|
230
|
-
end
|
231
|
-
|
232
|
-
test "parse author first last email" do
|
233
|
-
metadata, _ = parse_header_metadata 'Stuart Rackham <founder@asciidoc.org>'
|
234
|
-
assert_equal 7, metadata.size
|
235
|
-
assert_equal 1, metadata['authorcount']
|
236
|
-
assert_equal 'Stuart Rackham', metadata['author']
|
237
|
-
assert_equal metadata['author'], metadata['authors']
|
238
|
-
assert_equal 'Stuart', metadata['firstname']
|
239
|
-
assert_equal 'Rackham', metadata['lastname']
|
240
|
-
assert_equal 'founder@asciidoc.org', metadata['email']
|
241
|
-
assert_equal 'SR', metadata['authorinitials']
|
242
|
-
end
|
243
|
-
|
244
|
-
test "parse author with hyphen" do
|
245
|
-
metadata, _ = parse_header_metadata 'Tim Berners-Lee <founder@www.org>'
|
246
|
-
assert_equal 7, metadata.size
|
247
|
-
assert_equal 1, metadata['authorcount']
|
248
|
-
assert_equal 'Tim Berners-Lee', metadata['author']
|
249
|
-
assert_equal metadata['author'], metadata['authors']
|
250
|
-
assert_equal 'Tim', metadata['firstname']
|
251
|
-
assert_equal 'Berners-Lee', metadata['lastname']
|
252
|
-
assert_equal 'founder@www.org', metadata['email']
|
253
|
-
assert_equal 'TB', metadata['authorinitials']
|
254
|
-
end
|
255
|
-
|
256
|
-
test "parse author with single quote" do
|
257
|
-
metadata, _ = parse_header_metadata 'Stephen O\'Grady <founder@redmonk.com>'
|
258
|
-
assert_equal 7, metadata.size
|
259
|
-
assert_equal 1, metadata['authorcount']
|
260
|
-
assert_equal 'Stephen O\'Grady', metadata['author']
|
261
|
-
assert_equal metadata['author'], metadata['authors']
|
262
|
-
assert_equal 'Stephen', metadata['firstname']
|
263
|
-
assert_equal 'O\'Grady', metadata['lastname']
|
264
|
-
assert_equal 'founder@redmonk.com', metadata['email']
|
265
|
-
assert_equal 'SO', metadata['authorinitials']
|
266
|
-
end
|
267
|
-
|
268
|
-
test "parse author with dotted initial" do
|
269
|
-
metadata, _ = parse_header_metadata 'Heiko W. Rupp <hwr@example.de>'
|
270
|
-
assert_equal 8, metadata.size
|
271
|
-
assert_equal 1, metadata['authorcount']
|
272
|
-
assert_equal 'Heiko W. Rupp', metadata['author']
|
273
|
-
assert_equal metadata['author'], metadata['authors']
|
274
|
-
assert_equal 'Heiko', metadata['firstname']
|
275
|
-
assert_equal 'W.', metadata['middlename']
|
276
|
-
assert_equal 'Rupp', metadata['lastname']
|
277
|
-
assert_equal 'hwr@example.de', metadata['email']
|
278
|
-
assert_equal 'HWR', metadata['authorinitials']
|
279
|
-
end
|
280
|
-
|
281
|
-
test "parse author with underscore" do
|
282
|
-
metadata, _ = parse_header_metadata 'Tim_E Fella'
|
283
|
-
assert_equal 6, metadata.size
|
284
|
-
assert_equal 1, metadata['authorcount']
|
285
|
-
assert_equal 'Tim E Fella', metadata['author']
|
286
|
-
assert_equal metadata['author'], metadata['authors']
|
287
|
-
assert_equal 'Tim E', metadata['firstname']
|
288
|
-
assert_equal 'Fella', metadata['lastname']
|
289
|
-
assert_equal 'TF', metadata['authorinitials']
|
290
|
-
end
|
291
|
-
|
292
|
-
test 'parse author name with letters outside basic latin' do
|
293
|
-
metadata, _ = parse_header_metadata 'Stéphane Brontë'
|
294
|
-
assert_equal 6, metadata.size
|
295
|
-
assert_equal 1, metadata['authorcount']
|
296
|
-
assert_equal 'Stéphane Brontë', metadata['author']
|
297
|
-
assert_equal metadata['author'], metadata['authors']
|
298
|
-
assert_equal 'Stéphane', metadata['firstname']
|
299
|
-
assert_equal 'Brontë', metadata['lastname']
|
300
|
-
assert_equal 'SB', metadata['authorinitials']
|
301
|
-
end if ::RUBY_MIN_VERSION_1_9
|
302
|
-
|
303
|
-
test 'parse ideographic author names' do
|
304
|
-
metadata, _ = parse_header_metadata '李 四 <si.li@example.com>'
|
305
|
-
assert_equal 7, metadata.size
|
306
|
-
assert_equal 1, metadata['authorcount']
|
307
|
-
assert_equal '李 四', metadata['author']
|
308
|
-
assert_equal metadata['author'], metadata['authors']
|
309
|
-
assert_equal '李', metadata['firstname']
|
310
|
-
assert_equal '四', metadata['lastname']
|
311
|
-
assert_equal 'si.li@example.com', metadata['email']
|
312
|
-
assert_equal '李四', metadata['authorinitials']
|
313
|
-
end if ::RUBY_MIN_VERSION_1_9
|
314
|
-
|
315
|
-
test "parse author condenses whitespace" do
|
316
|
-
metadata, _ = parse_header_metadata ' Stuart Rackham <founder@asciidoc.org>'
|
317
|
-
assert_equal 7, metadata.size
|
318
|
-
assert_equal 1, metadata['authorcount']
|
319
|
-
assert_equal 'Stuart Rackham', metadata['author']
|
320
|
-
assert_equal metadata['author'], metadata['authors']
|
321
|
-
assert_equal 'Stuart', metadata['firstname']
|
322
|
-
assert_equal 'Rackham', metadata['lastname']
|
323
|
-
assert_equal 'founder@asciidoc.org', metadata['email']
|
324
|
-
assert_equal 'SR', metadata['authorinitials']
|
325
|
-
end
|
326
|
-
|
327
|
-
test "parse invalid author line becomes author" do
|
328
|
-
metadata, _ = parse_header_metadata ' Stuart Rackham, founder of AsciiDoc <founder@asciidoc.org>'
|
329
|
-
assert_equal 5, metadata.size
|
330
|
-
assert_equal 1, metadata['authorcount']
|
331
|
-
assert_equal 'Stuart Rackham, founder of AsciiDoc <founder@asciidoc.org>', metadata['author']
|
332
|
-
assert_equal metadata['author'], metadata['authors']
|
333
|
-
assert_equal 'Stuart Rackham, founder of AsciiDoc <founder@asciidoc.org>', metadata['firstname']
|
334
|
-
assert_equal 'S', metadata['authorinitials']
|
335
|
-
end
|
336
|
-
|
337
|
-
test 'parse multiple authors' do
|
338
|
-
metadata, _ = parse_header_metadata 'Doc Writer <doc.writer@asciidoc.org>; John Smith <john.smith@asciidoc.org>'
|
339
|
-
assert_equal 2, metadata['authorcount']
|
340
|
-
assert_equal 'Doc Writer, John Smith', metadata['authors']
|
341
|
-
assert_equal 'Doc Writer', metadata['author']
|
342
|
-
assert_equal 'Doc Writer', metadata['author_1']
|
343
|
-
assert_equal 'John Smith', metadata['author_2']
|
344
|
-
end
|
345
|
-
|
346
|
-
test 'skips blank author entries in implicit author line' do
|
347
|
-
metadata, _ = parse_header_metadata 'Doc Writer; ; John Smith <john.smith@asciidoc.org>;'
|
348
|
-
assert_equal 2, metadata['authorcount']
|
349
|
-
assert_equal 'Doc Writer', metadata['author_1']
|
350
|
-
assert_equal 'John Smith', metadata['author_2']
|
351
|
-
end
|
352
|
-
|
353
|
-
test 'parse name with more than 3 parts in author attribute' do
|
354
|
-
doc = empty_document
|
355
|
-
parse_header_metadata ':author: Leroy Harold Scherer, Jr.', doc
|
356
|
-
assert_equal 'Leroy Harold Scherer, Jr.', doc.attributes['author']
|
357
|
-
assert_equal 'Leroy', doc.attributes['firstname']
|
358
|
-
assert_equal 'Harold', doc.attributes['middlename']
|
359
|
-
assert_equal 'Scherer, Jr.', doc.attributes['lastname']
|
360
|
-
end
|
361
|
-
|
362
|
-
test 'use explicit authorinitials if set after implicit author line' do
|
363
|
-
input = <<-EOS.chomp
|
364
|
-
Jean-Claude Van Damme
|
365
|
-
:authorinitials: JCVD
|
366
|
-
EOS
|
367
|
-
doc = empty_document
|
368
|
-
parse_header_metadata input, doc
|
369
|
-
assert_equal 'JCVD', doc.attributes['authorinitials']
|
370
|
-
end
|
371
|
-
|
372
|
-
test 'use explicit authorinitials if set after author attribute' do
|
373
|
-
input = <<-EOS.chomp
|
374
|
-
:author: Jean-Claude Van Damme
|
375
|
-
:authorinitials: JCVD
|
376
|
-
EOS
|
377
|
-
doc = empty_document
|
378
|
-
parse_header_metadata input, doc
|
379
|
-
assert_equal 'JCVD', doc.attributes['authorinitials']
|
380
|
-
end
|
381
|
-
|
382
|
-
test 'sets authorcount to 0 if document has no authors' do
|
383
|
-
input = ''
|
384
|
-
doc = empty_document
|
385
|
-
metadata, _ = parse_header_metadata input, doc
|
386
|
-
assert_equal 0, doc.attributes['authorcount']
|
387
|
-
assert_equal 0, metadata['authorcount']
|
388
|
-
end
|
389
|
-
|
390
|
-
test 'does not drop name joiner when using multiple authors' do
|
391
|
-
input = <<-EOS
|
392
|
-
Kismet Chameleon; Lazarus het_Draeke
|
393
|
-
EOS
|
394
|
-
doc = empty_document
|
395
|
-
parse_header_metadata input, doc
|
396
|
-
assert_equal 2, doc.attributes['authorcount']
|
397
|
-
assert_equal 'Kismet Chameleon, Lazarus het Draeke', doc.attributes['authors']
|
398
|
-
assert_equal 'Kismet Chameleon', doc.attributes['author_1']
|
399
|
-
assert_equal 'Lazarus het Draeke', doc.attributes['author_2']
|
400
|
-
assert_equal 'het Draeke', doc.attributes['lastname_2']
|
401
|
-
end
|
402
|
-
|
403
|
-
test 'allows authors to be overridden using explicit author attributes' do
|
404
|
-
input = <<-EOS
|
405
|
-
Kismet Chameleon; Johnny Bravo; Lazarus het_Draeke
|
406
|
-
:author_2: Danger Mouse
|
407
|
-
EOS
|
408
|
-
doc = empty_document
|
409
|
-
parse_header_metadata input, doc
|
410
|
-
assert_equal 3, doc.attributes['authorcount']
|
411
|
-
assert_equal 'Kismet Chameleon, Danger Mouse, Lazarus het Draeke', doc.attributes['authors']
|
412
|
-
assert_equal 'Kismet Chameleon', doc.attributes['author_1']
|
413
|
-
assert_equal 'Danger Mouse', doc.attributes['author_2']
|
414
|
-
assert_equal 'Lazarus het Draeke', doc.attributes['author_3']
|
415
|
-
assert_equal 'het Draeke', doc.attributes['lastname_3']
|
416
|
-
end
|
417
|
-
|
418
|
-
test 'removes formatting before partitioning author defined using author attribute' do
|
419
|
-
input = <<-EOS
|
420
|
-
:author: pass:n[http://example.org/community/team.html[Ze_**Project** team]]
|
421
|
-
EOS
|
422
|
-
|
423
|
-
doc = empty_document
|
424
|
-
parse_header_metadata input, doc
|
425
|
-
assert_equal 1, doc.attributes['authorcount']
|
426
|
-
assert_equal '<a href="http://example.org/community/team.html">Ze <strong>Project</strong> team</a>', doc.attributes['authors']
|
427
|
-
assert_equal 'Ze Project', doc.attributes['firstname']
|
428
|
-
assert_equal 'team', doc.attributes['lastname']
|
429
|
-
end
|
430
|
-
|
431
|
-
test "parse rev number date remark" do
|
432
|
-
input = <<-EOS
|
433
|
-
Ryan Waldron
|
434
|
-
v0.0.7, 2013-12-18: The first release you can stand on
|
435
|
-
EOS
|
436
|
-
metadata, _ = parse_header_metadata input
|
437
|
-
assert_equal 9, metadata.size
|
438
|
-
assert_equal '0.0.7', metadata['revnumber']
|
439
|
-
assert_equal '2013-12-18', metadata['revdate']
|
440
|
-
assert_equal 'The first release you can stand on', metadata['revremark']
|
441
|
-
end
|
442
|
-
|
443
|
-
test 'parse rev number, data, and remark as attribute references' do
|
444
|
-
input = <<-EOS
|
445
|
-
Author Name
|
446
|
-
v{project-version}, {release-date}: {release-summary}
|
447
|
-
EOS
|
448
|
-
metadata, _ = parse_header_metadata input
|
449
|
-
assert_equal 9, metadata.size
|
450
|
-
assert_equal '{project-version}', metadata['revnumber']
|
451
|
-
assert_equal '{release-date}', metadata['revdate']
|
452
|
-
assert_equal '{release-summary}', metadata['revremark']
|
453
|
-
end
|
454
|
-
|
455
|
-
test 'should resolve attribute references in rev number, data, and remark' do
|
456
|
-
input = <<-EOS
|
457
|
-
= Document Title
|
458
|
-
Author Name
|
459
|
-
{project-version}, {release-date}: {release-summary}
|
460
|
-
EOS
|
461
|
-
doc = document_from_string input, :attributes => {
|
462
|
-
'project-version' => '1.0.1',
|
463
|
-
'release-date' => '2018-05-15',
|
464
|
-
'release-summary' => 'The one you can count on!'
|
465
|
-
}
|
466
|
-
assert_equal '1.0.1', (doc.attr 'revnumber')
|
467
|
-
assert_equal '2018-05-15', (doc.attr 'revdate')
|
468
|
-
assert_equal 'The one you can count on!', (doc.attr 'revremark')
|
469
|
-
end
|
470
|
-
|
471
|
-
test "parse rev date" do
|
472
|
-
input = <<-EOS
|
473
|
-
Ryan Waldron
|
474
|
-
2013-12-18
|
475
|
-
EOS
|
476
|
-
metadata, _ = parse_header_metadata input
|
477
|
-
assert_equal 7, metadata.size
|
478
|
-
assert_equal '2013-12-18', metadata['revdate']
|
479
|
-
end
|
480
|
-
|
481
|
-
test 'parse rev number with trailing comma' do
|
482
|
-
input = <<-EOS
|
483
|
-
Stuart Rackham
|
484
|
-
v8.6.8,
|
485
|
-
EOS
|
486
|
-
metadata, _ = parse_header_metadata input
|
487
|
-
assert_equal 7, metadata.size
|
488
|
-
assert_equal '8.6.8', metadata['revnumber']
|
489
|
-
refute metadata.has_key?('revdate')
|
490
|
-
end
|
491
|
-
|
492
|
-
# Asciidoctor recognizes a standalone revision without a trailing comma
|
493
|
-
test 'parse rev number' do
|
494
|
-
input = <<-EOS
|
495
|
-
Stuart Rackham
|
496
|
-
v8.6.8
|
497
|
-
EOS
|
498
|
-
metadata, _ = parse_header_metadata input
|
499
|
-
assert_equal 7, metadata.size
|
500
|
-
assert_equal '8.6.8', metadata['revnumber']
|
501
|
-
refute metadata.has_key?('revdate')
|
502
|
-
end
|
503
|
-
|
504
|
-
# while compliant w/ AsciiDoc, this is just sloppy parsing
|
505
|
-
test "treats arbitrary text on rev line as revdate" do
|
506
|
-
input = <<-EOS
|
507
|
-
Ryan Waldron
|
508
|
-
foobar
|
509
|
-
EOS
|
510
|
-
metadata, _ = parse_header_metadata input
|
511
|
-
assert_equal 7, metadata.size
|
512
|
-
assert_equal 'foobar', metadata['revdate']
|
513
|
-
end
|
514
|
-
|
515
|
-
test "parse rev date remark" do
|
516
|
-
input = <<-EOS
|
517
|
-
Ryan Waldron
|
518
|
-
2013-12-18: The first release you can stand on
|
519
|
-
EOS
|
520
|
-
metadata, _ = parse_header_metadata input
|
521
|
-
assert_equal 8, metadata.size
|
522
|
-
assert_equal '2013-12-18', metadata['revdate']
|
523
|
-
assert_equal 'The first release you can stand on', metadata['revremark']
|
524
|
-
end
|
525
|
-
|
526
|
-
test "should not mistake attribute entry as rev remark" do
|
527
|
-
input = <<-EOS
|
528
|
-
Joe Cool
|
529
|
-
:page-layout: post
|
530
|
-
EOS
|
531
|
-
metadata, _ = parse_header_metadata input
|
532
|
-
refute_equal 'page-layout: post', metadata['revremark']
|
533
|
-
refute metadata.has_key?('revdate')
|
534
|
-
end
|
535
|
-
|
536
|
-
test "parse rev remark only" do
|
537
|
-
input = <<-EOS
|
538
|
-
Joe Cool
|
539
|
-
:Must start revremark-only line with space
|
540
|
-
EOS
|
541
|
-
metadata, _ = parse_header_metadata input
|
542
|
-
assert_equal 'Must start revremark-only line with space', metadata['revremark']
|
543
|
-
refute metadata.has_key?('revdate')
|
544
|
-
end
|
545
|
-
|
546
|
-
test "skip line comments before author" do
|
547
|
-
input = <<-EOS
|
548
|
-
// Asciidoctor
|
549
|
-
// release artist
|
550
|
-
Ryan Waldron
|
551
|
-
EOS
|
552
|
-
metadata, _ = parse_header_metadata input
|
553
|
-
assert_equal 6, metadata.size
|
554
|
-
assert_equal 1, metadata['authorcount']
|
555
|
-
assert_equal 'Ryan Waldron', metadata['author']
|
556
|
-
assert_equal 'Ryan', metadata['firstname']
|
557
|
-
assert_equal 'Waldron', metadata['lastname']
|
558
|
-
assert_equal 'RW', metadata['authorinitials']
|
559
|
-
end
|
560
|
-
|
561
|
-
test "skip block comment before author" do
|
562
|
-
input = <<-EOS
|
563
|
-
////
|
564
|
-
Asciidoctor
|
565
|
-
release artist
|
566
|
-
////
|
567
|
-
Ryan Waldron
|
568
|
-
EOS
|
569
|
-
metadata, _ = parse_header_metadata input
|
570
|
-
assert_equal 6, metadata.size
|
571
|
-
assert_equal 1, metadata['authorcount']
|
572
|
-
assert_equal 'Ryan Waldron', metadata['author']
|
573
|
-
assert_equal 'Ryan', metadata['firstname']
|
574
|
-
assert_equal 'Waldron', metadata['lastname']
|
575
|
-
assert_equal 'RW', metadata['authorinitials']
|
576
|
-
end
|
577
|
-
|
578
|
-
test "skip block comment before rev" do
|
579
|
-
input = <<-EOS
|
580
|
-
Ryan Waldron
|
581
|
-
////
|
582
|
-
Asciidoctor
|
583
|
-
release info
|
584
|
-
////
|
585
|
-
v0.0.7, 2013-12-18
|
586
|
-
EOS
|
587
|
-
metadata, _ = parse_header_metadata input
|
588
|
-
assert_equal 8, metadata.size
|
589
|
-
assert_equal 1, metadata['authorcount']
|
590
|
-
assert_equal 'Ryan Waldron', metadata['author']
|
591
|
-
assert_equal '0.0.7', metadata['revnumber']
|
592
|
-
assert_equal '2013-12-18', metadata['revdate']
|
593
|
-
end
|
594
|
-
|
595
|
-
test 'break header at line with three forward slashes' do
|
596
|
-
input = <<-EOS
|
597
|
-
Joe Cool
|
598
|
-
v1.0
|
599
|
-
///
|
600
|
-
stuff
|
601
|
-
EOS
|
602
|
-
metadata, _ = parse_header_metadata input
|
603
|
-
assert_equal 7, metadata.size
|
604
|
-
assert_equal 1, metadata['authorcount']
|
605
|
-
assert_equal 'Joe Cool', metadata['author']
|
606
|
-
assert_equal '1.0', metadata['revnumber']
|
607
|
-
end
|
608
|
-
|
609
|
-
test 'attribute entry overrides generated author initials' do
|
610
|
-
doc = empty_document
|
611
|
-
metadata, _ = parse_header_metadata %(Stuart Rackham <founder@asciidoc.org>\n:Author Initials: SJR), doc
|
612
|
-
assert_equal 'SR', metadata['authorinitials']
|
613
|
-
assert_equal 'SJR', doc.attributes['authorinitials']
|
614
|
-
end
|
615
|
-
|
616
|
-
test 'adjust indentation to 0' do
|
617
|
-
input = <<-EOS.chomp
|
618
|
-
def names
|
619
|
-
|
620
|
-
@name.split
|
621
|
-
|
622
|
-
end
|
623
|
-
EOS
|
624
|
-
|
625
|
-
expected = <<-EOS.chomp
|
626
|
-
def names
|
627
|
-
|
628
|
-
@name.split
|
629
|
-
|
630
|
-
end
|
631
|
-
EOS
|
632
|
-
|
633
|
-
lines = input.split("\n")
|
634
|
-
Asciidoctor::Parser.adjust_indentation! lines
|
635
|
-
assert_equal expected, (lines * "\n")
|
636
|
-
end
|
637
|
-
|
638
|
-
test 'adjust indentation mixed with tabs and spaces to 0' do
|
639
|
-
input = <<-EOS.chomp
|
640
|
-
def names
|
641
|
-
|
642
|
-
\t @name.split
|
643
|
-
|
644
|
-
end
|
645
|
-
EOS
|
646
|
-
|
647
|
-
expected = <<-EOS.chomp
|
648
|
-
def names
|
649
|
-
|
650
|
-
@name.split
|
651
|
-
|
652
|
-
end
|
653
|
-
EOS
|
654
|
-
|
655
|
-
lines = input.split("\n")
|
656
|
-
Asciidoctor::Parser.adjust_indentation! lines, 0, 4
|
657
|
-
assert_equal expected, (lines * "\n")
|
658
|
-
end
|
659
|
-
|
660
|
-
test 'expands tabs to spaces' do
|
661
|
-
input = <<-EOS.chomp
|
662
|
-
Filesystem Size Used Avail Use% Mounted on
|
663
|
-
Filesystem Size Used Avail Use% Mounted on
|
664
|
-
devtmpfs 3.9G 0 3.9G 0% /dev
|
665
|
-
/dev/mapper/fedora-root 48G 18G 29G 39% /
|
666
|
-
EOS
|
667
|
-
|
668
|
-
expected = <<-EOS.chomp
|
669
|
-
Filesystem Size Used Avail Use% Mounted on
|
670
|
-
Filesystem Size Used Avail Use% Mounted on
|
671
|
-
devtmpfs 3.9G 0 3.9G 0% /dev
|
672
|
-
/dev/mapper/fedora-root 48G 18G 29G 39% /
|
673
|
-
EOS
|
674
|
-
|
675
|
-
lines = input.split("\n")
|
676
|
-
Asciidoctor::Parser.adjust_indentation! lines, 0, 4
|
677
|
-
assert_equal expected, (lines * "\n")
|
678
|
-
end
|
679
|
-
|
680
|
-
test 'adjust indentation to non-zero' do
|
681
|
-
input = <<-EOS.chomp
|
682
|
-
def names
|
683
|
-
|
684
|
-
@name.split
|
685
|
-
|
686
|
-
end
|
687
|
-
EOS
|
688
|
-
|
689
|
-
expected = <<-EOS.chomp
|
690
|
-
def names
|
691
|
-
|
692
|
-
@name.split
|
693
|
-
|
694
|
-
end
|
695
|
-
EOS
|
696
|
-
|
697
|
-
lines = input.split("\n")
|
698
|
-
Asciidoctor::Parser.adjust_indentation! lines, 2
|
699
|
-
assert_equal expected, (lines * "\n")
|
700
|
-
end
|
701
|
-
|
702
|
-
test 'preserve block indent if indent is -1' do
|
703
|
-
input = <<-EOS
|
704
|
-
def names
|
705
|
-
|
706
|
-
@name.split
|
707
|
-
|
708
|
-
end
|
709
|
-
EOS
|
710
|
-
|
711
|
-
expected = input
|
712
|
-
|
713
|
-
lines = input.lines.entries
|
714
|
-
Asciidoctor::Parser.adjust_indentation! lines, -1
|
715
|
-
assert_equal expected, lines.join
|
716
|
-
end
|
717
|
-
|
718
|
-
test 'adjust indentation handles empty lines gracefully' do
|
719
|
-
input = []
|
720
|
-
expected = input
|
721
|
-
|
722
|
-
lines = input.dup
|
723
|
-
Asciidoctor::Parser.adjust_indentation! lines
|
724
|
-
assert_equal expected, lines
|
725
|
-
end
|
726
|
-
|
727
|
-
test 'should warn if inline anchor is already in use' do
|
728
|
-
input = <<-EOS
|
729
|
-
[#in-use]
|
730
|
-
A paragraph with an id.
|
731
|
-
|
732
|
-
Another paragraph
|
733
|
-
[[in-use]]that uses an id
|
734
|
-
which is already in use.
|
735
|
-
EOS
|
736
|
-
|
737
|
-
using_memory_logger do |logger|
|
738
|
-
document_from_string input
|
739
|
-
assert_message logger, :WARN, '<stdin>: line 5: id assigned to anchor already in use: in-use', Hash
|
740
|
-
end
|
741
|
-
end
|
742
|
-
end
|