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.

Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +330 -143
  3. data/README-fr.adoc +441 -0
  4. data/README-jp.adoc +418 -0
  5. data/README-zh_CN.adoc +430 -0
  6. data/README.adoc +454 -0
  7. data/Rakefile +57 -0
  8. data/asciidoctor.gemspec +7 -1
  9. data/data/locale/attributes-ar.adoc +22 -0
  10. data/data/locale/attributes-bg.adoc +22 -0
  11. data/data/locale/attributes-ca.adoc +22 -0
  12. data/data/locale/attributes-cs.adoc +22 -0
  13. data/data/locale/attributes-da.adoc +22 -0
  14. data/data/locale/attributes-de.adoc +22 -0
  15. data/data/locale/attributes-en.adoc +23 -0
  16. data/data/locale/attributes-es.adoc +22 -0
  17. data/data/locale/attributes-fa.adoc +22 -0
  18. data/data/locale/attributes-fi.adoc +22 -0
  19. data/data/locale/attributes-fr.adoc +22 -0
  20. data/data/locale/attributes-hu.adoc +22 -0
  21. data/data/locale/attributes-id.adoc +22 -0
  22. data/data/locale/attributes-it.adoc +22 -0
  23. data/data/locale/attributes-ja.adoc +22 -0
  24. data/data/locale/attributes-kr.adoc +22 -0
  25. data/data/locale/attributes-nb.adoc +22 -0
  26. data/data/locale/attributes-nl.adoc +22 -0
  27. data/data/locale/attributes-nn.adoc +22 -0
  28. data/data/locale/attributes-pl.adoc +22 -0
  29. data/data/locale/attributes-pt.adoc +22 -0
  30. data/data/locale/attributes-pt_BR.adoc +22 -0
  31. data/data/locale/attributes-ro.adoc +22 -0
  32. data/data/locale/attributes-ru.adoc +22 -0
  33. data/data/locale/attributes-sr.adoc +22 -0
  34. data/data/locale/attributes-sr_Latn.adoc +22 -0
  35. data/data/locale/attributes-tr.adoc +22 -0
  36. data/data/locale/attributes-uk.adoc +22 -0
  37. data/data/locale/attributes-zh_CN.adoc +22 -0
  38. data/data/locale/attributes-zh_TW.adoc +22 -0
  39. data/data/locale/attributes.adoc +8 -649
  40. data/data/stylesheets/asciidoctor-default.css +77 -72
  41. data/features/xref.feature +366 -7
  42. data/lib/asciidoctor.rb +107 -93
  43. data/lib/asciidoctor/abstract_block.rb +247 -239
  44. data/lib/asciidoctor/abstract_node.rb +56 -58
  45. data/lib/asciidoctor/block.rb +3 -3
  46. data/lib/asciidoctor/callouts.rb +1 -1
  47. data/lib/asciidoctor/cli/invoker.rb +36 -9
  48. data/lib/asciidoctor/cli/options.rb +63 -25
  49. data/lib/asciidoctor/converter.rb +23 -13
  50. data/lib/asciidoctor/converter/base.rb +4 -0
  51. data/lib/asciidoctor/converter/docbook45.rb +16 -9
  52. data/lib/asciidoctor/converter/docbook5.rb +115 -97
  53. data/lib/asciidoctor/converter/factory.rb +29 -31
  54. data/lib/asciidoctor/converter/html5.rb +229 -192
  55. data/lib/asciidoctor/converter/manpage.rb +72 -50
  56. data/lib/asciidoctor/converter/template.rb +12 -12
  57. data/lib/asciidoctor/core_ext.rb +5 -1
  58. data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +6 -0
  59. data/lib/asciidoctor/document.rb +168 -77
  60. data/lib/asciidoctor/extensions.rb +79 -47
  61. data/lib/asciidoctor/helpers.rb +33 -11
  62. data/lib/asciidoctor/inline.rb +3 -2
  63. data/lib/asciidoctor/list.rb +2 -1
  64. data/lib/asciidoctor/logging.rb +122 -0
  65. data/lib/asciidoctor/parser.rb +406 -382
  66. data/lib/asciidoctor/path_resolver.rb +169 -162
  67. data/lib/asciidoctor/reader.rb +166 -121
  68. data/lib/asciidoctor/section.rb +45 -28
  69. data/lib/asciidoctor/stylesheets.rb +13 -5
  70. data/lib/asciidoctor/substitutors.rb +328 -254
  71. data/lib/asciidoctor/table.rb +105 -48
  72. data/lib/asciidoctor/timings.rb +34 -6
  73. data/lib/asciidoctor/version.rb +1 -1
  74. data/man/asciidoctor.1 +41 -23
  75. data/man/asciidoctor.adoc +14 -8
  76. data/test/api_test.rb +1004 -0
  77. data/test/attributes_test.rb +241 -50
  78. data/test/blocks_test.rb +549 -124
  79. data/test/converter_test.rb +170 -78
  80. data/test/document_test.rb +208 -767
  81. data/test/extensions_test.rb +188 -53
  82. data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +1 -1
  83. data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +1 -1
  84. data/test/fixtures/file-with-missing-include.adoc +1 -0
  85. data/test/fixtures/include-file.jsx +8 -0
  86. data/test/fixtures/lists.adoc +96 -0
  87. data/test/fixtures/other-chapters.adoc +11 -0
  88. data/test/fixtures/outer-include.adoc +5 -0
  89. data/test/fixtures/sample.asciidoc +5 -1
  90. data/test/fixtures/subdir/index.adoc +3 -0
  91. data/test/fixtures/subdir/inner-include.adoc +3 -0
  92. data/test/fixtures/subdir/middle-include.adoc +5 -0
  93. data/test/fixtures/tagged-class-enclosed.rb +0 -1
  94. data/test/fixtures/unclosed-tag.adoc +3 -0
  95. data/test/fixtures/unexpected-end-tag.adoc +4 -0
  96. data/test/invoker_test.rb +101 -40
  97. data/test/links_test.rb +266 -72
  98. data/test/lists_test.rb +243 -45
  99. data/test/logger_test.rb +211 -0
  100. data/test/manpage_test.rb +124 -6
  101. data/test/options_test.rb +46 -1
  102. data/test/paragraphs_test.rb +23 -10
  103. data/test/parser_test.rb +30 -1
  104. data/test/paths_test.rb +115 -33
  105. data/test/preamble_test.rb +1 -1
  106. data/test/reader_test.rb +337 -81
  107. data/test/sections_test.rb +656 -72
  108. data/test/substitutions_test.rb +182 -57
  109. data/test/tables_test.rb +324 -57
  110. data/test/test_helper.rb +77 -32
  111. data/test/text_test.rb +7 -7
  112. metadata +67 -3
