asciidoctor 1.5.6.2 → 1.5.7
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 +330 -143
- data/README-fr.adoc +441 -0
- data/README-jp.adoc +418 -0
- data/README-zh_CN.adoc +430 -0
- data/README.adoc +454 -0
- data/Rakefile +57 -0
- data/asciidoctor.gemspec +7 -1
- data/data/locale/attributes-ar.adoc +22 -0
- data/data/locale/attributes-bg.adoc +22 -0
- data/data/locale/attributes-ca.adoc +22 -0
- data/data/locale/attributes-cs.adoc +22 -0
- data/data/locale/attributes-da.adoc +22 -0
- data/data/locale/attributes-de.adoc +22 -0
- data/data/locale/attributes-en.adoc +23 -0
- data/data/locale/attributes-es.adoc +22 -0
- data/data/locale/attributes-fa.adoc +22 -0
- data/data/locale/attributes-fi.adoc +22 -0
- data/data/locale/attributes-fr.adoc +22 -0
- data/data/locale/attributes-hu.adoc +22 -0
- data/data/locale/attributes-id.adoc +22 -0
- data/data/locale/attributes-it.adoc +22 -0
- data/data/locale/attributes-ja.adoc +22 -0
- data/data/locale/attributes-kr.adoc +22 -0
- data/data/locale/attributes-nb.adoc +22 -0
- data/data/locale/attributes-nl.adoc +22 -0
- data/data/locale/attributes-nn.adoc +22 -0
- data/data/locale/attributes-pl.adoc +22 -0
- data/data/locale/attributes-pt.adoc +22 -0
- data/data/locale/attributes-pt_BR.adoc +22 -0
- data/data/locale/attributes-ro.adoc +22 -0
- data/data/locale/attributes-ru.adoc +22 -0
- data/data/locale/attributes-sr.adoc +22 -0
- data/data/locale/attributes-sr_Latn.adoc +22 -0
- data/data/locale/attributes-tr.adoc +22 -0
- data/data/locale/attributes-uk.adoc +22 -0
- data/data/locale/attributes-zh_CN.adoc +22 -0
- data/data/locale/attributes-zh_TW.adoc +22 -0
- data/data/locale/attributes.adoc +8 -649
- data/data/stylesheets/asciidoctor-default.css +77 -72
- data/features/xref.feature +366 -7
- data/lib/asciidoctor.rb +107 -93
- data/lib/asciidoctor/abstract_block.rb +247 -239
- data/lib/asciidoctor/abstract_node.rb +56 -58
- data/lib/asciidoctor/block.rb +3 -3
- data/lib/asciidoctor/callouts.rb +1 -1
- data/lib/asciidoctor/cli/invoker.rb +36 -9
- data/lib/asciidoctor/cli/options.rb +63 -25
- data/lib/asciidoctor/converter.rb +23 -13
- data/lib/asciidoctor/converter/base.rb +4 -0
- data/lib/asciidoctor/converter/docbook45.rb +16 -9
- data/lib/asciidoctor/converter/docbook5.rb +115 -97
- data/lib/asciidoctor/converter/factory.rb +29 -31
- data/lib/asciidoctor/converter/html5.rb +229 -192
- data/lib/asciidoctor/converter/manpage.rb +72 -50
- data/lib/asciidoctor/converter/template.rb +12 -12
- data/lib/asciidoctor/core_ext.rb +5 -1
- data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +6 -0
- data/lib/asciidoctor/document.rb +168 -77
- data/lib/asciidoctor/extensions.rb +79 -47
- data/lib/asciidoctor/helpers.rb +33 -11
- data/lib/asciidoctor/inline.rb +3 -2
- data/lib/asciidoctor/list.rb +2 -1
- data/lib/asciidoctor/logging.rb +122 -0
- data/lib/asciidoctor/parser.rb +406 -382
- data/lib/asciidoctor/path_resolver.rb +169 -162
- data/lib/asciidoctor/reader.rb +166 -121
- data/lib/asciidoctor/section.rb +45 -28
- data/lib/asciidoctor/stylesheets.rb +13 -5
- data/lib/asciidoctor/substitutors.rb +328 -254
- data/lib/asciidoctor/table.rb +105 -48
- data/lib/asciidoctor/timings.rb +34 -6
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +41 -23
- data/man/asciidoctor.adoc +14 -8
- data/test/api_test.rb +1004 -0
- data/test/attributes_test.rb +241 -50
- data/test/blocks_test.rb +549 -124
- data/test/converter_test.rb +170 -78
- data/test/document_test.rb +208 -767
- data/test/extensions_test.rb +188 -53
- data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +1 -1
- data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +1 -1
- data/test/fixtures/file-with-missing-include.adoc +1 -0
- data/test/fixtures/include-file.jsx +8 -0
- data/test/fixtures/lists.adoc +96 -0
- data/test/fixtures/other-chapters.adoc +11 -0
- data/test/fixtures/outer-include.adoc +5 -0
- data/test/fixtures/sample.asciidoc +5 -1
- data/test/fixtures/subdir/index.adoc +3 -0
- data/test/fixtures/subdir/inner-include.adoc +3 -0
- data/test/fixtures/subdir/middle-include.adoc +5 -0
- data/test/fixtures/tagged-class-enclosed.rb +0 -1
- data/test/fixtures/unclosed-tag.adoc +3 -0
- data/test/fixtures/unexpected-end-tag.adoc +4 -0
- data/test/invoker_test.rb +101 -40
- data/test/links_test.rb +266 -72
- data/test/lists_test.rb +243 -45
- data/test/logger_test.rb +211 -0
- data/test/manpage_test.rb +124 -6
- data/test/options_test.rb +46 -1
- data/test/paragraphs_test.rb +23 -10
- data/test/parser_test.rb +30 -1
- data/test/paths_test.rb +115 -33
- data/test/preamble_test.rb +1 -1
- data/test/reader_test.rb +337 -81
- data/test/sections_test.rb +656 -72
- data/test/substitutions_test.rb +182 -57
- data/test/tables_test.rb +324 -57
- data/test/test_helper.rb +77 -32
- data/test/text_test.rb +7 -7
- metadata +67 -3
data/test/extensions_test.rb
CHANGED
@@ -10,14 +10,17 @@ class ExtensionsInitTest < Minitest::Test
|
|
10
10
|
refute doc.extensions?, 'Extensions should not be enabled by default'
|
11
11
|
|
12
12
|
begin
|
13
|
-
# NOTE trigger extensions to autoload
|
14
|
-
Asciidoctor::Extensions.
|
13
|
+
# NOTE trigger extensions to autoload by registering empty group
|
14
|
+
Asciidoctor::Extensions.register do
|
15
|
+
end
|
15
16
|
rescue; end
|
16
17
|
|
17
18
|
doc = empty_document
|
18
19
|
assert doc.extensions?, 'Extensions should be enabled after being autoloaded'
|
19
20
|
|
20
21
|
self.class.remove_tests self.class
|
22
|
+
ensure
|
23
|
+
Asciidoctor::Extensions.unregister_all
|
21
24
|
end
|
22
25
|
self
|
23
26
|
end.new(nil).test_autoload
|
@@ -200,6 +203,12 @@ end
|
|
200
203
|
|
201
204
|
context 'Extensions' do
|
202
205
|
context 'Register' do
|
206
|
+
test 'should not activate registry if no extension groups are registered' do
|
207
|
+
assert defined? Asciidoctor::Extensions
|
208
|
+
doc = empty_document
|
209
|
+
refute doc.extensions?, 'Extensions should not be enabled if not groups are registered'
|
210
|
+
end
|
211
|
+
|
203
212
|
test 'should register extension group class' do
|
204
213
|
begin
|
205
214
|
Asciidoctor::Extensions.register :sample, SampleExtensionGroup
|
@@ -238,7 +247,7 @@ context 'Extensions' do
|
|
238
247
|
Asciidoctor::Extensions.register :sample, SampleExtensionGroup.new
|
239
248
|
refute_nil Asciidoctor::Extensions.groups
|
240
249
|
assert_equal 1, Asciidoctor::Extensions.groups.size
|
241
|
-
|
250
|
+
assert_kind_of SampleExtensionGroup, Asciidoctor::Extensions.groups[:sample]
|
242
251
|
ensure
|
243
252
|
Asciidoctor::Extensions.unregister_all
|
244
253
|
end
|
@@ -250,7 +259,7 @@ context 'Extensions' do
|
|
250
259
|
end
|
251
260
|
refute_nil Asciidoctor::Extensions.groups
|
252
261
|
assert_equal 1, Asciidoctor::Extensions.groups.size
|
253
|
-
|
262
|
+
assert_kind_of Proc, Asciidoctor::Extensions.groups[:sample]
|
254
263
|
ensure
|
255
264
|
Asciidoctor::Extensions.unregister_all
|
256
265
|
end
|
@@ -331,6 +340,24 @@ context 'Extensions' do
|
|
331
340
|
end
|
332
341
|
end
|
333
342
|
|
343
|
+
test 'should raise exception if constant name is invalid' do
|
344
|
+
begin
|
345
|
+
Asciidoctor::Extensions.class_for_name 'foobar'
|
346
|
+
flunk 'Expecting RuntimeError to be raised'
|
347
|
+
rescue NameError => e
|
348
|
+
assert_equal 'Could not resolve class for name: foobar', e.message
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
test 'should raise exception if class not found in scope' do
|
353
|
+
begin
|
354
|
+
Asciidoctor::Extensions.class_for_name 'Asciidoctor::Extensions::String'
|
355
|
+
flunk 'Expecting RuntimeError to be raised'
|
356
|
+
rescue NameError => e
|
357
|
+
assert_equal 'Could not resolve class for name: Asciidoctor::Extensions::String', e.message
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
334
361
|
test 'should raise exception if name resolves to module' do
|
335
362
|
begin
|
336
363
|
Asciidoctor::Extensions.class_for_name 'Asciidoctor::Extensions'
|
@@ -352,6 +379,29 @@ context 'Extensions' do
|
|
352
379
|
assert_equal Asciidoctor::Document, clazz
|
353
380
|
end
|
354
381
|
|
382
|
+
test 'should not resolve class if not in scope' do
|
383
|
+
begin
|
384
|
+
Asciidoctor::Extensions.resolve_class 'Asciidoctor::Extensions::String'
|
385
|
+
flunk 'Expecting RuntimeError to be raised'
|
386
|
+
rescue NameError => e
|
387
|
+
assert_equal 'Could not resolve class for name: Asciidoctor::Extensions::String', e.message
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
test 'should raise NameError if extension class cannot be resolved from string' do
|
392
|
+
begin
|
393
|
+
Asciidoctor::Extensions.register do
|
394
|
+
block 'foobar'
|
395
|
+
end
|
396
|
+
empty_document
|
397
|
+
flunk 'Expecting RuntimeError to be raised'
|
398
|
+
rescue NameError => e
|
399
|
+
assert_equal 'Could not resolve class for name: foobar', e.message
|
400
|
+
ensure
|
401
|
+
Asciidoctor::Extensions.unregister_all
|
402
|
+
end
|
403
|
+
end
|
404
|
+
|
355
405
|
test 'should allow standalone registry to be created but not registered' do
|
356
406
|
registry = Asciidoctor::Extensions.create 'sample' do
|
357
407
|
block do
|
@@ -407,7 +457,7 @@ context 'Extensions' do
|
|
407
457
|
SampleExtensionGroup.register
|
408
458
|
doc = Asciidoctor::Document.new
|
409
459
|
assert doc.extensions?
|
410
|
-
|
460
|
+
assert_kind_of Asciidoctor::Extensions::Registry, doc.extensions
|
411
461
|
ensure
|
412
462
|
Asciidoctor::Extensions.unregister_all
|
413
463
|
end
|
@@ -423,9 +473,9 @@ context 'Extensions' do
|
|
423
473
|
assert registry.preprocessors?
|
424
474
|
extensions = registry.preprocessors
|
425
475
|
assert_equal 1, extensions.size
|
426
|
-
|
427
|
-
|
428
|
-
|
476
|
+
assert_kind_of Asciidoctor::Extensions::ProcessorExtension, extensions.first
|
477
|
+
assert_kind_of SamplePreprocessor, extensions.first.instance
|
478
|
+
assert_kind_of Method, extensions.first.process_method
|
429
479
|
end
|
430
480
|
|
431
481
|
test 'should instantiate include processors' do
|
@@ -435,9 +485,9 @@ context 'Extensions' do
|
|
435
485
|
assert registry.include_processors?
|
436
486
|
extensions = registry.include_processors
|
437
487
|
assert_equal 1, extensions.size
|
438
|
-
|
439
|
-
|
440
|
-
|
488
|
+
assert_kind_of Asciidoctor::Extensions::ProcessorExtension, extensions.first
|
489
|
+
assert_kind_of SampleIncludeProcessor, extensions.first.instance
|
490
|
+
assert_kind_of Method, extensions.first.process_method
|
441
491
|
end
|
442
492
|
|
443
493
|
test 'should instantiate docinfo processors' do
|
@@ -448,9 +498,9 @@ context 'Extensions' do
|
|
448
498
|
assert registry.docinfo_processors?(:head)
|
449
499
|
extensions = registry.docinfo_processors
|
450
500
|
assert_equal 1, extensions.size
|
451
|
-
|
452
|
-
|
453
|
-
|
501
|
+
assert_kind_of Asciidoctor::Extensions::ProcessorExtension, extensions.first
|
502
|
+
assert_kind_of SampleDocinfoProcessor, extensions.first.instance
|
503
|
+
assert_kind_of Method, extensions.first.process_method
|
454
504
|
end
|
455
505
|
|
456
506
|
# NOTE intentionally using the legacy names
|
@@ -461,9 +511,9 @@ context 'Extensions' do
|
|
461
511
|
assert registry.treeprocessors?
|
462
512
|
extensions = registry.treeprocessors
|
463
513
|
assert_equal 1, extensions.size
|
464
|
-
|
465
|
-
|
466
|
-
|
514
|
+
assert_kind_of Asciidoctor::Extensions::ProcessorExtension, extensions.first
|
515
|
+
assert_kind_of SampleTreeprocessor, extensions.first.instance
|
516
|
+
assert_kind_of Method, extensions.first.process_method
|
467
517
|
end
|
468
518
|
|
469
519
|
test 'should instantiate postprocessors' do
|
@@ -473,9 +523,9 @@ context 'Extensions' do
|
|
473
523
|
assert registry.postprocessors?
|
474
524
|
extensions = registry.postprocessors
|
475
525
|
assert_equal 1, extensions.size
|
476
|
-
|
477
|
-
|
478
|
-
|
526
|
+
assert_kind_of Asciidoctor::Extensions::ProcessorExtension, extensions.first
|
527
|
+
assert_kind_of SamplePostprocessor, extensions.first.instance
|
528
|
+
assert_kind_of Method, extensions.first.process_method
|
479
529
|
end
|
480
530
|
|
481
531
|
test 'should instantiate block processor' do
|
@@ -485,9 +535,9 @@ context 'Extensions' do
|
|
485
535
|
assert registry.blocks?
|
486
536
|
assert registry.registered_for_block? :sample, :paragraph
|
487
537
|
extension = registry.find_block_extension :sample
|
488
|
-
|
489
|
-
|
490
|
-
|
538
|
+
assert_kind_of Asciidoctor::Extensions::ProcessorExtension, extension
|
539
|
+
assert_kind_of SampleBlock, extension.instance
|
540
|
+
assert_kind_of Method, extension.process_method
|
491
541
|
end
|
492
542
|
|
493
543
|
test 'should not match block processor for unsupported context' do
|
@@ -504,9 +554,9 @@ context 'Extensions' do
|
|
504
554
|
assert registry.block_macros?
|
505
555
|
assert registry.registered_for_block_macro? 'sample'
|
506
556
|
extension = registry.find_block_macro_extension 'sample'
|
507
|
-
|
508
|
-
|
509
|
-
|
557
|
+
assert_kind_of Asciidoctor::Extensions::ProcessorExtension, extension
|
558
|
+
assert_kind_of SampleBlockMacro, extension.instance
|
559
|
+
assert_kind_of Method, extension.process_method
|
510
560
|
end
|
511
561
|
|
512
562
|
test 'should instantiate inline macro processor' do
|
@@ -516,9 +566,9 @@ context 'Extensions' do
|
|
516
566
|
assert registry.inline_macros?
|
517
567
|
assert registry.registered_for_inline_macro? 'sample'
|
518
568
|
extension = registry.find_inline_macro_extension 'sample'
|
519
|
-
|
520
|
-
|
521
|
-
|
569
|
+
assert_kind_of Asciidoctor::Extensions::ProcessorExtension, extension
|
570
|
+
assert_kind_of SampleInlineMacro, extension.instance
|
571
|
+
assert_kind_of Method, extension.process_method
|
522
572
|
end
|
523
573
|
|
524
574
|
test 'should allow processors to be registered by a string name' do
|
@@ -528,12 +578,12 @@ context 'Extensions' do
|
|
528
578
|
assert registry.preprocessors?
|
529
579
|
extensions = registry.preprocessors
|
530
580
|
assert_equal 1, extensions.size
|
531
|
-
|
581
|
+
assert_kind_of Asciidoctor::Extensions::ProcessorExtension, extensions.first
|
532
582
|
end
|
533
583
|
end
|
534
584
|
|
535
585
|
context 'Integration' do
|
536
|
-
test 'can provide extension registry as option' do
|
586
|
+
test 'can provide extension registry as an option' do
|
537
587
|
registry = Asciidoctor::Extensions.create do
|
538
588
|
tree_processor SampleTreeProcessor
|
539
589
|
end
|
@@ -546,6 +596,19 @@ context 'Extensions' do
|
|
546
596
|
assert_equal 0, Asciidoctor::Extensions.groups.size
|
547
597
|
end
|
548
598
|
|
599
|
+
# NOTE I'm not convinced we want to continue to support this use case
|
600
|
+
test 'can provide extension registry created without any groups as option' do
|
601
|
+
registry = Asciidoctor::Extensions.create
|
602
|
+
registry.tree_processor SampleTreeProcessor
|
603
|
+
|
604
|
+
doc = document_from_string %(= Document Title\n\ncontent), :extension_registry => registry
|
605
|
+
refute_nil doc.extensions
|
606
|
+
assert_equal 0, doc.extensions.groups.size
|
607
|
+
assert doc.extensions.tree_processors?
|
608
|
+
assert_equal 1, doc.extensions.tree_processors.size
|
609
|
+
assert_equal 0, Asciidoctor::Extensions.groups.size
|
610
|
+
end
|
611
|
+
|
549
612
|
test 'can provide extensions proc as option' do
|
550
613
|
doc = document_from_string %(= Document Title\n\ncontent), :extensions => proc {
|
551
614
|
tree_processor SampleTreeProcessor
|
@@ -597,9 +660,9 @@ after
|
|
597
660
|
|
598
661
|
result = render_string input, :safe => :server
|
599
662
|
assert_css '.paragraph > p', result, 3
|
600
|
-
|
601
|
-
|
602
|
-
|
663
|
+
assert_includes result, 'before'
|
664
|
+
assert_includes result, 'Lorem ipsum'
|
665
|
+
assert_includes result, 'after'
|
603
666
|
ensure
|
604
667
|
Asciidoctor::Extensions.unregister_all
|
605
668
|
end
|
@@ -614,19 +677,21 @@ include::include-file.asciidoc[]
|
|
614
677
|
last line
|
615
678
|
EOS
|
616
679
|
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
end
|
680
|
+
registry = Asciidoctor::Extensions.create do
|
681
|
+
include_processor do
|
682
|
+
handles? do |target|
|
683
|
+
target == 'include-file.asciidoc'
|
684
|
+
end
|
623
685
|
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
686
|
+
process do |doc, reader, target, attributes|
|
687
|
+
# demonstrate that push_include normalizes endlines
|
688
|
+
content = ["include target:: #{target}\n", "\n", "middle line\n"]
|
689
|
+
reader.push_include content, target, target, 1, attributes
|
690
|
+
end
|
628
691
|
end
|
629
692
|
end
|
693
|
+
# Safe Mode is not required here
|
694
|
+
document = empty_document :base_dir => testdir, :extension_registry => registry
|
630
695
|
reader = Asciidoctor::PreprocessorReader.new document, input, nil, :normalize => true
|
631
696
|
lines = []
|
632
697
|
lines << reader.read_line
|
@@ -662,6 +727,25 @@ content
|
|
662
727
|
end
|
663
728
|
end
|
664
729
|
|
730
|
+
test 'should set source_location on document before invoking tree processors' do
|
731
|
+
begin
|
732
|
+
Asciidoctor::Extensions.register do
|
733
|
+
tree_processor do
|
734
|
+
process do |doc|
|
735
|
+
para = create_paragraph doc.blocks.last.parent, %(file: #{doc.file}, lineno: #{doc.lineno}), {}
|
736
|
+
doc << para
|
737
|
+
end
|
738
|
+
end
|
739
|
+
end
|
740
|
+
|
741
|
+
sample_doc = fixture_path 'sample.asciidoc'
|
742
|
+
doc = Asciidoctor.load_file sample_doc, :sourcemap => true
|
743
|
+
assert_includes doc.convert, 'file: sample.asciidoc, lineno: 1'
|
744
|
+
ensure
|
745
|
+
Asciidoctor::Extensions.unregister_all
|
746
|
+
end
|
747
|
+
end
|
748
|
+
|
665
749
|
test 'should allow tree processor to replace tree' do
|
666
750
|
input = <<-EOS
|
667
751
|
= Original Document
|
@@ -751,6 +835,28 @@ Hi there!
|
|
751
835
|
end
|
752
836
|
end
|
753
837
|
|
838
|
+
test 'should invoke processor for custom block in an AsciiDoc table cell' do
|
839
|
+
input = <<-EOS
|
840
|
+
|===
|
841
|
+
a|
|
842
|
+
[yell]
|
843
|
+
Hi there!
|
844
|
+
|===
|
845
|
+
EOS
|
846
|
+
|
847
|
+
begin
|
848
|
+
Asciidoctor::Extensions.register do
|
849
|
+
block UppercaseBlock
|
850
|
+
end
|
851
|
+
|
852
|
+
output = render_embedded_string input
|
853
|
+
assert_xpath '/table//p', output, 1
|
854
|
+
assert_xpath '/table//p[text()="HI THERE!"]', output, 1
|
855
|
+
ensure
|
856
|
+
Asciidoctor::Extensions.unregister_all
|
857
|
+
end
|
858
|
+
end
|
859
|
+
|
754
860
|
test 'should pass cloaked context in attributes passed to process method of custom block' do
|
755
861
|
input = <<-EOS
|
756
862
|
[custom]
|
@@ -789,7 +895,30 @@ snippet::12345[mode=edit]
|
|
789
895
|
end
|
790
896
|
|
791
897
|
output = render_embedded_string input
|
792
|
-
|
898
|
+
assert_includes output, '<script src="http://example.com/12345.js?_mode=edit"></script>'
|
899
|
+
ensure
|
900
|
+
Asciidoctor::Extensions.unregister_all
|
901
|
+
end
|
902
|
+
end
|
903
|
+
|
904
|
+
test 'should invoke processor for custom block macro in an AsciiDoc table cell' do
|
905
|
+
input = <<-EOS
|
906
|
+
|===
|
907
|
+
a|message::hi[]
|
908
|
+
|===
|
909
|
+
EOS
|
910
|
+
|
911
|
+
begin
|
912
|
+
Asciidoctor::Extensions.register do
|
913
|
+
block_macro :message do
|
914
|
+
process do |parent, target, attrs|
|
915
|
+
create_paragraph parent, target.upcase, {}
|
916
|
+
end
|
917
|
+
end
|
918
|
+
end
|
919
|
+
|
920
|
+
output = render_embedded_string input
|
921
|
+
assert_xpath '/table//p[text()="HI"]', output, 1
|
793
922
|
ensure
|
794
923
|
Asciidoctor::Extensions.unregister_all
|
795
924
|
end
|
@@ -828,10 +957,10 @@ custom_toc::[]
|
|
828
957
|
end
|
829
958
|
|
830
959
|
output = render_embedded_string 'Room temperature is deg:25[C,precision=0].', :attributes => { 'temperature-unit' => 'F' }
|
831
|
-
|
960
|
+
assert_includes output, 'Room temperature is 25 °C.'
|
832
961
|
|
833
962
|
output = render_embedded_string 'Normal body temperature is deg:37[].', :attributes => { 'temperature-unit' => 'F' }
|
834
|
-
|
963
|
+
assert_includes output, 'Normal body temperature is 98.6 °F.'
|
835
964
|
ensure
|
836
965
|
Asciidoctor::Extensions.unregister_all
|
837
966
|
end
|
@@ -851,7 +980,7 @@ custom_toc::[]
|
|
851
980
|
end
|
852
981
|
|
853
982
|
output = render_embedded_string 'label:[Checkbox]'
|
854
|
-
|
983
|
+
assert_includes output, '<label>Checkbox</label>'
|
855
984
|
ensure
|
856
985
|
Asciidoctor::Extensions.unregister_all
|
857
986
|
end
|
@@ -952,7 +1081,7 @@ target="target", attributes=[]
|
|
952
1081
|
end
|
953
1082
|
|
954
1083
|
output = render_embedded_string 'mention:mojavelinux[Dan]'
|
955
|
-
|
1084
|
+
assert_includes output, '<a href="https://github.com/mojavelinux">Dan</a>'
|
956
1085
|
ensure
|
957
1086
|
Asciidoctor::Extensions.unregister_all
|
958
1087
|
end
|
@@ -1094,6 +1223,7 @@ content
|
|
1094
1223
|
process do |parent, target, attrs|
|
1095
1224
|
opts = (level = attrs.delete 'level') ? { :level => level.to_i } : {}
|
1096
1225
|
attrs['id'] = false if attrs['id'] == 'false'
|
1226
|
+
parent = parent.parent if parent.context == :preamble
|
1097
1227
|
sect = create_section parent, 'Section Title', attrs, opts
|
1098
1228
|
nil
|
1099
1229
|
end
|
@@ -1111,20 +1241,26 @@ sect::[%s]
|
|
1111
1241
|
{
|
1112
1242
|
'' => ['chapter', 1, false, true, '_section_title'],
|
1113
1243
|
'level=0' => ['part', 0, false, false, '_section_title'],
|
1244
|
+
'level=0,alt' => ['part', 0, false, true, '_section_title', { 'partnums' => '' }],
|
1114
1245
|
'level=0,style=appendix' => ['appendix', 1, true, true, '_section_title'],
|
1115
1246
|
'style=appendix' => ['appendix', 1, true, true, '_section_title'],
|
1116
1247
|
'style=glossary' => ['glossary', 1, true, false, '_section_title'],
|
1248
|
+
'style=glossary,alt' => ['glossary', 1, true, :chapter, '_section_title', { 'sectnums' => 'all' }],
|
1117
1249
|
'style=abstract' => ['chapter', 1, false, true, '_section_title'],
|
1118
1250
|
'id=section-title' => ['chapter', 1, false, true, 'section-title'],
|
1119
1251
|
'id=false' => ['chapter', 1, false, true, nil]
|
1120
|
-
}.each do |attrlist, (expect_sectname, expect_level, expect_special, expect_numbered, expect_id)|
|
1252
|
+
}.each do |attrlist, (expect_sectname, expect_level, expect_special, expect_numbered, expect_id, extra_attrs)|
|
1121
1253
|
input = input_tpl % attrlist
|
1122
|
-
document_from_string input, :safe => :server
|
1254
|
+
document_from_string input, :safe => :server, :attributes => extra_attrs
|
1123
1255
|
assert_equal expect_sectname, sect.sectname
|
1124
1256
|
assert_equal expect_level, sect.level
|
1125
1257
|
assert_equal expect_special, sect.special
|
1126
1258
|
assert_equal expect_numbered, sect.numbered
|
1127
|
-
|
1259
|
+
if expect_id
|
1260
|
+
assert_equal expect_id, sect.id
|
1261
|
+
else
|
1262
|
+
assert_nil sect.id
|
1263
|
+
end
|
1128
1264
|
end
|
1129
1265
|
ensure
|
1130
1266
|
Asciidoctor::Extensions.unregister_all
|
@@ -1150,7 +1286,6 @@ sample content
|
|
1150
1286
|
end
|
1151
1287
|
end
|
1152
1288
|
|
1153
|
-
|
1154
1289
|
test 'should add multiple docinfo to document' do
|
1155
1290
|
input = <<-EOS
|
1156
1291
|
= Document Title
|