asciidoctor 1.5.2 → 1.5.3
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 +107 -1
- data/LICENSE.adoc +1 -1
- data/README.adoc +155 -230
- data/Rakefile +2 -1
- data/bin/asciidoctor +5 -1
- data/data/stylesheets/asciidoctor-default.css +37 -29
- data/data/stylesheets/coderay-asciidoctor.css +3 -3
- data/features/text_formatting.feature +2 -0
- data/lib/asciidoctor.rb +46 -21
- data/lib/asciidoctor/abstract_block.rb +14 -8
- data/lib/asciidoctor/abstract_node.rb +77 -24
- data/lib/asciidoctor/attribute_list.rb +1 -1
- data/lib/asciidoctor/block.rb +2 -3
- data/lib/asciidoctor/cli/options.rb +14 -15
- data/lib/asciidoctor/converter/docbook45.rb +8 -8
- data/lib/asciidoctor/converter/docbook5.rb +25 -17
- data/lib/asciidoctor/converter/factory.rb +6 -1
- data/lib/asciidoctor/converter/html5.rb +159 -117
- data/lib/asciidoctor/converter/manpage.rb +671 -0
- data/lib/asciidoctor/converter/template.rb +24 -17
- data/lib/asciidoctor/document.rb +89 -47
- data/lib/asciidoctor/extensions.rb +22 -21
- data/lib/asciidoctor/helpers.rb +73 -16
- data/lib/asciidoctor/list.rb +26 -5
- data/lib/asciidoctor/parser.rb +179 -122
- data/lib/asciidoctor/path_resolver.rb +6 -10
- data/lib/asciidoctor/reader.rb +37 -34
- data/lib/asciidoctor/stylesheets.rb +16 -10
- data/lib/asciidoctor/substitutors.rb +98 -21
- data/lib/asciidoctor/table.rb +21 -17
- data/lib/asciidoctor/timings.rb +3 -3
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +155 -89
- data/man/asciidoctor.adoc +19 -11
- data/test/attributes_test.rb +86 -0
- data/test/blocks_test.rb +203 -15
- data/test/converter_test.rb +15 -2
- data/test/document_test.rb +290 -36
- data/test/extensions_test.rb +22 -3
- data/test/fixtures/circle.svg +8 -0
- data/test/fixtures/subs-docinfo.html +2 -0
- data/test/fixtures/subs.adoc +7 -0
- data/test/invoker_test.rb +25 -0
- data/test/links_test.rb +17 -0
- data/test/lists_test.rb +173 -0
- data/test/options_test.rb +2 -2
- data/test/paragraphs_test.rb +2 -2
- data/test/parser_test.rb +56 -13
- data/test/reader_test.rb +35 -3
- data/test/sections_test.rb +59 -0
- data/test/substitutions_test.rb +53 -14
- data/test/tables_test.rb +158 -2
- data/test/test_helper.rb +7 -2
- metadata +22 -11
- data/benchmark/benchmark.rb +0 -129
- data/benchmark/sample-data/mdbasics.adoc +0 -334
- data/lib/asciidoctor/opal_ext.rb +0 -26
- data/lib/asciidoctor/opal_ext/comparable.rb +0 -38
- data/lib/asciidoctor/opal_ext/dir.rb +0 -13
- data/lib/asciidoctor/opal_ext/error.rb +0 -2
- data/lib/asciidoctor/opal_ext/file.rb +0 -145
data/test/extensions_test.rb
CHANGED
@@ -125,7 +125,7 @@ end
|
|
125
125
|
|
126
126
|
class MetaAppDocinfoProcessor < Asciidoctor::Extensions::DocinfoProcessor
|
127
127
|
use_dsl
|
128
|
-
at_location :
|
128
|
+
at_location :head
|
129
129
|
|
130
130
|
def process document
|
131
131
|
'<meta name="application-name" content="Asciidoctor App">'
|
@@ -310,7 +310,7 @@ context 'Extensions' do
|
|
310
310
|
registry.docinfo_processor SampleDocinfoProcessor
|
311
311
|
registry.activate Asciidoctor::Document.new
|
312
312
|
assert registry.docinfo_processors?
|
313
|
-
assert registry.docinfo_processors?(:
|
313
|
+
assert registry.docinfo_processors?(:head)
|
314
314
|
extensions = registry.docinfo_processors
|
315
315
|
assert_equal 1, extensions.size
|
316
316
|
assert extensions.first.is_a? Asciidoctor::Extensions::ProcessorExtension
|
@@ -589,6 +589,25 @@ snippet::12345[]
|
|
589
589
|
end
|
590
590
|
end
|
591
591
|
|
592
|
+
test 'should resolve regexp for inline macro lazily' do
|
593
|
+
begin
|
594
|
+
Asciidoctor::Extensions.register do
|
595
|
+
inline_macro do
|
596
|
+
named :label
|
597
|
+
using_format :short
|
598
|
+
process do |parent, target|
|
599
|
+
%(<label>#{target}</label>)
|
600
|
+
end
|
601
|
+
end
|
602
|
+
end
|
603
|
+
|
604
|
+
output = render_embedded_string 'label:[Checkbox]'
|
605
|
+
assert output.include?('<label>Checkbox</label>')
|
606
|
+
ensure
|
607
|
+
Asciidoctor::Extensions.unregister_all
|
608
|
+
end
|
609
|
+
end
|
610
|
+
|
592
611
|
test 'should not carry over attributes if block processor returns nil' do
|
593
612
|
begin
|
594
613
|
Asciidoctor::Extensions.register do
|
@@ -687,7 +706,7 @@ sample content
|
|
687
706
|
|
688
707
|
doc = document_from_string input, :safe => :server
|
689
708
|
assert_equal '<meta name="robots" content="index,follow">
|
690
|
-
<meta name="application-name" content="Asciidoctor App">', doc.docinfo
|
709
|
+
<meta name="application-name" content="Asciidoctor App">', doc.docinfo
|
691
710
|
assert_equal '<script><!-- analytics code --></script>', doc.docinfo(:footer)
|
692
711
|
ensure
|
693
712
|
Asciidoctor::Extensions.unregister_all
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
3
|
+
<!-- An SVG of a black circle -->
|
4
|
+
<svg viewBox="0 0 120 120" version="1.1"
|
5
|
+
xmlns="http://www.w3.org/2000/svg" style="width:500px;height:500px"
|
6
|
+
width="500px" height="500px">
|
7
|
+
<circle cx="60" cy="60" r="50"/>
|
8
|
+
</svg>
|
data/test/invoker_test.rb
CHANGED
@@ -46,6 +46,15 @@ context 'Invoker' do
|
|
46
46
|
assert invoker.read_output.empty?
|
47
47
|
end
|
48
48
|
|
49
|
+
test 'should allow docdate and doctime to be overridden' do
|
50
|
+
sample_filepath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.asciidoc'))
|
51
|
+
invoker = invoke_cli_to_buffer %w(-o /dev/null -a docdate=2015-01-01 -a doctime=10:00:00-07:00), sample_filepath
|
52
|
+
doc = invoker.document
|
53
|
+
assert doc.attr?('docdate', '2015-01-01')
|
54
|
+
assert doc.attr?('doctime', '10:00:00-07:00')
|
55
|
+
assert doc.attr?('docdatetime', '2015-01-01 10:00:00-07:00')
|
56
|
+
end
|
57
|
+
|
49
58
|
test 'should accept document from stdin and write to stdout' do
|
50
59
|
invoker = invoke_cli_to_buffer(%w(-s), '-') { 'content' }
|
51
60
|
doc = invoker.document
|
@@ -277,6 +286,22 @@ context 'Invoker' do
|
|
277
286
|
end
|
278
287
|
end
|
279
288
|
|
289
|
+
test 'should not copy custom stylesheet to target directory if stylesdir is a URI' do
|
290
|
+
destdir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'output'))
|
291
|
+
sample_outpath = File.join destdir, 'sample-output.html'
|
292
|
+
stylesdir = File.join destdir, 'http:'
|
293
|
+
begin
|
294
|
+
invoker = invoke_cli %W(-o #{sample_outpath} -a linkcss -a stylesdir=http://example.org/styles -a stylesheet=custom.css)
|
295
|
+
invoker.document
|
296
|
+
assert File.exist?(sample_outpath)
|
297
|
+
assert !File.exist?(stylesdir)
|
298
|
+
ensure
|
299
|
+
FileUtils.rm_f(sample_outpath)
|
300
|
+
FileUtils.rmdir(stylesdir) if File.directory? stylesdir
|
301
|
+
FileUtils.rmdir(destdir)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
280
305
|
test 'should render all passed files' do
|
281
306
|
basic_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'basic.html'))
|
282
307
|
sample_outpath = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'sample.html'))
|
data/test/links_test.rb
CHANGED
@@ -202,6 +202,23 @@ context 'Links' do
|
|
202
202
|
assert_xpath '//a[@href="tigers.html"][text() = "[tigers]"]', doc.render, 1
|
203
203
|
end
|
204
204
|
|
205
|
+
test 'xref using angled bracket syntax with path sans extension using docbook backend' do
|
206
|
+
doc = document_from_string '<<tigers#>>', :header_footer => false, :backend => 'docbook'
|
207
|
+
assert_match '<link xlink:href="tigers.xml">tigers.xml</link>', doc.render, 1
|
208
|
+
doc = document_from_string '<<tigers#>>', :header_footer => false, :backend => 'docbook45'
|
209
|
+
assert_match '<ulink url="tigers.xml">tigers.xml</ulink>', doc.render, 1
|
210
|
+
end
|
211
|
+
|
212
|
+
test 'xref using angled bracket syntax with ancestor path sans extension' do
|
213
|
+
doc = document_from_string '<<../tigers#,tigers>>', :header_footer => false
|
214
|
+
assert_xpath '//a[@href="../tigers.html"][text() = "tigers"]', doc.render, 1
|
215
|
+
end
|
216
|
+
|
217
|
+
test 'xref using angled bracket syntax with absolute path sans extension' do
|
218
|
+
doc = document_from_string '<</path/to/tigers#,tigers>>', :header_footer => false
|
219
|
+
assert_xpath '//a[@href="/path/to/tigers.html"][text() = "tigers"]', doc.render, 1
|
220
|
+
end
|
221
|
+
|
205
222
|
test 'xref using angled bracket syntax with path and extension' do
|
206
223
|
doc = document_from_string '<<tigers.adoc#>>', :header_footer => false
|
207
224
|
assert_xpath '//a[@href="tigers.html"][text() = "[tigers]"]', doc.render, 1
|
data/test/lists_test.rb
CHANGED
@@ -453,6 +453,17 @@ List
|
|
453
453
|
assert_xpath '//ul/li', output, 3
|
454
454
|
end
|
455
455
|
|
456
|
+
test 'indented unicode bullet elements using spaces' do
|
457
|
+
input = <<-EOS
|
458
|
+
• Foo
|
459
|
+
• Boo
|
460
|
+
• Blech
|
461
|
+
EOS
|
462
|
+
output = render_string input
|
463
|
+
assert_xpath '//ul', output, 1
|
464
|
+
assert_xpath '//ul/li', output, 3
|
465
|
+
end if ::RUBY_MIN_VERSION_1_9
|
466
|
+
|
456
467
|
test 'indented asterisk elements using tabs' do
|
457
468
|
input = <<-EOS
|
458
469
|
\t*\tFoo
|
@@ -804,6 +815,27 @@ List
|
|
804
815
|
assert_xpath '(((((//ul)[1]/li//ul)[1]/li//ul)[1]/li//ul)[1]/li//ul)[1]/li', output, 1
|
805
816
|
end
|
806
817
|
|
818
|
+
test 'nested elements (5) with unicode bullet' do
|
819
|
+
input = <<-EOS
|
820
|
+
List
|
821
|
+
====
|
822
|
+
|
823
|
+
• Foo
|
824
|
+
•• Boo
|
825
|
+
••• Snoo
|
826
|
+
•••• Froo
|
827
|
+
••••• Groo
|
828
|
+
• Blech
|
829
|
+
EOS
|
830
|
+
output = render_string input
|
831
|
+
assert_xpath '//ul', output, 5
|
832
|
+
assert_xpath '(//ul)[1]/li', output, 2
|
833
|
+
assert_xpath '((//ul)[1]/li//ul)[1]/li', output, 1
|
834
|
+
assert_xpath '(((//ul)[1]/li//ul)[1]/li//ul)[1]/li', output, 1
|
835
|
+
assert_xpath '((((//ul)[1]/li//ul)[1]/li//ul)[1]/li//ul)[1]/li', output, 1
|
836
|
+
assert_xpath '(((((//ul)[1]/li//ul)[1]/li//ul)[1]/li//ul)[1]/li//ul)[1]/li', output, 1
|
837
|
+
end if ::RUBY_MIN_VERSION_1_9
|
838
|
+
|
807
839
|
test "nested ordered elements (2)" do
|
808
840
|
input = <<-EOS
|
809
841
|
List
|
@@ -1848,6 +1880,39 @@ term2::
|
|
1848
1880
|
assert_xpath '(//dl/dt)[2]/following-sibling::dd/p[text() = "def2"]', output, 1
|
1849
1881
|
end
|
1850
1882
|
|
1883
|
+
test "multi-line elements with indented paragraph content that includes comment lines" do
|
1884
|
+
input = <<-EOS
|
1885
|
+
term1::
|
1886
|
+
def1
|
1887
|
+
// comment
|
1888
|
+
term2::
|
1889
|
+
def2
|
1890
|
+
// comment
|
1891
|
+
def2 continued
|
1892
|
+
EOS
|
1893
|
+
output = render_embedded_string input
|
1894
|
+
assert_xpath '//dl', output, 1
|
1895
|
+
assert_xpath '//dl/dt', output, 2
|
1896
|
+
assert_xpath '//dl/dt/following-sibling::dd', output, 2
|
1897
|
+
assert_xpath '(//dl/dt)[1][normalize-space(text()) = "term1"]', output, 1
|
1898
|
+
assert_xpath '(//dl/dt)[1]/following-sibling::dd/p[text() = "def1"]', output, 1
|
1899
|
+
assert_xpath '(//dl/dt)[2][normalize-space(text()) = "term2"]', output, 1
|
1900
|
+
assert_xpath %((//dl/dt)[2]/following-sibling::dd/p[text() = "def2\ndef2 continued"]), output, 1
|
1901
|
+
end
|
1902
|
+
|
1903
|
+
test "should not strip comment line in literal paragraph block attached to list item" do
|
1904
|
+
input = <<-EOS
|
1905
|
+
term1::
|
1906
|
+
+
|
1907
|
+
line 1
|
1908
|
+
// not a comment
|
1909
|
+
line 3
|
1910
|
+
EOS
|
1911
|
+
output = render_embedded_string input
|
1912
|
+
assert_xpath '//*[@class="literalblock"]', output, 1
|
1913
|
+
assert_xpath %(//*[@class="literalblock"]//pre[text()=" line 1\n// not a comment\n line 3"]), output, 1
|
1914
|
+
end
|
1915
|
+
|
1851
1916
|
test 'multi-line element with paragraph starting with multiple dashes should not be seen as list' do
|
1852
1917
|
input = <<-EOS
|
1853
1918
|
term1::
|
@@ -2225,6 +2290,18 @@ section text
|
|
2225
2290
|
assert_xpath '/*[@class="sect1"]/h2[text()="Section"]', output, 1
|
2226
2291
|
assert_xpath '/*[@class="ulist"]/following-sibling::*[@class="sect1"]', output, 1
|
2227
2292
|
end
|
2293
|
+
|
2294
|
+
test 'more than 4 consecutive colons should become part of description list term' do
|
2295
|
+
input = <<-EOS
|
2296
|
+
A term::::: a description
|
2297
|
+
EOS
|
2298
|
+
|
2299
|
+
output = render_embedded_string input
|
2300
|
+
assert_xpath '//dl', output, 1
|
2301
|
+
assert_xpath '//dt', output, 1
|
2302
|
+
assert_xpath '//dt[text()="A term:"]', output, 1
|
2303
|
+
assert_xpath '//dd/p[text()="a description"]', output, 1
|
2304
|
+
end
|
2228
2305
|
end
|
2229
2306
|
|
2230
2307
|
context "Nested lists" do
|
@@ -4179,4 +4256,100 @@ context 'Lists model' do
|
|
4179
4256
|
assert_equal 3, items.size
|
4180
4257
|
assert_equal list.items, list.content
|
4181
4258
|
end
|
4259
|
+
|
4260
|
+
test 'list item should be the parent of block attached to a list item' do
|
4261
|
+
input = <<-EOS
|
4262
|
+
* list item 1
|
4263
|
+
+
|
4264
|
+
----
|
4265
|
+
listing block in list item 1
|
4266
|
+
----
|
4267
|
+
EOS
|
4268
|
+
|
4269
|
+
doc = document_from_string input
|
4270
|
+
list = doc.blocks.first
|
4271
|
+
list_item_1 = list.items.first
|
4272
|
+
listing_block = list_item_1.blocks.first
|
4273
|
+
assert_equal :listing, listing_block.context
|
4274
|
+
assert_equal list_item_1, listing_block.parent
|
4275
|
+
end
|
4276
|
+
|
4277
|
+
test 'outline? should return true for unordered list' do
|
4278
|
+
input = <<-EOS
|
4279
|
+
* one
|
4280
|
+
* two
|
4281
|
+
* three
|
4282
|
+
EOS
|
4283
|
+
|
4284
|
+
doc = document_from_string input
|
4285
|
+
list = doc.blocks.first
|
4286
|
+
assert list.outline?
|
4287
|
+
end
|
4288
|
+
|
4289
|
+
test 'outline? should return true for ordered list' do
|
4290
|
+
input = <<-EOS
|
4291
|
+
. one
|
4292
|
+
. two
|
4293
|
+
. three
|
4294
|
+
EOS
|
4295
|
+
|
4296
|
+
doc = document_from_string input
|
4297
|
+
list = doc.blocks.first
|
4298
|
+
assert list.outline?
|
4299
|
+
end
|
4300
|
+
|
4301
|
+
test 'outline? should return false for description list' do
|
4302
|
+
input = <<-EOS
|
4303
|
+
label:: desc
|
4304
|
+
EOS
|
4305
|
+
|
4306
|
+
doc = document_from_string input
|
4307
|
+
list = doc.blocks.first
|
4308
|
+
assert !list.outline?
|
4309
|
+
end
|
4310
|
+
|
4311
|
+
test 'simple? should return true for list item with no nested blocks' do
|
4312
|
+
input = <<-EOS
|
4313
|
+
* one
|
4314
|
+
* two
|
4315
|
+
* three
|
4316
|
+
EOS
|
4317
|
+
|
4318
|
+
doc = document_from_string input
|
4319
|
+
list = doc.blocks.first
|
4320
|
+
assert list.items.first.simple?
|
4321
|
+
assert !list.items.first.compound?
|
4322
|
+
end
|
4323
|
+
|
4324
|
+
test 'simple? should return true for list item with nested outline list' do
|
4325
|
+
input = <<-EOS
|
4326
|
+
* one
|
4327
|
+
** more about one
|
4328
|
+
** and more
|
4329
|
+
* two
|
4330
|
+
* three
|
4331
|
+
EOS
|
4332
|
+
|
4333
|
+
doc = document_from_string input
|
4334
|
+
list = doc.blocks.first
|
4335
|
+
assert list.items.first.simple?
|
4336
|
+
assert !list.items.first.compound?
|
4337
|
+
end
|
4338
|
+
|
4339
|
+
test 'simple? should return false for list item with block content' do
|
4340
|
+
input = <<-EOS
|
4341
|
+
* one
|
4342
|
+
+
|
4343
|
+
----
|
4344
|
+
listing block in list item 1
|
4345
|
+
----
|
4346
|
+
* two
|
4347
|
+
* three
|
4348
|
+
EOS
|
4349
|
+
|
4350
|
+
doc = document_from_string input
|
4351
|
+
list = doc.blocks.first
|
4352
|
+
assert !list.items.first.simple?
|
4353
|
+
assert list.items.first.compound?
|
4354
|
+
end
|
4182
4355
|
end
|
data/test/options_test.rb
CHANGED
@@ -57,9 +57,9 @@ context 'Options' do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
test 'standard attribute assignment' do
|
60
|
-
options = Asciidoctor::Cli::Options.parse!(%w(-a
|
60
|
+
options = Asciidoctor::Cli::Options.parse!(%w(-a docinfosubs=attributes,replacements -a icons test/fixtures/sample.asciidoc))
|
61
61
|
|
62
|
-
assert_equal '
|
62
|
+
assert_equal 'attributes,replacements', options[:attributes]['docinfosubs']
|
63
63
|
assert_equal '', options[:attributes]['icons']
|
64
64
|
end
|
65
65
|
|
data/test/paragraphs_test.rb
CHANGED
@@ -514,10 +514,10 @@ Wise words from a wise person.
|
|
514
514
|
assert_equal '<a href="http://asciidoc.org">AsciiDoc</a> is a <em>lightweight</em> markup language…​', output
|
515
515
|
end
|
516
516
|
|
517
|
-
test 'should output
|
517
|
+
test 'should output nil if first block is not a paragraph' do
|
518
518
|
input = '* bullet'
|
519
519
|
output = render_string input, :doctype => 'inline'
|
520
|
-
assert output.
|
520
|
+
assert output.nil?
|
521
521
|
end
|
522
522
|
end
|
523
523
|
end
|
data/test/parser_test.rb
CHANGED
@@ -477,6 +477,29 @@ Ryan Waldron
|
|
477
477
|
assert_equal '2013-12-18', metadata['revdate']
|
478
478
|
end
|
479
479
|
|
480
|
+
test 'parse rev number with trailing comma' do
|
481
|
+
input = <<-EOS
|
482
|
+
Stuart Rackham
|
483
|
+
v8.6.8,
|
484
|
+
EOS
|
485
|
+
metadata, _ = parse_header_metadata input
|
486
|
+
assert_equal 7, metadata.size
|
487
|
+
assert_equal '8.6.8', metadata['revnumber']
|
488
|
+
assert !metadata.has_key?('revdate')
|
489
|
+
end
|
490
|
+
|
491
|
+
# Asciidoctor recognizes a standalone revision without a trailing comma
|
492
|
+
test 'parse rev number' do
|
493
|
+
input = <<-EOS
|
494
|
+
Stuart Rackham
|
495
|
+
v8.6.8
|
496
|
+
EOS
|
497
|
+
metadata, _ = parse_header_metadata input
|
498
|
+
assert_equal 7, metadata.size
|
499
|
+
assert_equal '8.6.8', metadata['revnumber']
|
500
|
+
assert !metadata.has_key?('revdate')
|
501
|
+
end
|
502
|
+
|
480
503
|
# while compliant w/ AsciiDoc, this is just sloppy parsing
|
481
504
|
test "treats arbitrary text on rev line as revdate" do
|
482
505
|
input = <<-EOS
|
@@ -516,7 +539,7 @@ Joe Cool
|
|
516
539
|
EOS
|
517
540
|
metadata, _ = parse_header_metadata input
|
518
541
|
assert_equal 'Must start revremark-only line with space', metadata['revremark']
|
519
|
-
|
542
|
+
assert !metadata.has_key?('revdate')
|
520
543
|
end
|
521
544
|
|
522
545
|
test "skip line comments before author" do
|
@@ -576,7 +599,7 @@ v0.0.7, 2013-12-18
|
|
576
599
|
assert_equal 'SJR', blankdoc.attributes['authorinitials']
|
577
600
|
end
|
578
601
|
|
579
|
-
test '
|
602
|
+
test 'adjust indentation to 0' do
|
580
603
|
input = <<-EOS.chomp
|
581
604
|
def names
|
582
605
|
|
@@ -594,11 +617,11 @@ end
|
|
594
617
|
EOS
|
595
618
|
|
596
619
|
lines = input.split("\n")
|
597
|
-
Asciidoctor::Parser.
|
620
|
+
Asciidoctor::Parser.adjust_indentation! lines
|
598
621
|
assert_equal expected, (lines * "\n")
|
599
622
|
end
|
600
623
|
|
601
|
-
test '
|
624
|
+
test 'adjust indentation mixed with tabs and spaces to 0' do
|
602
625
|
input = <<-EOS.chomp
|
603
626
|
def names
|
604
627
|
|
@@ -616,11 +639,31 @@ end
|
|
616
639
|
EOS
|
617
640
|
|
618
641
|
lines = input.split("\n")
|
619
|
-
Asciidoctor::Parser.
|
642
|
+
Asciidoctor::Parser.adjust_indentation! lines, 0, 4
|
620
643
|
assert_equal expected, (lines * "\n")
|
621
644
|
end
|
622
645
|
|
623
|
-
test '
|
646
|
+
test 'expands tabs to spaces' do
|
647
|
+
input = <<-EOS.chomp
|
648
|
+
Filesystem Size Used Avail Use% Mounted on
|
649
|
+
Filesystem Size Used Avail Use% Mounted on
|
650
|
+
devtmpfs 3.9G 0 3.9G 0% /dev
|
651
|
+
/dev/mapper/fedora-root 48G 18G 29G 39% /
|
652
|
+
EOS
|
653
|
+
|
654
|
+
expected = <<-EOS.chomp
|
655
|
+
Filesystem Size Used Avail Use% Mounted on
|
656
|
+
Filesystem Size Used Avail Use% Mounted on
|
657
|
+
devtmpfs 3.9G 0 3.9G 0% /dev
|
658
|
+
/dev/mapper/fedora-root 48G 18G 29G 39% /
|
659
|
+
EOS
|
660
|
+
|
661
|
+
lines = input.split("\n")
|
662
|
+
Asciidoctor::Parser.adjust_indentation! lines, 0, 4
|
663
|
+
assert_equal expected, (lines * "\n")
|
664
|
+
end
|
665
|
+
|
666
|
+
test 'adjust indentation to non-zero' do
|
624
667
|
input = <<-EOS.chomp
|
625
668
|
def names
|
626
669
|
|
@@ -631,18 +674,18 @@ end
|
|
631
674
|
|
632
675
|
expected = <<-EOS.chomp
|
633
676
|
def names
|
634
|
-
|
677
|
+
|
635
678
|
@name.split ' '
|
636
|
-
|
679
|
+
|
637
680
|
end
|
638
681
|
EOS
|
639
682
|
|
640
683
|
lines = input.split("\n")
|
641
|
-
Asciidoctor::Parser.
|
684
|
+
Asciidoctor::Parser.adjust_indentation! lines, 2
|
642
685
|
assert_equal expected, (lines * "\n")
|
643
686
|
end
|
644
687
|
|
645
|
-
test 'preserve block indent' do
|
688
|
+
test 'preserve block indent if indent is -1' do
|
646
689
|
input = <<-EOS
|
647
690
|
def names
|
648
691
|
|
@@ -654,16 +697,16 @@ end
|
|
654
697
|
expected = input
|
655
698
|
|
656
699
|
lines = input.lines.entries
|
657
|
-
Asciidoctor::Parser.
|
700
|
+
Asciidoctor::Parser.adjust_indentation! lines, -1
|
658
701
|
assert_equal expected, lines.join
|
659
702
|
end
|
660
703
|
|
661
|
-
test '
|
704
|
+
test 'adjust indentation handles empty lines gracefully' do
|
662
705
|
input = []
|
663
706
|
expected = input
|
664
707
|
|
665
708
|
lines = input.dup
|
666
|
-
Asciidoctor::Parser.
|
709
|
+
Asciidoctor::Parser.adjust_indentation! lines
|
667
710
|
assert_equal expected, lines
|
668
711
|
end
|
669
712
|
|