@@ -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.groups
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
- assert Asciidoctor::Extensions.groups[:sample].is_a? SampleExtensionGroup
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
- assert Asciidoctor::Extensions.groups[:sample].is_a? Proc
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
- assert doc.extensions.is_a? Asciidoctor::Extensions::Registry
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
- assert extensions.first.is_a? Asciidoctor::Extensions::ProcessorExtension
427
- assert extensions.first.instance.is_a? SamplePreprocessor
428
- assert extensions.first.process_method.is_a? ::Method
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
- assert extensions.first.is_a? Asciidoctor::Extensions::ProcessorExtension
439
- assert extensions.first.instance.is_a? SampleIncludeProcessor
440
- assert extensions.first.process_method.is_a? ::Method
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
- assert extensions.first.is_a? Asciidoctor::Extensions::ProcessorExtension
452
- assert extensions.first.instance.is_a? SampleDocinfoProcessor
453
- assert extensions.first.process_method.is_a? ::Method
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
- assert extensions.first.is_a? Asciidoctor::Extensions::ProcessorExtension
465
- assert extensions.first.instance.is_a? SampleTreeprocessor
466
- assert extensions.first.process_method.is_a? ::Method
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
- assert extensions.first.is_a? Asciidoctor::Extensions::ProcessorExtension
477
- assert extensions.first.instance.is_a? SamplePostprocessor
478
- assert extensions.first.process_method.is_a? ::Method
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
- assert extension.is_a? Asciidoctor::Extensions::ProcessorExtension
489
- assert extension.instance.is_a? SampleBlock
490
- assert extension.process_method.is_a? ::Method
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
- assert extension.is_a? Asciidoctor::Extensions::ProcessorExtension
508
- assert extension.instance.is_a? SampleBlockMacro
509
- assert extension.process_method.is_a? ::Method
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
- assert extension.is_a? Asciidoctor::Extensions::ProcessorExtension
520
- assert extension.instance.is_a? SampleInlineMacro
521
- assert extension.process_method.is_a? ::Method
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
- assert extensions.first.is_a? Asciidoctor::Extensions::ProcessorExtension
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
- assert result.include?('before')
601
- assert result.include?('Lorem ipsum')
602
- assert result.include?('after')
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
- # Safe Mode is not required here
618
- document = empty_document :base_dir => File.expand_path(File.dirname(__FILE__))
619
- document.extensions.include_processor do
620
- handles? do |target|
621
- target == 'include-file.asciidoc'
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
- process do |doc, reader, target, attributes|
625
- # demonstrate that push_include normalizes endlines
626
- content = ["include target:: #{target}\n", "\n", "middle line\n"]
627
- reader.push_include content, target, target, 1, attributes
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
- assert output.include?('<script src="http://example.com/12345.js?_mode=edit"></script>')
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
- assert output.include?('Room temperature is 25 &#176;C.')
960
+ assert_includes output, 'Room temperature is 25 &#176;C.'
832
961
 
833
962
  output = render_embedded_string 'Normal body temperature is deg:37[].', :attributes => { 'temperature-unit' => 'F' }
834
- assert output.include?('Normal body temperature is 98.6 &#176;F.')
963
+ assert_includes output, 'Normal body temperature is 98.6 &#176;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
- assert output.include?('<label>Checkbox</label>')
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
- assert output.include?('<a href="https://github.com/mojavelinux">Dan</a>')
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
- assert_equal expect_id, sect.id
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
@@ -1,3 +1,3 @@
1
1
  - if title?
2
2
  .title=title
3
- p id=@id class=(attr 'role') =content
3
+ p id=id class="#{role}" =content