asciidoctor 1.5.6 → 1.5.6.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of asciidoctor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +52 -1
- data/README-fr.adoc +21 -15
- data/README-jp.adoc +20 -8
- data/README-zh_CN.adoc +21 -9
- data/README.adoc +10 -7
- data/Rakefile +11 -4
- data/lib/asciidoctor.rb +30 -27
- data/lib/asciidoctor/abstract_node.rb +0 -5
- data/lib/asciidoctor/converter/html5.rb +1 -1
- data/lib/asciidoctor/extensions.rb +4 -5
- data/lib/asciidoctor/parser.rb +96 -105
- data/lib/asciidoctor/path_resolver.rb +7 -7
- data/lib/asciidoctor/reader.rb +88 -84
- data/lib/asciidoctor/substitutors.rb +19 -14
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +5 -5
- data/man/asciidoctor.adoc +1 -1
- data/test/attributes_test.rb +20 -20
- data/test/blocks_test.rb +51 -16
- data/test/converter_test.rb +10 -10
- data/test/document_test.rb +84 -69
- data/test/extensions_test.rb +48 -5
- data/test/invoker_test.rb +21 -21
- data/test/links_test.rb +4 -4
- data/test/lists_test.rb +10 -10
- data/test/paragraphs_test.rb +1 -1
- data/test/parser_test.rb +4 -4
- data/test/paths_test.rb +7 -0
- data/test/reader_test.rb +46 -12
- data/test/sections_test.rb +64 -42
- data/test/substitutions_test.rb +34 -14
- data/test/tables_test.rb +2 -2
- data/test/text_test.rb +12 -10
- metadata +3 -3
data/test/extensions_test.rb
CHANGED
@@ -228,7 +228,7 @@ context 'Extensions' do
|
|
228
228
|
|
229
229
|
test 'should register extension block' do
|
230
230
|
begin
|
231
|
-
Asciidoctor::Extensions.register
|
231
|
+
Asciidoctor::Extensions.register :sample do
|
232
232
|
end
|
233
233
|
refute_nil Asciidoctor::Extensions.groups
|
234
234
|
assert_equal 1, Asciidoctor::Extensions.groups.size
|
@@ -238,6 +238,17 @@ context 'Extensions' do
|
|
238
238
|
end
|
239
239
|
end
|
240
240
|
|
241
|
+
test 'should coerce group name to symbol when registering' do
|
242
|
+
begin
|
243
|
+
Asciidoctor::Extensions.register 'sample', SampleExtensionGroup
|
244
|
+
refute_nil Asciidoctor::Extensions.groups
|
245
|
+
assert_equal 1, Asciidoctor::Extensions.groups.size
|
246
|
+
assert_equal SampleExtensionGroup, Asciidoctor::Extensions.groups[:sample]
|
247
|
+
ensure
|
248
|
+
Asciidoctor::Extensions.unregister_all
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
241
252
|
test 'should unregister extension group by symbol name' do
|
242
253
|
begin
|
243
254
|
Asciidoctor::Extensions.register :sample, SampleExtensionGroup
|
@@ -465,7 +476,7 @@ context 'Extensions' do
|
|
465
476
|
registry = Asciidoctor::Extensions::Registry.new
|
466
477
|
registry.block SampleBlock, :sample
|
467
478
|
registry.activate Asciidoctor::Document.new
|
468
|
-
|
479
|
+
refute registry.registered_for_block? :sample, :sidebar
|
469
480
|
end
|
470
481
|
|
471
482
|
test 'should instantiate block macro processor' do
|
@@ -933,7 +944,7 @@ target="target", attributes=[]
|
|
933
944
|
begin
|
934
945
|
Asciidoctor::Extensions.register do
|
935
946
|
block do
|
936
|
-
named :
|
947
|
+
named :skipme
|
937
948
|
on_context :paragraph
|
938
949
|
parses_content_as :raw
|
939
950
|
process do |parent, reader, attrs|
|
@@ -943,7 +954,38 @@ target="target", attributes=[]
|
|
943
954
|
end
|
944
955
|
input = <<-EOS
|
945
956
|
.unused title
|
946
|
-
[
|
957
|
+
[skipme]
|
958
|
+
not rendered
|
959
|
+
|
960
|
+
--
|
961
|
+
rendered
|
962
|
+
--
|
963
|
+
EOS
|
964
|
+
doc = document_from_string input
|
965
|
+
assert_equal 1, doc.blocks.size
|
966
|
+
assert_nil doc.blocks[0].attributes['title']
|
967
|
+
ensure
|
968
|
+
Asciidoctor::Extensions.unregister_all
|
969
|
+
end
|
970
|
+
end
|
971
|
+
|
972
|
+
test 'should not invoke process method or carry over attributes if block processor declares skip content model' do
|
973
|
+
begin
|
974
|
+
process_method_called = false
|
975
|
+
Asciidoctor::Extensions.register do
|
976
|
+
block do
|
977
|
+
named :ignore
|
978
|
+
on_context :paragraph
|
979
|
+
parses_content_as :skip
|
980
|
+
process do |parent, reader, attrs|
|
981
|
+
process_method_called = true
|
982
|
+
nil
|
983
|
+
end
|
984
|
+
end
|
985
|
+
end
|
986
|
+
input = <<-EOS
|
987
|
+
.unused title
|
988
|
+
[ignore]
|
947
989
|
not rendered
|
948
990
|
|
949
991
|
--
|
@@ -951,6 +993,7 @@ rendered
|
|
951
993
|
--
|
952
994
|
EOS
|
953
995
|
doc = document_from_string input
|
996
|
+
refute process_method_called
|
954
997
|
assert_equal 1, doc.blocks.size
|
955
998
|
assert_nil doc.blocks[0].attributes['title']
|
956
999
|
ensure
|
@@ -1130,7 +1173,7 @@ sample content
|
|
1130
1173
|
:header_footer => true,
|
1131
1174
|
:safe => Asciidoctor::SafeMode::SERVER,
|
1132
1175
|
:attributes => {'docinfo' => ''}
|
1133
|
-
|
1176
|
+
refute_empty output
|
1134
1177
|
assert_css 'script[src="modernizr.js"]', output, 1
|
1135
1178
|
assert_css 'meta[name="robots"]', output, 1
|
1136
1179
|
assert_css 'meta[http-equiv="imagetoolbar"]', output, 0
|
data/test/invoker_test.rb
CHANGED
@@ -14,9 +14,9 @@ context 'Invoker' do
|
|
14
14
|
invoker = invoke_cli %w(-o -)
|
15
15
|
output = out.string
|
16
16
|
end
|
17
|
-
|
17
|
+
refute_nil invoker
|
18
18
|
doc = invoker.document
|
19
|
-
|
19
|
+
refute_nil doc
|
20
20
|
assert_equal 'Document Title', doc.doctitle
|
21
21
|
assert_equal 'Doc Writer', doc.attr('author')
|
22
22
|
assert_equal 'html5', doc.attr('backend')
|
@@ -24,7 +24,7 @@ context 'Invoker' do
|
|
24
24
|
assert_equal 'article', doc.attr('doctype')
|
25
25
|
assert doc.blocks?
|
26
26
|
assert_equal :preamble, doc.blocks.first.context
|
27
|
-
|
27
|
+
refute_empty output
|
28
28
|
assert_xpath '/html', output, 1
|
29
29
|
assert_xpath '/html/head', output, 1
|
30
30
|
assert_xpath '/html/body', output, 1
|
@@ -44,7 +44,7 @@ context 'Invoker' do
|
|
44
44
|
assert doc.attr?('docyear')
|
45
45
|
assert doc.attr?('doctime')
|
46
46
|
assert doc.attr?('docdatetime')
|
47
|
-
|
47
|
+
assert_empty invoker.read_output
|
48
48
|
end
|
49
49
|
|
50
50
|
test 'should allow docdate and doctime to be overridden' do
|
@@ -60,16 +60,16 @@ context 'Invoker' do
|
|
60
60
|
test 'should accept document from stdin and write to stdout' do
|
61
61
|
invoker = invoke_cli_to_buffer(%w(-s), '-') { 'content' }
|
62
62
|
doc = invoker.document
|
63
|
-
|
64
|
-
|
63
|
+
refute doc.attr?('docname')
|
64
|
+
refute doc.attr?('docfile')
|
65
65
|
assert_equal Dir.pwd, doc.attr('docdir')
|
66
66
|
assert_equal doc.attr('docdate'), doc.attr('localdate')
|
67
67
|
assert_equal doc.attr('docyear'), doc.attr('localyear')
|
68
68
|
assert_equal doc.attr('doctime'), doc.attr('localtime')
|
69
69
|
assert_equal doc.attr('docdatetime'), doc.attr('localdatetime')
|
70
|
-
|
70
|
+
refute doc.attr?('outfile')
|
71
71
|
output = invoker.read_output
|
72
|
-
|
72
|
+
refute_empty output
|
73
73
|
assert_xpath '/*[@class="paragraph"]/p[text()="content"]', output, 1
|
74
74
|
end
|
75
75
|
|
@@ -90,8 +90,8 @@ context 'Invoker' do
|
|
90
90
|
begin
|
91
91
|
invoker = invoke_cli(%W(-s -o #{sample_outpath}), '-') { 'content' }
|
92
92
|
doc = invoker.document
|
93
|
-
|
94
|
-
|
93
|
+
refute doc.attr?('docname')
|
94
|
+
refute doc.attr?('docfile')
|
95
95
|
assert_equal Dir.pwd, doc.attr('docdir')
|
96
96
|
assert_equal doc.attr('docdate'), doc.attr('localdate')
|
97
97
|
assert_equal doc.attr('docyear'), doc.attr('localyear')
|
@@ -210,7 +210,7 @@ context 'Invoker' do
|
|
210
210
|
assert_equal sample_outpath, doc.attr('outfile')
|
211
211
|
assert File.exist?(sample_outpath)
|
212
212
|
output = IO.read(sample_outpath)
|
213
|
-
|
213
|
+
refute_empty output
|
214
214
|
assert_xpath '/html', output, 1
|
215
215
|
assert_xpath '/html/head', output, 1
|
216
216
|
assert_xpath '/html/body', output, 1
|
@@ -274,7 +274,7 @@ context 'Invoker' do
|
|
274
274
|
invoker = invoke_cli %W(-o #{sample_outpath} -a linkcss -a copycss!)
|
275
275
|
invoker.document
|
276
276
|
assert File.exist?(sample_outpath)
|
277
|
-
|
277
|
+
refute File.exist?(default_stylesheet)
|
278
278
|
ensure
|
279
279
|
FileUtils.rm_f(sample_outpath)
|
280
280
|
FileUtils.rm_f(default_stylesheet)
|
@@ -308,7 +308,7 @@ context 'Invoker' do
|
|
308
308
|
invoker = invoke_cli %W(-o #{sample_outpath} -a linkcss -a stylesdir=./styles -a stylesheet=custom.css -a copycss!)
|
309
309
|
invoker.document
|
310
310
|
assert File.exist?(sample_outpath)
|
311
|
-
|
311
|
+
refute File.exist?(custom_stylesheet)
|
312
312
|
ensure
|
313
313
|
FileUtils.rm_f(sample_outpath)
|
314
314
|
FileUtils.rm_f(custom_stylesheet)
|
@@ -325,7 +325,7 @@ context 'Invoker' do
|
|
325
325
|
invoker = invoke_cli %W(-o #{sample_outpath} -a linkcss -a stylesdir=http://example.org/styles -a stylesheet=custom.css)
|
326
326
|
invoker.document
|
327
327
|
assert File.exist?(sample_outpath)
|
328
|
-
|
328
|
+
refute File.exist?(stylesdir)
|
329
329
|
ensure
|
330
330
|
FileUtils.rm_f(sample_outpath)
|
331
331
|
FileUtils.rmdir(stylesdir) if File.directory? stylesdir
|
@@ -401,8 +401,8 @@ context 'Invoker' do
|
|
401
401
|
invoker = invoke_cli %w(-o -)
|
402
402
|
output = out.string
|
403
403
|
end
|
404
|
-
|
405
|
-
|
404
|
+
refute_nil invoker
|
405
|
+
refute_nil output
|
406
406
|
assert output.end_with?("\n")
|
407
407
|
end
|
408
408
|
|
@@ -529,7 +529,7 @@ context 'Invoker' do
|
|
529
529
|
test 'should unset attribute ending in bang' do
|
530
530
|
invoker = invoke_cli_to_buffer %w(-a sectids! -s -o -)
|
531
531
|
doc = invoker.document
|
532
|
-
|
532
|
+
refute doc.attr?('sectids')
|
533
533
|
output = invoker.read_output
|
534
534
|
# leave the count loose in case we add more sections
|
535
535
|
assert_xpath '//h2[not(@id)]', output
|
@@ -581,9 +581,9 @@ context 'Invoker' do
|
|
581
581
|
_, out, _ = Open3.popen3 cmd
|
582
582
|
#stderr_lines = stderr.readlines
|
583
583
|
# warnings may be issued, so don't assert on stderr
|
584
|
-
#
|
584
|
+
#assert_empty stderr_lines, 'Command failed. Expected to receive a rendered document.'
|
585
585
|
stdout_lines = out.readlines
|
586
|
-
|
586
|
+
refute_empty stdout_lines
|
587
587
|
stdout_lines.each {|l| l.force_encoding Encoding::UTF_8 } if Asciidoctor::FORCE_ENCODING
|
588
588
|
stdout_str = stdout_lines.join
|
589
589
|
assert stdout_str.include?('Codierungen sind verrückt auf älteren Versionen von Ruby')
|
@@ -602,8 +602,8 @@ context 'Invoker' do
|
|
602
602
|
invoker = invoke_cli(%w(-t -o /dev/null), '-') { input }
|
603
603
|
error = err.string
|
604
604
|
end
|
605
|
-
|
606
|
-
|
605
|
+
refute_nil invoker
|
606
|
+
refute_nil error
|
607
607
|
assert_match(/Total time/, error)
|
608
608
|
end
|
609
609
|
|
data/test/links_test.rb
CHANGED
@@ -380,7 +380,7 @@ anchor:foo[b[a\]r]text'
|
|
380
380
|
|
381
381
|
test 'xref using angled bracket syntax with path sans extension' do
|
382
382
|
doc = document_from_string '<<tigers#>>', :header_footer => false
|
383
|
-
assert_xpath '//a[@href="tigers.html"][text() = "
|
383
|
+
assert_xpath '//a[@href="tigers.html"][text() = "tigers.html"]', doc.render, 1
|
384
384
|
end
|
385
385
|
|
386
386
|
test 'inter-document xref should not truncate after period if path has no extension' do
|
@@ -412,12 +412,12 @@ anchor:foo[b[a\]r]text'
|
|
412
412
|
|
413
413
|
test 'xref using angled bracket syntax with path and extension' do
|
414
414
|
doc = document_from_string '<<tigers.adoc#>>', :header_footer => false
|
415
|
-
assert_xpath '//a[@href="tigers.html"][text() = "
|
415
|
+
assert_xpath '//a[@href="tigers.html"][text() = "tigers.html"]', doc.render, 1
|
416
416
|
end
|
417
417
|
|
418
418
|
test 'xref using angled bracket syntax with path and fragment' do
|
419
419
|
doc = document_from_string '<<tigers#about>>', :header_footer => false
|
420
|
-
assert_xpath '//a[@href="tigers.html#about"][text() = "
|
420
|
+
assert_xpath '//a[@href="tigers.html#about"][text() = "tigers.html"]', doc.render, 1
|
421
421
|
end
|
422
422
|
|
423
423
|
test 'xref using angled bracket syntax with path, fragment and text' do
|
@@ -575,7 +575,7 @@ See <<foobaz>>.
|
|
575
575
|
old_verbose, $VERBOSE = $VERBOSE, true
|
576
576
|
output, warnings = redirect_streams {|_, err| [(render_embedded_string input), err.string] }
|
577
577
|
assert_xpath '//a[@href="#foobaz"][text() = "[foobaz]"]', output, 1
|
578
|
-
|
578
|
+
refute_empty warnings
|
579
579
|
assert_includes warnings, 'asciidoctor: WARNING: invalid reference: foobaz'
|
580
580
|
ensure
|
581
581
|
$VERBOSE = old_verbose
|
data/test/lists_test.rb
CHANGED
@@ -185,7 +185,7 @@ Bar
|
|
185
185
|
|
186
186
|
output = render_embedded_string input
|
187
187
|
assert_css 'ul ul', output, 1
|
188
|
-
|
188
|
+
refute output.include?('* Foo')
|
189
189
|
end
|
190
190
|
|
191
191
|
test 'a list item for a different list terminates non-indented paragraph for text of list item' do
|
@@ -205,9 +205,9 @@ term:: def
|
|
205
205
|
|
206
206
|
output = render_embedded_string input
|
207
207
|
assert_css 'ul ol', output, 1
|
208
|
-
|
208
|
+
refute output.include?('* Foo')
|
209
209
|
assert_css 'ul dl', output, 1
|
210
|
-
|
210
|
+
refute output.include?('term:: def')
|
211
211
|
end
|
212
212
|
|
213
213
|
test 'an indented wrapped line is unindented and folded into text of list item' do
|
@@ -255,7 +255,7 @@ second wrapped line
|
|
255
255
|
|
256
256
|
output = render_embedded_string input
|
257
257
|
assert_css 'ul ul', output, 1
|
258
|
-
|
258
|
+
refute output.include?('* Foo')
|
259
259
|
end
|
260
260
|
|
261
261
|
test 'a list item that starts with a sequence of list markers characters should not match a nested list' do
|
@@ -287,9 +287,9 @@ term:: def
|
|
287
287
|
|
288
288
|
output = render_embedded_string input
|
289
289
|
assert_css 'ul ol', output, 1
|
290
|
-
|
290
|
+
refute output.include?('* Foo')
|
291
291
|
assert_css 'ul dl', output, 1
|
292
|
-
|
292
|
+
refute output.include?('term:: def')
|
293
293
|
end
|
294
294
|
|
295
295
|
test "a literal paragraph offset by blank lines in list content is appended as a literal block" do
|
@@ -4471,7 +4471,7 @@ label:: desc
|
|
4471
4471
|
|
4472
4472
|
doc = document_from_string input
|
4473
4473
|
list = doc.blocks.first
|
4474
|
-
|
4474
|
+
refute list.outline?
|
4475
4475
|
end
|
4476
4476
|
|
4477
4477
|
test 'simple? should return true for list item with no nested blocks' do
|
@@ -4484,7 +4484,7 @@ label:: desc
|
|
4484
4484
|
doc = document_from_string input
|
4485
4485
|
list = doc.blocks.first
|
4486
4486
|
assert list.items.first.simple?
|
4487
|
-
|
4487
|
+
refute list.items.first.compound?
|
4488
4488
|
end
|
4489
4489
|
|
4490
4490
|
test 'simple? should return true for list item with nested outline list' do
|
@@ -4499,7 +4499,7 @@ label:: desc
|
|
4499
4499
|
doc = document_from_string input
|
4500
4500
|
list = doc.blocks.first
|
4501
4501
|
assert list.items.first.simple?
|
4502
|
-
|
4502
|
+
refute list.items.first.compound?
|
4503
4503
|
end
|
4504
4504
|
|
4505
4505
|
test 'simple? should return false for list item with block content' do
|
@@ -4515,7 +4515,7 @@ listing block in list item 1
|
|
4515
4515
|
|
4516
4516
|
doc = document_from_string input
|
4517
4517
|
list = doc.blocks.first
|
4518
|
-
|
4518
|
+
refute list.items.first.simple?
|
4519
4519
|
assert list.items.first.compound?
|
4520
4520
|
end
|
4521
4521
|
|
data/test/paragraphs_test.rb
CHANGED
data/test/parser_test.rb
CHANGED
@@ -606,7 +606,7 @@ v8.6.8,
|
|
606
606
|
metadata, _ = parse_header_metadata input
|
607
607
|
assert_equal 7, metadata.size
|
608
608
|
assert_equal '8.6.8', metadata['revnumber']
|
609
|
-
|
609
|
+
refute metadata.has_key?('revdate')
|
610
610
|
end
|
611
611
|
|
612
612
|
# Asciidoctor recognizes a standalone revision without a trailing comma
|
@@ -618,7 +618,7 @@ v8.6.8
|
|
618
618
|
metadata, _ = parse_header_metadata input
|
619
619
|
assert_equal 7, metadata.size
|
620
620
|
assert_equal '8.6.8', metadata['revnumber']
|
621
|
-
|
621
|
+
refute metadata.has_key?('revdate')
|
622
622
|
end
|
623
623
|
|
624
624
|
# while compliant w/ AsciiDoc, this is just sloppy parsing
|
@@ -650,7 +650,7 @@ Joe Cool
|
|
650
650
|
EOS
|
651
651
|
metadata, _ = parse_header_metadata input
|
652
652
|
refute_equal 'page-layout: post', metadata['revremark']
|
653
|
-
|
653
|
+
refute metadata.has_key?('revdate')
|
654
654
|
end
|
655
655
|
|
656
656
|
test "parse rev remark only" do
|
@@ -660,7 +660,7 @@ Joe Cool
|
|
660
660
|
EOS
|
661
661
|
metadata, _ = parse_header_metadata input
|
662
662
|
assert_equal 'Must start revremark-only line with space', metadata['revremark']
|
663
|
-
|
663
|
+
refute metadata.has_key?('revdate')
|
664
664
|
end
|
665
665
|
|
666
666
|
test "skip line comments before author" do
|
data/test/paths_test.rb
CHANGED
@@ -248,6 +248,13 @@ context 'Path Resolver' do
|
|
248
248
|
assert_equal 'part1/chapter1/section1.adoc', @resolver.relative_path(filename, JAIL)
|
249
249
|
end
|
250
250
|
|
251
|
+
test 'should resolve relative path to filename if does not share common root with base directory' do
|
252
|
+
filename = '/docs/partials'
|
253
|
+
base_dir = '/home/user/docs'
|
254
|
+
result = @resolver.relative_path filename, base_dir
|
255
|
+
assert_equal filename, result
|
256
|
+
end
|
257
|
+
|
251
258
|
test 'should resolve relative path relative to base dir in unsafe mode' do
|
252
259
|
base_dir = fixture_path 'base'
|
253
260
|
doc = empty_document :base_dir => base_dir, :safe => Asciidoctor::SafeMode::UNSAFE
|
data/test/reader_test.rb
CHANGED
@@ -73,7 +73,7 @@ third line
|
|
73
73
|
|
74
74
|
context 'With empty data' do
|
75
75
|
test 'has_more_lines? should return false with empty data' do
|
76
|
-
|
76
|
+
refute Asciidoctor::Reader.new.has_more_lines?
|
77
77
|
end
|
78
78
|
|
79
79
|
test 'empty? should return true with empty data' do
|
@@ -90,7 +90,7 @@ third line
|
|
90
90
|
end
|
91
91
|
|
92
92
|
test 'peek_lines should return empty Array with empty data' do
|
93
|
-
assert_equal [], Asciidoctor::Reader.new.peek_lines
|
93
|
+
assert_equal [], Asciidoctor::Reader.new.peek_lines(1)
|
94
94
|
end
|
95
95
|
|
96
96
|
test 'read_line should return nil with empty data' do
|
@@ -112,13 +112,13 @@ third line
|
|
112
112
|
|
113
113
|
test 'empty? should return false if there are lines remaining' do
|
114
114
|
reader = Asciidoctor::Reader.new SAMPLE_DATA
|
115
|
-
|
116
|
-
|
115
|
+
refute reader.empty?
|
116
|
+
refute reader.eof?
|
117
117
|
end
|
118
118
|
|
119
119
|
test 'next_line_empty? should return false if next line is not blank' do
|
120
120
|
reader = Asciidoctor::Reader.new SAMPLE_DATA
|
121
|
-
|
121
|
+
refute reader.next_line_empty?
|
122
122
|
end
|
123
123
|
|
124
124
|
test 'next_line_empty? should return true if next line is blank' do
|
@@ -180,7 +180,7 @@ third line
|
|
180
180
|
assert reader.advance
|
181
181
|
assert reader.advance
|
182
182
|
assert reader.advance
|
183
|
-
|
183
|
+
refute reader.advance
|
184
184
|
end
|
185
185
|
|
186
186
|
test 'read_lines should return all lines' do
|
@@ -196,7 +196,7 @@ third line
|
|
196
196
|
test 'has_more_lines? should return false after read_lines is invoked' do
|
197
197
|
reader = Asciidoctor::Reader.new SAMPLE_DATA
|
198
198
|
reader.read_lines
|
199
|
-
|
199
|
+
refute reader.has_more_lines?
|
200
200
|
end
|
201
201
|
|
202
202
|
test 'unshift puts line onto Reader as next line to read' do
|
@@ -273,7 +273,7 @@ This is another paragraph.
|
|
273
273
|
result = reader.read_lines_until
|
274
274
|
assert_equal 3, result.size
|
275
275
|
assert_equal lines.map {|l| l.chomp }, result
|
276
|
-
|
276
|
+
refute reader.has_more_lines?
|
277
277
|
assert reader.eof?
|
278
278
|
end
|
279
279
|
|
@@ -411,9 +411,9 @@ endlines\r
|
|
411
411
|
doc = Asciidoctor::Document.new lines
|
412
412
|
reader = doc.reader
|
413
413
|
reader.lines.each do |line|
|
414
|
-
|
415
|
-
|
416
|
-
|
414
|
+
refute line.end_with?("\r"), "CRLF not properly cleaned for source lines: #{lines.inspect}"
|
415
|
+
refute line.end_with?("\r\n"), "CRLF not properly cleaned for source lines: #{lines.inspect}"
|
416
|
+
refute line.end_with?("\n"), "CRLF not properly cleaned for source lines: #{lines.inspect}"
|
417
417
|
end
|
418
418
|
end
|
419
419
|
end
|
@@ -434,7 +434,7 @@ preamble
|
|
434
434
|
|
435
435
|
doc = Asciidoctor::Document.new input
|
436
436
|
reader = doc.reader
|
437
|
-
|
437
|
+
refute doc.attributes.key?('front-matter')
|
438
438
|
assert_equal '---', reader.peek_line
|
439
439
|
end
|
440
440
|
|
@@ -1244,6 +1244,40 @@ endif::asciidoctor[]
|
|
1244
1244
|
assert_equal 2, reader.lineno
|
1245
1245
|
end
|
1246
1246
|
|
1247
|
+
test 'peek_lines should preprocess lines if direct is false' do
|
1248
|
+
input = <<-EOS
|
1249
|
+
The Asciidoctor
|
1250
|
+
ifdef::asciidoctor[is in.]
|
1251
|
+
EOS
|
1252
|
+
doc = Asciidoctor::Document.new input
|
1253
|
+
reader = doc.reader
|
1254
|
+
result = reader.peek_lines 2, false
|
1255
|
+
assert_equal ['The Asciidoctor', 'is in.'], result
|
1256
|
+
end
|
1257
|
+
|
1258
|
+
test 'peek_lines should not preprocess lines if direct is true' do
|
1259
|
+
input = <<-EOS
|
1260
|
+
The Asciidoctor
|
1261
|
+
ifdef::asciidoctor[is in.]
|
1262
|
+
EOS
|
1263
|
+
doc = Asciidoctor::Document.new input
|
1264
|
+
reader = doc.reader
|
1265
|
+
result = reader.peek_lines 2, true
|
1266
|
+
assert_equal ['The Asciidoctor', 'ifdef::asciidoctor[is in.]'], result
|
1267
|
+
end
|
1268
|
+
|
1269
|
+
test 'peek_lines should not prevent subsequent preprocessing of peeked lines' do
|
1270
|
+
input = <<-EOS
|
1271
|
+
The Asciidoctor
|
1272
|
+
ifdef::asciidoctor[is in.]
|
1273
|
+
EOS
|
1274
|
+
doc = Asciidoctor::Document.new input
|
1275
|
+
reader = doc.reader
|
1276
|
+
result = reader.peek_lines 2, true
|
1277
|
+
result = reader.peek_lines 2, false
|
1278
|
+
assert_equal ['The Asciidoctor', 'is in.'], result
|
1279
|
+
end
|
1280
|
+
|
1247
1281
|
test 'process_line returns line if cursor not advanced' do
|
1248
1282
|
input = <<-EOS
|
1249
1283
|
content
|