asciidoctor 1.5.7.1 → 1.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +95 -5
  3. data/Gemfile +23 -13
  4. data/README-de.adoc +482 -0
  5. data/README-fr.adoc +128 -119
  6. data/README-jp.adoc +2 -3
  7. data/README-zh_CN.adoc +2 -3
  8. data/README.adoc +131 -106
  9. data/asciidoctor.gemspec +9 -7
  10. data/data/locale/attributes-ar.adoc +1 -1
  11. data/data/locale/attributes-bg.adoc +1 -1
  12. data/data/locale/attributes-ca.adoc +1 -1
  13. data/data/locale/attributes-cs.adoc +1 -1
  14. data/data/locale/attributes-da.adoc +1 -1
  15. data/data/locale/attributes-de.adoc +1 -1
  16. data/data/locale/attributes-en.adoc +1 -1
  17. data/data/locale/attributes-es.adoc +1 -1
  18. data/data/locale/attributes-fa.adoc +1 -1
  19. data/data/locale/attributes-fi.adoc +1 -1
  20. data/data/locale/attributes-fr.adoc +1 -1
  21. data/data/locale/attributes-hu.adoc +1 -1
  22. data/data/locale/attributes-id.adoc +1 -1
  23. data/data/locale/attributes-it.adoc +1 -1
  24. data/data/locale/attributes-ja.adoc +1 -1
  25. data/data/locale/attributes-kr.adoc +1 -1
  26. data/data/locale/attributes-nb.adoc +1 -1
  27. data/data/locale/attributes-nl.adoc +1 -1
  28. data/data/locale/attributes-nn.adoc +1 -1
  29. data/data/locale/attributes-pl.adoc +1 -1
  30. data/data/locale/attributes-pt.adoc +1 -1
  31. data/data/locale/attributes-pt_BR.adoc +1 -1
  32. data/data/locale/attributes-ro.adoc +1 -1
  33. data/data/locale/attributes-ru.adoc +1 -1
  34. data/data/locale/attributes-sr.adoc +5 -4
  35. data/data/locale/attributes-sr_Latn.adoc +5 -4
  36. data/data/locale/attributes-sv.adoc +23 -0
  37. data/data/locale/attributes-tr.adoc +1 -1
  38. data/data/locale/attributes-uk.adoc +1 -1
  39. data/data/locale/attributes-zh_CN.adoc +1 -1
  40. data/data/locale/attributes-zh_TW.adoc +1 -1
  41. data/data/stylesheets/asciidoctor-default.css +23 -23
  42. data/lib/asciidoctor.rb +110 -104
  43. data/lib/asciidoctor/abstract_block.rb +55 -32
  44. data/lib/asciidoctor/abstract_node.rb +32 -17
  45. data/lib/asciidoctor/attribute_list.rb +8 -7
  46. data/lib/asciidoctor/block.rb +5 -7
  47. data/lib/asciidoctor/cli/options.rb +5 -9
  48. data/lib/asciidoctor/converter.rb +2 -2
  49. data/lib/asciidoctor/converter/docbook45.rb +7 -20
  50. data/lib/asciidoctor/converter/docbook5.rb +36 -37
  51. data/lib/asciidoctor/converter/factory.rb +10 -8
  52. data/lib/asciidoctor/converter/html5.rb +90 -65
  53. data/lib/asciidoctor/converter/manpage.rb +72 -62
  54. data/lib/asciidoctor/converter/template.rb +8 -6
  55. data/lib/asciidoctor/core_ext/1.8.7/concurrent/hash.rb +5 -0
  56. data/lib/asciidoctor/document.rb +62 -10
  57. data/lib/asciidoctor/extensions.rb +74 -16
  58. data/lib/asciidoctor/helpers.rb +11 -14
  59. data/lib/asciidoctor/list.rb +2 -2
  60. data/lib/asciidoctor/parser.rb +223 -195
  61. data/lib/asciidoctor/path_resolver.rb +15 -7
  62. data/lib/asciidoctor/reader.rb +65 -36
  63. data/lib/asciidoctor/section.rb +6 -4
  64. data/lib/asciidoctor/substitutors.rb +170 -149
  65. data/lib/asciidoctor/table.rb +16 -8
  66. data/lib/asciidoctor/version.rb +1 -1
  67. data/man/asciidoctor.1 +6 -5
  68. data/man/asciidoctor.adoc +3 -2
  69. data/test/api_test.rb +236 -0
  70. data/test/attribute_list_test.rb +242 -0
  71. data/test/attributes_test.rb +65 -52
  72. data/test/blocks_test.rb +408 -260
  73. data/test/converter_test.rb +7 -7
  74. data/test/document_test.rb +60 -54
  75. data/test/extensions_test.rb +218 -32
  76. data/test/fixtures/doctime-localtime.adoc +2 -0
  77. data/test/fixtures/section-a.adoc +4 -0
  78. data/test/fixtures/subs.adoc +0 -1
  79. data/test/invoker_test.rb +56 -18
  80. data/test/links_test.rb +105 -81
  81. data/test/lists_test.rb +636 -265
  82. data/test/logger_test.rb +1 -1
  83. data/test/manpage_test.rb +140 -3
  84. data/test/paragraphs_test.rb +42 -42
  85. data/test/parser_test.rb +63 -183
  86. data/test/paths_test.rb +21 -4
  87. data/test/preamble_test.rb +9 -9
  88. data/test/reader_test.rb +78 -28
  89. data/test/sections_test.rb +273 -151
  90. data/test/substitutions_test.rb +53 -19
  91. data/test/tables_test.rb +286 -163
  92. data/test/test_helper.rb +4 -3
  93. data/test/text_test.rb +65 -65
  94. metadata +16 -21
@@ -56,7 +56,7 @@ context 'Attributes' do
56
56
 
57
57
  {#{name}}
58
58
  EOS
59
- result = render_embedded_string str
59
+ result = convert_string_to_embedded str
60
60
  assert_includes result, %(<p>#{value}</p>)
61
61
  end
62
62
 
@@ -167,7 +167,7 @@ linus.torvalds@example.com
167
167
  {bigfoot}
168
168
  EOS
169
169
 
170
- result = render_embedded_string input
170
+ result = convert_string_to_embedded input
171
171
  assert_includes result, 'bigfoot'
172
172
  end
173
173
 
@@ -182,7 +182,7 @@ content
182
182
  {bigfoot}
183
183
  EOS
184
184
 
185
- result = render_embedded_string input
185
+ result = convert_string_to_embedded input
186
186
  assert_includes result, '<em>big</em>foot'
187
187
  end
188
188
 
@@ -194,7 +194,7 @@ content
194
194
  {name}
195
195
  EOS
196
196
 
197
- result = render_embedded_string input, :doctype => :inline
197
+ result = convert_inline_string input
198
198
  assert_equal expected, result
199
199
  assert_equal 4096, result.bytesize
200
200
  end
@@ -207,7 +207,7 @@ content
207
207
  {name}
208
208
  EOS
209
209
 
210
- result = render_embedded_string input, :doctype => :inline, :attributes => { 'max-attribute-value-size' => 6 }
210
+ result = convert_inline_string input, :attributes => { 'max-attribute-value-size' => 6 }
211
211
  assert_equal expected, result
212
212
  assert_equal 6, result.bytesize
213
213
  end
@@ -220,7 +220,7 @@ content
220
220
  {name}
221
221
  EOS
222
222
 
223
- result = render_embedded_string input, :doctype => :inline, :attributes => { 'max-attribute-value-size' => 8 }
223
+ result = convert_inline_string input, :attributes => { 'max-attribute-value-size' => 8 }
224
224
  assert_equal expected, result
225
225
  assert_equal 6, result.bytesize
226
226
  end
@@ -233,7 +233,7 @@ content
233
233
  {name}
234
234
  EOS
235
235
 
236
- result = render_embedded_string input, :doctype => :inline, :attributes => { 'max-attribute-value-size' => nil }
236
+ result = convert_inline_string input, :attributes => { 'max-attribute-value-size' => nil }
237
237
  assert_equal expected, result
238
238
  assert_equal 5000, result.bytesize
239
239
  end
@@ -244,7 +244,7 @@ content
244
244
 
245
245
  {imagesdir}
246
246
  EOS
247
- output = render_embedded_string input, :doctype => :inline, :safe => :safe
247
+ output = convert_inline_string input, :safe => :safe
248
248
  if RUBY_VERSION >= '1.9'
249
249
  assert_equal %(#{Dir.home}/etc/images), output
250
250
  else
@@ -258,12 +258,8 @@ EOS
258
258
 
259
259
  {imagesdir}
260
260
  EOS
261
- output = render_embedded_string input, :doctype => :inline, :safe => :server
262
- if RUBY_VERSION >= '1.9'
263
- assert_equal %(./etc/images), output
264
- else
265
- assert_equal %(./etc/images), output
266
- end
261
+ output = convert_inline_string input, :safe => :server
262
+ assert_equal './etc/images', output
267
263
  end
268
264
 
269
265
  test "apply custom substitutions to text in passthrough macro and assign to attribute" do
@@ -294,7 +290,7 @@ ifndef::holygrail[]
294
290
  Buggers! What happened to the grail?
295
291
  endif::holygrail[]
296
292
  EOS
297
- output = render_string input
293
+ output = convert_string input
298
294
  assert_xpath '//p', output, 2
299
295
  assert_xpath '(//p)[1][text() = "The holy grail has been found!"]', output, 1
300
296
  assert_xpath '(//p)[2][text() = "Buggers! What happened to the grail?"]', output, 1
@@ -356,6 +352,23 @@ endif::holygrail[]
356
352
  end
357
353
  end
358
354
 
355
+ test 'can soft unset built-in attribute from API and still override in document' do
356
+ [
357
+ { 'sectids!@' => '' },
358
+ { '!sectids@' => '' },
359
+ { 'sectids!' => '@' },
360
+ { '!sectids' => '@' },
361
+ { 'sectids' => false },
362
+ ].each do |attributes|
363
+ doc = document_from_string '== Heading', :attributes => attributes
364
+ refute doc.attr?('sectids')
365
+ assert_css '#_heading', (doc.convert :header_footer => false), 0
366
+ doc = document_from_string %(:sectids:\n\n== Heading), :attributes => attributes
367
+ assert doc.attr?('sectids')
368
+ assert_css '#_heading', (doc.convert :header_footer => false), 1
369
+ end
370
+ end
371
+
359
372
  test 'backend and doctype attributes are set by default in default configuration' do
360
373
  input = <<-EOS
361
374
  = Document Title
@@ -563,8 +576,8 @@ toc toc-placement! | |content |macro |nil
563
576
 
564
577
  context 'Interpolation' do
565
578
 
566
- test "render properly with simple names" do
567
- html = render_string(":frog: Tanglefoot\n:my_super-hero: Spiderman\n\nYo, {frog}!\nBeat {my_super-hero}!")
579
+ test "convert properly with simple names" do
580
+ html = convert_string(":frog: Tanglefoot\n:my_super-hero: Spiderman\n\nYo, {frog}!\nBeat {my_super-hero}!")
568
581
  result = Nokogiri::HTML(html)
569
582
  assert_equal "Yo, Tanglefoot!\nBeat Spiderman!", result.css("p").first.content.strip
570
583
  end
@@ -577,13 +590,13 @@ He-Man: {He-Man}
577
590
 
578
591
  She-Ra: {She-Ra}
579
592
  EOS
580
- result = render_embedded_string input, :attributes => {'She-Ra' => 'The Princess of Power'}
593
+ result = convert_string_to_embedded input, :attributes => {'She-Ra' => 'The Princess of Power'}
581
594
  assert_xpath '//p[text()="He-Man: The most powerful man in the universe"]', result, 1
582
595
  assert_xpath '//p[text()="She-Ra: The Princess of Power"]', result, 1
583
596
  end
584
597
 
585
- test "render properly with single character name" do
586
- html = render_string(":r: Ruby\n\nR is for {r}!")
598
+ test "convert properly with single character name" do
599
+ html = convert_string(":r: Ruby\n\nR is for {r}!")
587
600
  result = Nokogiri::HTML(html)
588
601
  assert_equal 'R is for Ruby!', result.css("p").first.content.strip
589
602
  end
@@ -596,7 +609,7 @@ Main Header
596
609
 
597
610
  Yo, {myfrog}!
598
611
  EOS
599
- output = render_string input
612
+ output = convert_string input
600
613
  assert_xpath '(//p)[1][text()="Yo, Tanglefoot!"]', output, 1
601
614
  end
602
615
 
@@ -608,13 +621,13 @@ This is
608
621
  blah blah {foobarbaz}
609
622
  all there is.
610
623
  EOS
611
- output = render_embedded_string input
624
+ output = convert_string_to_embedded input
612
625
  para = xmlnodes_at_css 'p', output, 1
613
626
  refute_includes 'blah blah', para.content
614
627
  assert_message @logger, :WARN, 'dropping line containing reference to missing attribute: foobarbaz'
615
628
  end
616
629
 
617
- test "attribute value gets interpretted when rendering" do
630
+ test "attribute value gets interpretted when converting" do
618
631
  doc = document_from_string(":google: http://google.com[Google]\n\n{google}")
619
632
  assert_equal 'http://google.com[Google]', doc.attributes['google']
620
633
  output = doc.convert
@@ -629,7 +642,7 @@ Line 1: This line should appear in the output.
629
642
  Line 2: Oh no, a {bogus-attribute}! This line should not appear in the output.
630
643
  EOS
631
644
 
632
- output = render_embedded_string input
645
+ output = convert_string_to_embedded input
633
646
  assert_match(/Line 1/, output)
634
647
  refute_match(/Line 2/, output)
635
648
  assert_message @logger, :WARN, 'dropping line containing reference to missing attribute: bogus-attribute'
@@ -641,7 +654,7 @@ Line 1: This line should appear in the output.
641
654
  Line 2: A {bogus-attribute}! This time, this line should appear in the output.
642
655
  EOS
643
656
 
644
- output = render_embedded_string input
657
+ output = convert_string_to_embedded input
645
658
  assert_match(/Line 1/, output)
646
659
  assert_match(/Line 2/, output)
647
660
  assert_match(/\{bogus-attribute\}/, output)
@@ -655,7 +668,7 @@ Line 1: This line should appear in the output.
655
668
  Line 2: {set:a!}This line should not appear in the output.
656
669
  EOS
657
670
 
658
- output = render_embedded_string input
671
+ output = convert_string_to_embedded input
659
672
  assert_match(/Line 1/, output)
660
673
  refute_match(/Line 2/, output)
661
674
  end
@@ -669,7 +682,7 @@ Line 1: This line should appear in the output.
669
682
  Line 2: {set:a!}This line should appear in the output.
670
683
  EOS
671
684
 
672
- output = render_embedded_string input
685
+ output = convert_string_to_embedded input
673
686
  assert_match(/Line 1/, output)
674
687
  assert_match(/Line 2/, output)
675
688
  refute_match(/\{set:a!\}/, output)
@@ -682,7 +695,7 @@ Line 1
682
695
  Line 2
683
696
  EOS
684
697
 
685
- output = render_embedded_string input
698
+ output = convert_string_to_embedded input
686
699
  assert_xpath %(//p[text()="Line 1\nLine 2"]), output, 1
687
700
  end
688
701
 
@@ -693,18 +706,18 @@ Line 1
693
706
  Line 2
694
707
  EOS
695
708
 
696
- output = render_embedded_string input, :attributes => { 'attribute-missing' => 'drop' }
709
+ output = convert_string_to_embedded input, :attributes => { 'attribute-missing' => 'drop' }
697
710
  assert_xpath %(//p[text()="Line 1\nLine 2"]), output, 1
698
711
  end
699
712
 
700
713
  test "substitutes inside unordered list items" do
701
- html = render_string(":foo: bar\n* snort at the {foo}\n* yawn")
714
+ html = convert_string(":foo: bar\n* snort at the {foo}\n* yawn")
702
715
  result = Nokogiri::HTML(html)
703
716
  assert_match(/snort at the bar/, result.css("li").first.content.strip)
704
717
  end
705
718
 
706
719
  test 'substitutes inside section title' do
707
- output = render_string(":prefix: Cool\n\n== {prefix} Title\n\ncontent")
720
+ output = convert_string(":prefix: Cool\n\n== {prefix} Title\n\ncontent")
708
721
  result = Nokogiri::HTML(output)
709
722
  assert_match(/Cool Title/, result.css('h2').first.content)
710
723
  assert_match(/_cool_title/, result.css('h2').first.attr('id'))
@@ -794,7 +807,7 @@ content
794
807
  .Require the +{gem_name}+ gem
795
808
  To use {gem_name}, the first thing to do is to import it in your Ruby source file.
796
809
  EOS
797
- output = render_embedded_string input, :attributes => {'compat-mode' => ''}
810
+ output = convert_string_to_embedded input, :attributes => {'compat-mode' => ''}
798
811
  assert_xpath '//*[@class="title"]/code[text()="asciidoctor"]', output, 1
799
812
 
800
813
  input = <<-EOS
@@ -803,11 +816,11 @@ To use {gem_name}, the first thing to do is to import it in your Ruby source fil
803
816
  .Require the `{gem_name}` gem
804
817
  To use {gem_name}, the first thing to do is to import it in your Ruby source file.
805
818
  EOS
806
- output = render_embedded_string input
819
+ output = convert_string_to_embedded input
807
820
  assert_xpath '//*[@class="title"]/code[text()="asciidoctor"]', output, 1
808
821
  end
809
822
 
810
- test 'renders attribute until it is deleted' do
823
+ test 'sets attribute until it is deleted' do
811
824
  input = <<-EOS
812
825
  :foo: bar
813
826
 
@@ -817,7 +830,7 @@ Crossing the {foo}.
817
830
 
818
831
  Belly up to the {foo}.
819
832
  EOS
820
- output = render_embedded_string input
833
+ output = convert_string_to_embedded input
821
834
  assert_xpath '//p[text()="Crossing the bar."]', output, 1
822
835
  assert_xpath '//p[text()="Belly up to the bar."]', output, 0
823
836
  end
@@ -840,20 +853,20 @@ Belly up to the {foo}.
840
853
  `{foo}`
841
854
  EOS
842
855
 
843
- result = render_embedded_string input, :attributes => {'compat-mode' => '@'}
856
+ result = convert_string_to_embedded input, :attributes => {'compat-mode' => '@'}
844
857
  assert_xpath '/*[@id="paragraph-a"]//code[text()="{foo}"]', result, 1
845
858
  assert_xpath '/*[@id="paragraph-b"]//code[text()="bar"]', result, 1
846
859
  assert_xpath '/*[@id="paragraph-c"]//code[text()="{foo}"]', result, 1
847
860
  end
848
861
 
849
862
  test 'does not disturb attribute-looking things escaped with backslash' do
850
- html = render_string(":foo: bar\nThis is a \\{foo} day.")
863
+ html = convert_string(":foo: bar\nThis is a \\{foo} day.")
851
864
  result = Nokogiri::HTML(html)
852
865
  assert_equal 'This is a {foo} day.', result.css('p').first.content.strip
853
866
  end
854
867
 
855
868
  test 'does not disturb attribute-looking things escaped with literals' do
856
- html = render_string(":foo: bar\nThis is a +++{foo}+++ day.")
869
+ html = convert_string(":foo: bar\nThis is a +++{foo}+++ day.")
857
870
  result = Nokogiri::HTML(html)
858
871
  assert_equal 'This is a {foo} day.', result.css('p').first.content.strip
859
872
  end
@@ -866,7 +879,7 @@ Belly up to the {foo}.
866
879
  puts 'The forecast for today is {forecast}'
867
880
  ----
868
881
  EOS
869
- output = render_string(input)
882
+ output = convert_string(input)
870
883
  assert_match(/\{forecast\}/, output)
871
884
  end
872
885
 
@@ -879,7 +892,7 @@ You insert the text {foo} to expand the value
879
892
  of the attribute named foo in your document.
880
893
  ....
881
894
  EOS
882
- output = render_string(input)
895
+ output = convert_string(input)
883
896
  assert_match(/\{foo\}/, output)
884
897
  end
885
898
 
@@ -891,7 +904,7 @@ of the attribute named foo in your document.
891
904
 
892
905
  docdir = Dir.pwd
893
906
  docfile = File.join(docdir, 'sample.asciidoc')
894
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docdir' => docdir, 'docfile' => docfile}
907
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER, :attributes => {'docdir' => docdir, 'docfile' => docfile}
895
908
  assert_xpath '//li[1]/p[text()="docdir: "]', output, 1
896
909
  assert_xpath '//li[2]/p[text()="docfile: sample.asciidoc"]', output, 1
897
910
  end
@@ -904,28 +917,28 @@ of the attribute named foo in your document.
904
917
 
905
918
  docdir = Dir.pwd
906
919
  docfile = File.join(docdir, 'sample.asciidoc')
907
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'docdir' => docdir, 'docfile' => docfile}
920
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'docdir' => docdir, 'docfile' => docfile}
908
921
  assert_xpath %(//li[1]/p[text()="docdir: #{docdir}"]), output, 1
909
922
  assert_xpath %(//li[2]/p[text()="docfile: #{docfile}"]), output, 1
910
923
  end
911
924
 
912
925
  test 'assigns attribute defined in attribute reference with set prefix and value' do
913
926
  input = '{set:foo:bar}{foo}'
914
- output = render_embedded_string input
927
+ output = convert_string_to_embedded input
915
928
  assert_xpath '//p', output, 1
916
929
  assert_xpath '//p[text()="bar"]', output, 1
917
930
  end
918
931
 
919
932
  test 'assigns attribute defined in attribute reference with set prefix and no value' do
920
933
  input = "{set:foo}\n{foo}yes"
921
- output = render_embedded_string input
934
+ output = convert_string_to_embedded input
922
935
  assert_xpath '//p', output, 1
923
936
  assert_xpath '//p[normalize-space(text())="yes"]', output, 1
924
937
  end
925
938
 
926
939
  test 'assigns attribute defined in attribute reference with set prefix and empty value' do
927
940
  input = "{set:foo:}\n{foo}yes"
928
- output = render_embedded_string input
941
+ output = convert_string_to_embedded input
929
942
  assert_xpath '//p', output, 1
930
943
  assert_xpath '//p[normalize-space(text())="yes"]', output, 1
931
944
  end
@@ -938,7 +951,7 @@ of the attribute named foo in your document.
938
951
  {set:foo!}
939
952
  {foo}yes
940
953
  EOS
941
- output = render_embedded_string input
954
+ output = convert_string_to_embedded input
942
955
  assert_xpath '//p', output, 1
943
956
  assert_xpath '//p/child::text()', output, 0
944
957
  end
@@ -948,19 +961,19 @@ of the attribute named foo in your document.
948
961
 
949
962
  test "substitute intrinsics" do
950
963
  Asciidoctor::INTRINSIC_ATTRIBUTES.each_pair do |key, value|
951
- html = render_string("Look, a {#{key}} is here")
964
+ html = convert_string("Look, a {#{key}} is here")
952
965
  # can't use Nokogiri because it interprets the HTML entities and we can't match them
953
966
  assert_match(/Look, a #{Regexp.escape(value)} is here/, html)
954
967
  end
955
968
  end
956
969
 
957
970
  test "don't escape intrinsic substitutions" do
958
- html = render_string('happy{nbsp}together')
971
+ html = convert_string('happy{nbsp}together')
959
972
  assert_match(/happy&#160;together/, html)
960
973
  end
961
974
 
962
975
  test "escape special characters" do
963
- html = render_string('<node>&</node>')
976
+ html = convert_string('<node>&</node>')
964
977
  assert_match(/&lt;node&gt;&amp;&lt;\/node&gt;/, html)
965
978
  end
966
979
 
@@ -1089,7 +1102,7 @@ image::baz.jpg[]
1089
1102
  image::qux.jpg[]
1090
1103
  EOS
1091
1104
 
1092
- output = render_embedded_string input
1105
+ output = convert_string_to_embedded input
1093
1106
  assert_xpath '//div[@class="title"]', output, 4
1094
1107
  assert_xpath '//div[@class="title"][text() = "Figure 1. Title for Foo"]', output, 1
1095
1108
  assert_xpath '//div[@class="title"][text() = "Figure 2. Title for Bar"]', output, 1
@@ -1166,7 +1179,7 @@ ____
1166
1179
  [title='*title*']
1167
1180
  content
1168
1181
  EOS
1169
- output = render_embedded_string input
1182
+ output = convert_string_to_embedded input
1170
1183
  assert_xpath '//*[@class="title"]/strong[text()="title"]', output, 1
1171
1184
  end
1172
1185
 
@@ -1518,7 +1531,7 @@ A normal paragraph
1518
1531
  == Section
1519
1532
  Content.
1520
1533
  EOS
1521
- output = render_embedded_string input
1534
+ output = convert_string_to_embedded input
1522
1535
  assert_xpath '/div[@class="sect1 small"]', output, 1
1523
1536
  assert_xpath '/div[@class="sect1 small"]/h2[@id="dedication"]', output, 1
1524
1537
  end
@@ -18,14 +18,14 @@ context 'Blocks' do
18
18
  context 'Layout Breaks' do
19
19
  test 'horizontal rule' do
20
20
  %w(''' '''' '''''').each do |line|
21
- output = render_embedded_string line
21
+ output = convert_string_to_embedded line
22
22
  assert_includes output, '<hr>'
23
23
  end
24
24
  end
25
25
 
26
26
  test '< 3 chars does not make horizontal rule' do
27
27
  %w(' '').each do |line|
28
- output = render_embedded_string line
28
+ output = convert_string_to_embedded line
29
29
  refute_includes output, '<hr>'
30
30
  assert_includes output, %(<p>#{line}</p>)
31
31
  end
@@ -33,21 +33,21 @@ context 'Blocks' do
33
33
 
34
34
  test 'mixed chars does not make horizontal rule' do
35
35
  [%q(''<), %q('''<), %q(' ' ')].each do |line|
36
- output = render_embedded_string line
36
+ output = convert_string_to_embedded line
37
37
  refute_includes output, '<hr>'
38
38
  assert_includes output, %(<p>#{line.sub '<', '&lt;'}</p>)
39
39
  end
40
40
  end
41
41
 
42
42
  test 'horizontal rule between blocks' do
43
- output = render_embedded_string %(Block above\n\n'''\n\nBlock below)
43
+ output = convert_string_to_embedded %(Block above\n\n'''\n\nBlock below)
44
44
  assert_xpath '/hr', output, 1
45
45
  assert_xpath '/hr/preceding-sibling::*', output, 1
46
46
  assert_xpath '/hr/following-sibling::*', output, 1
47
47
  end
48
48
 
49
49
  test 'page break' do
50
- output = render_embedded_string %(page 1\n\n<<<\n\npage 2)
50
+ output = convert_string_to_embedded %(page 1\n\n<<<\n\npage 2)
51
51
  assert_xpath '/*[translate(@style, ";", "")="page-break-after: always"]', output, 1
52
52
  assert_xpath '/*[translate(@style, ";", "")="page-break-after: always"]/preceding-sibling::div/p[text()="page 1"]', output, 1
53
53
  assert_xpath '/*[translate(@style, ";", "")="page-break-after: always"]/following-sibling::div/p[text()="page 2"]', output, 1
@@ -63,7 +63,7 @@ first paragraph
63
63
 
64
64
  second paragraph
65
65
  EOS
66
- output = render_embedded_string input
66
+ output = convert_string_to_embedded input
67
67
  refute_match(/line comment/, output)
68
68
  assert_xpath '//p', output, 2
69
69
  end
@@ -74,7 +74,7 @@ first line
74
74
  // line comment
75
75
  second line
76
76
  EOS
77
- output = render_embedded_string input
77
+ output = convert_string_to_embedded input
78
78
  refute_match(/line comment/, output)
79
79
  assert_xpath '//p', output, 1
80
80
  assert_xpath "//p[1][text()='first line\nsecond line']", output, 1
@@ -90,7 +90,7 @@ block comment
90
90
 
91
91
  second paragraph
92
92
  EOS
93
- output = render_embedded_string input
93
+ output = convert_string_to_embedded input
94
94
  refute_match(/block comment/, output)
95
95
  assert_xpath '//p', output, 2
96
96
  end
@@ -107,7 +107,7 @@ block comment
107
107
  second paragraph
108
108
  ====
109
109
  EOS
110
- output = render_embedded_string input
110
+ output = convert_string_to_embedded input
111
111
  refute_match(/block comment/, output)
112
112
  assert_xpath '//p', output, 2
113
113
  end
@@ -120,12 +120,12 @@ block comment
120
120
  ////
121
121
  second paragraph
122
122
  EOS
123
- output = render_embedded_string input
123
+ output = convert_string_to_embedded input
124
124
  refute_match(/block comment/, output)
125
125
  assert_xpath '//p', output, 2
126
126
  end
127
127
 
128
- test "can render with block comment at end of document with trailing endlines" do
128
+ test "can convert with block comment at end of document with trailing endlines" do
129
129
  input = <<-EOS
130
130
  paragraph
131
131
 
@@ -135,7 +135,7 @@ block comment
135
135
 
136
136
 
137
137
  EOS
138
- output = render_embedded_string input
138
+ output = convert_string_to_embedded input
139
139
  refute_match(/block comment/, output)
140
140
  end
141
141
 
@@ -159,7 +159,7 @@ block comment
159
159
  /// not a line comment
160
160
  EOS
161
161
 
162
- output = render_embedded_string input
162
+ output = convert_string_to_embedded input
163
163
  refute_empty output.strip, "Line should be emitted => #{input.rstrip}"
164
164
  end
165
165
 
@@ -169,11 +169,11 @@ block comment
169
169
  ////
170
170
  ifdef::asciidoctor[////]
171
171
  ////
172
- line should be rendered
172
+ line should be shown
173
173
  EOS
174
174
 
175
- output = render_embedded_string input
176
- assert_xpath '//p[text() = "line should be rendered"]', output, 1
175
+ output = convert_string_to_embedded input
176
+ assert_xpath '//p[text() = "line should be shown"]', output, 1
177
177
  end
178
178
 
179
179
  test 'preprocessor directives should not be processed within comment block' do
@@ -184,11 +184,11 @@ dummy line
184
184
  ifdef::asciidoctor[////]
185
185
  ////
186
186
 
187
- line should be rendered
187
+ line should be shown
188
188
  EOS
189
189
 
190
- output = render_embedded_string input
191
- assert_xpath '//p[text() = "line should be rendered"]', output, 1
190
+ output = convert_string_to_embedded input
191
+ assert_xpath '//p[text() = "line should be shown"]', output, 1
192
192
  end
193
193
 
194
194
  test 'should warn if unterminated comment block is detected in body' do
@@ -201,7 +201,7 @@ content that has been disabled
201
201
  supposed to be after comment block, except it got swallowed by block comment
202
202
  EOS
203
203
 
204
- render_embedded_string input
204
+ convert_string_to_embedded input
205
205
  assert_message @logger, :WARN, '<stdin>: line 3: unterminated comment block', Hash
206
206
  end
207
207
 
@@ -217,7 +217,7 @@ content that has been disabled
217
217
  supposed to be after sidebar block, except it got swallowed by block comment
218
218
  EOS
219
219
 
220
- render_embedded_string input
220
+ convert_string_to_embedded input
221
221
  assert_message @logger, :WARN, '<stdin>: line 4: unterminated comment block', Hash
222
222
  end
223
223
 
@@ -229,12 +229,12 @@ supposed to be after sidebar block, except it got swallowed by block comment
229
229
  --
230
230
  first line of comment
231
231
  ifdef::asciidoctor[--]
232
- line should not be rendered
232
+ line should not be shown
233
233
  --
234
234
 
235
235
  EOS
236
236
 
237
- output = render_embedded_string input
237
+ output = convert_string_to_embedded input
238
238
  assert_xpath '//p', output, 0
239
239
  end
240
240
 
@@ -246,11 +246,11 @@ line should not be rendered
246
246
  first line of content
247
247
  ifdef::asciidoctor[////]
248
248
 
249
- this line should be rendered
249
+ this line should be shown
250
250
  EOS
251
251
 
252
- output = render_embedded_string input
253
- assert_xpath '//p[text() = "this line should be rendered"]', output, 1
252
+ output = convert_string_to_embedded input
253
+ assert_xpath '//p[text() = "this line should be shown"]', output, 1
254
254
  end
255
255
 
256
256
  test 'comment style on open block should only skip block' do
@@ -264,7 +264,7 @@ this block
264
264
 
265
265
  not this text
266
266
  EOS
267
- result = render_embedded_string input
267
+ result = convert_string_to_embedded input
268
268
  assert_xpath '//p', result, 1
269
269
  assert_xpath '//p[text()="not this text"]', result, 1
270
270
  end
@@ -277,7 +277,7 @@ this paragraph
277
277
 
278
278
  not this text
279
279
  EOS
280
- result = render_embedded_string input
280
+ result = convert_string_to_embedded input
281
281
  assert_xpath '//p', result, 1
282
282
  assert_xpath '//p[text()="not this text"]', result, 1
283
283
  end
@@ -290,7 +290,7 @@ this paragraph
290
290
  [example]
291
291
  not this text
292
292
  EOS
293
- result = render_embedded_string input
293
+ result = convert_string_to_embedded input
294
294
  assert_xpath '/*[@class="exampleblock"]', result, 1
295
295
  assert_xpath '/*[@class="exampleblock"]//*[normalize-space(text())="not this text"]', result, 1
296
296
  end
@@ -307,7 +307,7 @@ skip
307
307
  paragraph
308
308
  ====
309
309
  EOS
310
- result = render_embedded_string input
310
+ result = convert_string_to_embedded input
311
311
  assert_xpath '/*[@class="exampleblock"]', result, 1
312
312
  assert_xpath '/*[@class="exampleblock"]//*[@class="paragraph"]', result, 2
313
313
  assert_xpath '//*[@class="paragraph"][@id="idname"]', result, 0
@@ -321,7 +321,7 @@ ____
321
321
  A famous quote.
322
322
  ____
323
323
  EOS
324
- output = render_string input
324
+ output = convert_string input
325
325
  assert_css '.quoteblock', output, 1
326
326
  assert_css '.quoteblock > blockquote', output, 1
327
327
  assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
@@ -336,7 +336,7 @@ ____
336
336
  A famous quote.
337
337
  ____
338
338
  EOS
339
- output = render_string input
339
+ output = convert_string input
340
340
  assert_css '.quoteblock', output, 1
341
341
  assert_css '.quoteblock > blockquote', output, 1
342
342
  assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
@@ -357,7 +357,7 @@ Injustice anywhere is a threat to justice everywhere.
357
357
  ____
358
358
  EOS
359
359
 
360
- output = render_embedded_string input
360
+ output = convert_string_to_embedded input
361
361
  assert_css '.quoteblock', output, 1
362
362
  assert_css '#justice-to-all.quoteblock.solidarity', output, 1
363
363
  assert_css '.quoteblock > .attribution', output, 1
@@ -372,7 +372,7 @@ Injustice anywhere is a threat to justice everywhere.
372
372
  ____
373
373
  EOS
374
374
 
375
- output = render_embedded_string input
375
+ output = convert_string_to_embedded input
376
376
  assert_css '.quoteblock', output, 1
377
377
  assert_css '#justice-to-all.quoteblock.solidarity', output, 1
378
378
  assert_css '.quoteblock > .attribution', output, 1
@@ -386,7 +386,7 @@ A famous quote.
386
386
  NOTE: _That_ was inspiring.
387
387
  ____
388
388
  EOS
389
- output = render_string input
389
+ output = convert_string input
390
390
  assert_css '.quoteblock', output, 1
391
391
  assert_css '.quoteblock > blockquote', output, 1
392
392
  assert_css '.quoteblock > blockquote > .paragraph', output, 1
@@ -400,7 +400,7 @@ ____
400
400
  A famous quote.
401
401
  ____
402
402
  EOS
403
- output = render_string input, :backend => :docbook
403
+ output = convert_string input, :backend => :docbook
404
404
  assert_css 'blockquote', output, 1
405
405
  assert_css 'blockquote > simpara', output, 1
406
406
  assert_css 'blockquote > attribution', output, 1
@@ -418,7 +418,7 @@ ____
418
418
  A famous quote.
419
419
  ____
420
420
  EOS
421
- output = render_string input, :backend => :docbook
421
+ output = convert_string input, :backend => :docbook
422
422
  assert_css 'epigraph', output, 1
423
423
  assert_css 'epigraph > simpara', output, 1
424
424
  assert_css 'epigraph > attribution', output, 1
@@ -435,7 +435,7 @@ ____
435
435
  A famous quote.
436
436
  ""
437
437
  EOS
438
- output = render_string input
438
+ output = convert_string input
439
439
  assert_css '.quoteblock', output, 1
440
440
  assert_css '.quoteblock > blockquote', output, 1
441
441
  assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
@@ -448,7 +448,7 @@ A famous quote.
448
448
  > A famous quote.
449
449
  > Some more inspiring words.
450
450
  EOS
451
- output = render_string input
451
+ output = convert_string input
452
452
  assert_css '.quoteblock', output, 1
453
453
  assert_css '.quoteblock > blockquote', output, 1
454
454
  assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
@@ -461,7 +461,7 @@ A famous quote.
461
461
  > A famous quote.
462
462
  Some more inspiring words.
463
463
  EOS
464
- output = render_string input
464
+ output = convert_string input
465
465
  assert_css '.quoteblock', output, 1
466
466
  assert_css '.quoteblock > blockquote', output, 1
467
467
  assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
@@ -475,7 +475,7 @@ Some more inspiring words.
475
475
  >
476
476
  > Some more inspiring words.
477
477
  EOS
478
- output = render_string input
478
+ output = convert_string input
479
479
  assert_css '.quoteblock', output, 1
480
480
  assert_css '.quoteblock > blockquote', output, 1
481
481
  assert_css '.quoteblock > blockquote > .paragraph > p', output, 2
@@ -490,7 +490,7 @@ Some more inspiring words.
490
490
  >
491
491
  > NOTE: Some more inspiring words.
492
492
  EOS
493
- output = render_string input
493
+ output = convert_string input
494
494
  assert_css '.quoteblock', output, 1
495
495
  assert_css '.quoteblock > blockquote', output, 1
496
496
  assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
@@ -506,7 +506,7 @@ Some more inspiring words.
506
506
  > Some more inspiring words.
507
507
  > -- Famous Person, Famous Source, Volume 1 (1999)
508
508
  EOS
509
- output = render_string input
509
+ output = convert_string input
510
510
  assert_css '.quoteblock', output, 1
511
511
  assert_css '.quoteblock > blockquote', output, 1
512
512
  assert_css '.quoteblock > blockquote > .paragraph > p', output, 1
@@ -527,7 +527,7 @@ Some more inspiring words.
527
527
  -- Thomas Jefferson, https://jeffersonpapers.princeton.edu/selected-documents/james-madison-1[The Papers of Thomas Jefferson, Volume 11]
528
528
  EOS
529
529
 
530
- output = render_embedded_string input
530
+ output = convert_string_to_embedded input
531
531
  assert_css '.quoteblock', output, 1
532
532
  assert_css '.quoteblock cite a[href="https://jeffersonpapers.princeton.edu/selected-documents/james-madison-1"]', output, 1
533
533
  end
@@ -538,7 +538,7 @@ Some more inspiring words.
538
538
  Some more inspiring words."
539
539
  -- Famous Person, Famous Source, Volume 1 (1999)
540
540
  EOS
541
- output = render_string input
541
+ output = convert_string input
542
542
  assert_css '.quoteblock', output, 1
543
543
  assert_css '.quoteblock > blockquote', output, 1
544
544
  assert_xpath %(//*[@class = "quoteblock"]/blockquote[normalize-space(text()) = "A famous quote. Some more inspiring words."]), output, 1
@@ -558,7 +558,7 @@ and as necessary in the political world as storms in the physical."
558
558
  -- Thomas Jefferson, https://jeffersonpapers.princeton.edu/selected-documents/james-madison-1[The Papers of Thomas Jefferson, Volume 11]
559
559
  EOS
560
560
 
561
- output = render_embedded_string input
561
+ output = convert_string_to_embedded input
562
562
  assert_css '.quoteblock', output, 1
563
563
  assert_css '.quoteblock cite a[href="https://jeffersonpapers.princeton.edu/selected-documents/james-madison-1"]', output, 1
564
564
  end
@@ -570,7 +570,7 @@ ____
570
570
  A famous verse.
571
571
  ____
572
572
  EOS
573
- output = render_string input
573
+ output = convert_string input
574
574
  assert_css '.verseblock', output, 1
575
575
  assert_css '.verseblock > pre', output, 1
576
576
  assert_css '.verseblock > .attribution', output, 0
@@ -585,7 +585,7 @@ ____
585
585
  A famous verse.
586
586
  ____
587
587
  EOS
588
- output = render_string input
588
+ output = convert_string input
589
589
  assert_css '.verseblock', output, 1
590
590
  assert_css '.verseblock p', output, 0
591
591
  assert_css '.verseblock > pre', output, 1
@@ -605,7 +605,7 @@ ____
605
605
  A famous verse.
606
606
  ____
607
607
  EOS
608
- output = render_string input, :backend => :docbook
608
+ output = convert_string input, :backend => :docbook
609
609
  assert_css 'blockquote', output, 1
610
610
  assert_css 'blockquote simpara', output, 0
611
611
  assert_css 'blockquote > literallayout', output, 1
@@ -624,7 +624,7 @@ ____
624
624
  A famous verse.
625
625
  ____
626
626
  EOS
627
- output = render_string input, :backend => :docbook
627
+ output = convert_string input, :backend => :docbook
628
628
  assert_css 'epigraph', output, 1
629
629
  assert_css 'epigraph simpara', output, 0
630
630
  assert_css 'epigraph > literallayout', output, 1
@@ -645,7 +645,7 @@ A famous verse.
645
645
  Stanza two.
646
646
  ____
647
647
  EOS
648
- output = render_string input
648
+ output = convert_string input
649
649
  assert_xpath '//*[@class = "verseblock"]', output, 1
650
650
  assert_xpath '//*[@class = "verseblock"]/pre', output, 1
651
651
  assert_xpath '//*[@class = "verseblock"]//p', output, 0
@@ -664,7 +664,7 @@ not a literal
664
664
  ....
665
665
  ____
666
666
  EOS
667
- output = render_string input
667
+ output = convert_string input
668
668
  assert_css '.verseblock', output, 1
669
669
  assert_css '.verseblock > pre', output, 1
670
670
  assert_css '.verseblock p', output, 0
@@ -692,7 +692,7 @@ ____
692
692
  <1> Not pointing to a callout
693
693
  EOS
694
694
 
695
- output = render_embedded_string input
695
+ output = convert_string_to_embedded input
696
696
  assert_xpath '//pre[text()="La la la <1>"]', output, 1
697
697
  assert_message @logger, :WARN, '<stdin>: line 5: no callout found for <1>', Hash
698
698
  end
@@ -705,13 +705,13 @@ _GET /groups/link:#group-id[\{group-id\}]_
705
705
  ____
706
706
  EOS
707
707
 
708
- output = render_embedded_string input
708
+ output = convert_string_to_embedded input
709
709
  assert_includes output, '<pre class="content"><em>GET /groups/<a href="#group-id">{group-id}</a></em></pre>'
710
710
  end
711
711
  end
712
712
 
713
713
  context "Example Blocks" do
714
- test "can render example block" do
714
+ test "can convert example block" do
715
715
  input = <<-EOS
716
716
  ====
717
717
  This is an example of an example block.
@@ -720,11 +720,11 @@ How crazy is that?
720
720
  ====
721
721
  EOS
722
722
 
723
- output = render_string input
723
+ output = convert_string input
724
724
  assert_xpath '//*[@class="exampleblock"]//p', output, 2
725
725
  end
726
726
 
727
- test "assigns sequential numbered caption to example block with title" do
727
+ test 'assigns sequential numbered caption to example block with title' do
728
728
  input = <<-EOS
729
729
  .Writing Docs with AsciiDoc
730
730
  ====
@@ -742,7 +742,9 @@ You futz with XML.
742
742
  EOS
743
743
 
744
744
  doc = document_from_string input
745
+ assert_equal 1, doc.blocks[0].numeral
745
746
  assert_equal 1, doc.blocks[0].number
747
+ assert_equal 2, doc.blocks[1].numeral
746
748
  assert_equal 2, doc.blocks[1].number
747
749
  output = doc.convert
748
750
  assert_xpath '(//*[@class="exampleblock"])[1]/*[@class="title"][text()="Example 1. Writing Docs with AsciiDoc"]', output, 1
@@ -750,7 +752,7 @@ You futz with XML.
750
752
  assert_equal 2, doc.attributes['example-number']
751
753
  end
752
754
 
753
- test "assigns sequential character caption to example block with title" do
755
+ test 'assigns sequential character caption to example block with title' do
754
756
  input = <<-EOS
755
757
  :example-number: @
756
758
 
@@ -770,7 +772,9 @@ You futz with XML.
770
772
  EOS
771
773
 
772
774
  doc = document_from_string input
775
+ assert_equal 'A', doc.blocks[0].numeral
773
776
  assert_equal 'A', doc.blocks[0].number
777
+ assert_equal 'B', doc.blocks[1].numeral
774
778
  assert_equal 'B', doc.blocks[1].number
775
779
  output = doc.convert
776
780
  assert_xpath '(//*[@class="exampleblock"])[1]/*[@class="title"][text()="Example A. Writing Docs with AsciiDoc"]', output, 1
@@ -790,7 +794,7 @@ You just write.
790
794
  EOS
791
795
 
792
796
  doc = document_from_string input
793
- assert_nil doc.blocks[0].number
797
+ assert_nil doc.blocks[0].numeral
794
798
  output = doc.convert
795
799
  assert_xpath '(//*[@class="exampleblock"])[1]/*[@class="title"][text()="Look! Writing Docs with AsciiDoc"]', output, 1
796
800
  refute doc.attributes.has_key?('example-number')
@@ -819,7 +823,7 @@ yet another example
819
823
  ====
820
824
  EOS
821
825
 
822
- output = render_embedded_string input
826
+ output = convert_string_to_embedded input
823
827
  assert_xpath '/*[@class="exampleblock"]', output, 3
824
828
  assert_xpath '(/*[@class="exampleblock"])[1]/*[@class="title"][starts-with(text(), "Example ")]', output, 1
825
829
  assert_xpath '(/*[@class="exampleblock"])[2]/*[@class="title"][text()="second example"]', output, 1
@@ -838,7 +842,7 @@ still inside
838
842
  eof
839
843
  EOS
840
844
 
841
- output = render_embedded_string input
845
+ output = convert_string_to_embedded input
842
846
  assert_xpath '/*[@class="exampleblock"]', output, 1
843
847
  assert_message @logger, :WARN, '<stdin>: line 3: unterminated example block', Hash
844
848
  end
@@ -853,7 +857,7 @@ eof
853
857
  TIP: Override the caption of an admonition block using an attribute entry
854
858
  EOS
855
859
 
856
- output = render_embedded_string input
860
+ output = convert_string_to_embedded input
857
861
  assert_xpath '/*[@class="admonitionblock tip"]//*[@class="icon"]/*[@class="title"][text()="Pro Tip"]', output, 1
858
862
  end
859
863
 
@@ -864,7 +868,7 @@ TIP: Override the caption of an admonition block using an attribute entry
864
868
  TIP: Override the caption of an admonition block using an attribute entry
865
869
  EOS
866
870
 
867
- output = render_embedded_string input
871
+ output = convert_string_to_embedded input
868
872
  assert_xpath '/*[@class="admonitionblock tip"]//*[@class="icon"]/*[@class="title"][text()="Pro Tip"]', output, 1
869
873
  end
870
874
 
@@ -875,7 +879,7 @@ TIP: Override the caption of an admonition block using an attribute entry
875
879
  TIP: Override the caption of an admonition block using an attribute entry
876
880
  EOS
877
881
 
878
- output = render_embedded_string input
882
+ output = convert_string_to_embedded input
879
883
  assert_xpath '/*[@class="admonitionblock tip"]//*[@class="icon"]/*[@class="title"][text()="Tip"]', output, 1
880
884
  end
881
885
  end
@@ -890,7 +894,7 @@ listing content
890
894
  paragraph 2
891
895
  EOS
892
896
 
893
- output = render_embedded_string input
897
+ output = convert_string_to_embedded input
894
898
  assert_xpath '/*[@class="paragraph"]/p', output, 2
895
899
  assert_xpath '/*[@class="listingblock"]', output, 1
896
900
  assert_xpath '(/*[@class="paragraph"]/following-sibling::*)[1][@class="listingblock"]', output, 1
@@ -907,7 +911,7 @@ line three
907
911
  ....
908
912
  EOS
909
913
  [true, false].each {|header_footer|
910
- output = render_string input, :header_footer => header_footer
914
+ output = convert_string input, :header_footer => header_footer
911
915
  assert_xpath '//pre', output, 1
912
916
  assert_xpath '//pre/text()', output, 1
913
917
  text = xmlnodes_at_xpath('//pre/text()', output, 1).text
@@ -932,7 +936,7 @@ line three
932
936
  ----
933
937
  EOS
934
938
  [true, false].each {|header_footer|
935
- output = render_string input, header_footer => header_footer
939
+ output = convert_string input, header_footer => header_footer
936
940
  assert_xpath '//pre/code', output, 1
937
941
  assert_xpath '//pre/code/text()', output, 1
938
942
  text = xmlnodes_at_xpath('//pre/code/text()', output, 1).text
@@ -959,7 +963,7 @@ ____
959
963
  --
960
964
  EOS
961
965
  [true, false].each {|header_footer|
962
- output = render_string input, :header_footer => header_footer
966
+ output = convert_string input, :header_footer => header_footer
963
967
  assert_xpath '//*[@class="verseblock"]/pre', output, 1
964
968
  assert_xpath '//*[@class="verseblock"]/pre/text()', output, 1
965
969
  text = xmlnodes_at_xpath('//*[@class="verseblock"]/pre/text()', output, 1).text
@@ -972,7 +976,7 @@ EOS
972
976
  }
973
977
  end
974
978
 
975
- test 'should strip leading and trailing blank lines when rendering verbatim block' do
979
+ test 'should strip leading and trailing blank lines when converting verbatim block' do
976
980
  input = <<-EOS
977
981
  [subs="attributes"]
978
982
  ....
@@ -1003,7 +1007,7 @@ source line 2\r
1003
1007
  ----\r
1004
1008
  EOS
1005
1009
 
1006
- output = render_embedded_string input
1010
+ output = convert_string_to_embedded input
1007
1011
  refute_match(/\[source\]/, output)
1008
1012
  assert_xpath '/*[@class="listingblock"]//pre', output, 1
1009
1013
  assert_xpath '/*[@class="listingblock"]//pre/code', output, 1
@@ -1030,7 +1034,7 @@ def names
1030
1034
  end
1031
1035
  EOS
1032
1036
 
1033
- output = render_embedded_string input
1037
+ output = convert_string_to_embedded input
1034
1038
  assert_css 'pre', output, 1
1035
1039
  assert_css '.listingblock pre', output, 1
1036
1040
  result = xmlnodes_at_xpath('//pre', output, 1).text
@@ -1057,7 +1061,7 @@ end
1057
1061
  end
1058
1062
  EOS
1059
1063
 
1060
- output = render_embedded_string input
1064
+ output = convert_string_to_embedded input
1061
1065
  assert_css 'pre', output, 1
1062
1066
  assert_css '.listingblock pre', output, 1
1063
1067
  result = xmlnodes_at_xpath('//pre', output, 1).text
@@ -1084,7 +1088,7 @@ end
1084
1088
  end
1085
1089
  EOS
1086
1090
 
1087
- output = render_embedded_string input
1091
+ output = convert_string_to_embedded input
1088
1092
  assert_css 'pre', output, 1
1089
1093
  assert_css '.listingblock pre', output, 1
1090
1094
  result = xmlnodes_at_xpath('//pre', output, 1).text
@@ -1113,7 +1117,7 @@ end
1113
1117
  end
1114
1118
  EOS
1115
1119
 
1116
- output = render_embedded_string input
1120
+ output = convert_string_to_embedded input
1117
1121
  assert_css 'pre', output, 1
1118
1122
  assert_css '.listingblock pre', output, 1
1119
1123
  result = xmlnodes_at_xpath('//pre', output, 1).text
@@ -1142,7 +1146,7 @@ def names
1142
1146
  end
1143
1147
  EOS
1144
1148
 
1145
- output = render_embedded_string input
1149
+ output = convert_string_to_embedded input
1146
1150
  assert_css 'pre', output, 1
1147
1151
  assert_css '.listingblock pre', output, 1
1148
1152
  result = xmlnodes_at_xpath('//pre', output, 1).text
@@ -1157,7 +1161,7 @@ Do not wrap me if I get too long.
1157
1161
  ----
1158
1162
  EOS
1159
1163
 
1160
- output = render_embedded_string input
1164
+ output = convert_string_to_embedded input
1161
1165
  assert_css 'pre.nowrap', output, 1
1162
1166
  end
1163
1167
 
@@ -1170,7 +1174,7 @@ Do not wrap me if I get too long.
1170
1174
  ----
1171
1175
  EOS
1172
1176
 
1173
- output = render_embedded_string input
1177
+ output = convert_string_to_embedded input
1174
1178
  assert_css 'pre.nowrap', output, 1
1175
1179
  end
1176
1180
 
@@ -1214,7 +1218,7 @@ AssertionError
1214
1218
  ----
1215
1219
  EOS
1216
1220
 
1217
- output = render_embedded_string input
1221
+ output = convert_string_to_embedded input
1218
1222
 
1219
1223
  assert_css '.listingblock pre', output, 1
1220
1224
  assert_css '.listingblock pre strong', output, 1
@@ -1231,7 +1235,7 @@ AssertionError
1231
1235
  ----
1232
1236
  EOS
1233
1237
 
1234
- output2 = render_embedded_string input2
1238
+ output2 = convert_string_to_embedded input2
1235
1239
  # FIXME JRuby is adding extra trailing endlines in the second document,
1236
1240
  # for now, rstrip is necessary
1237
1241
  assert_equal output.rstrip, output2.rstrip
@@ -1247,7 +1251,7 @@ AssertionError
1247
1251
  ----
1248
1252
  EOS
1249
1253
 
1250
- output = render_embedded_string input
1254
+ output = convert_string_to_embedded input
1251
1255
  assert_xpath '//*[@class="title"][text()=".gitignore"]', output
1252
1256
  end
1253
1257
 
@@ -1258,7 +1262,7 @@ listing block
1258
1262
  ----
1259
1263
  EOS
1260
1264
 
1261
- output = render_embedded_string input, :backend => 'docbook'
1265
+ output = convert_string_to_embedded input, :backend => 'docbook'
1262
1266
  assert_xpath '/screen[text()="listing block"]', output, 1
1263
1267
  end
1264
1268
 
@@ -1270,7 +1274,7 @@ listing block
1270
1274
  ----
1271
1275
  EOS
1272
1276
 
1273
- output = render_embedded_string input, :backend => 'docbook'
1277
+ output = convert_string_to_embedded input, :backend => 'docbook'
1274
1278
  assert_xpath '/formalpara', output, 1
1275
1279
  assert_xpath '/formalpara/title[text()="title"]', output, 1
1276
1280
  assert_xpath '/formalpara/para/screen[text()="listing block"]', output, 1
@@ -1284,7 +1288,7 @@ listing block
1284
1288
  ----
1285
1289
  EOS
1286
1290
 
1287
- output = render_embedded_string input, :backend => 'docbook'
1291
+ output = convert_string_to_embedded input, :backend => 'docbook'
1288
1292
  assert_xpath '/screen[text()="listing block"]', output, 1
1289
1293
  end
1290
1294
 
@@ -1297,7 +1301,7 @@ listing block
1297
1301
  ----
1298
1302
  EOS
1299
1303
 
1300
- output = render_embedded_string input, :backend => 'docbook'
1304
+ output = convert_string_to_embedded input, :backend => 'docbook'
1301
1305
  assert_xpath '/formalpara', output, 1
1302
1306
  assert_xpath '/formalpara/title[text()="title"]', output, 1
1303
1307
  assert_xpath '/formalpara/para/screen[text()="listing block"]', output, 1
@@ -1305,7 +1309,7 @@ listing block
1305
1309
  end
1306
1310
 
1307
1311
  context "Open Blocks" do
1308
- test "can render open block" do
1312
+ test "can convert open block" do
1309
1313
  input = <<-EOS
1310
1314
  --
1311
1315
  This is an open block.
@@ -1314,7 +1318,7 @@ It can span multiple lines.
1314
1318
  --
1315
1319
  EOS
1316
1320
 
1317
- output = render_string input
1321
+ output = convert_string input
1318
1322
  assert_xpath '//*[@class="openblock"]//p', output, 2
1319
1323
  end
1320
1324
 
@@ -1331,7 +1335,7 @@ ____
1331
1335
  --
1332
1336
  EOS
1333
1337
 
1334
- output = render_string input
1338
+ output = convert_string input
1335
1339
  assert_xpath '//*[@class="openblock"]//p', output, 3
1336
1340
  assert_xpath '//*[@class="openblock"]//*[@class="quoteblock"]', output, 1
1337
1341
  end
@@ -1350,7 +1354,7 @@ TIP: An open block can have other blocks inside of it.
1350
1354
  Back to our regularly scheduled programming.
1351
1355
  EOS
1352
1356
 
1353
- output = render_string input, :backend => :docbook, :keep_namespaces => true
1357
+ output = convert_string input, :backend => :docbook, :keep_namespaces => true
1354
1358
  assert_css 'article > simpara', output, 2
1355
1359
  assert_css 'article > para', output, 1
1356
1360
  assert_css 'article > para > simpara', output, 1
@@ -1371,7 +1375,7 @@ Back to our regularly scheduled programming.
1371
1375
  This is an open paragraph.
1372
1376
  EOS
1373
1377
 
1374
- output = render_string input, :backend => :docbook, :keep_namespaces => true
1378
+ output = convert_string input, :backend => :docbook, :keep_namespaces => true
1375
1379
  assert_css 'article > simpara', output, 1
1376
1380
  open = xmlnodes_at_xpath '/xmlns:article/xmlns:simpara', output, 1
1377
1381
  open = xmlnodes_at_xpath '/xmlns:article/xmlns:simpara[text()="This is an open paragraph."]', output, 1
@@ -1392,7 +1396,7 @@ This is an open block with a title.
1392
1396
  --
1393
1397
  EOS
1394
1398
 
1395
- output = render_string input, :backend => :docbook
1399
+ output = convert_string input, :backend => :docbook
1396
1400
  assert_css 'article > formalpara', output, 1
1397
1401
  assert_css 'article > formalpara > *', output, 2
1398
1402
  assert_css 'article > formalpara > title', output, 1
@@ -1407,7 +1411,7 @@ This is an open block with a title.
1407
1411
  This is an open paragraph with a title.
1408
1412
  EOS
1409
1413
 
1410
- output = render_string input, :backend => :docbook
1414
+ output = convert_string input, :backend => :docbook
1411
1415
  assert_css 'article > formalpara', output, 1
1412
1416
  assert_css 'article > formalpara > *', output, 2
1413
1417
  assert_css 'article > formalpara > title', output, 1
@@ -1425,7 +1429,7 @@ It holds stuff.
1425
1429
  --
1426
1430
  EOS
1427
1431
 
1428
- output = render_string input, :backend => :docbook
1432
+ output = convert_string input, :backend => :docbook
1429
1433
  assert_css 'article > para[role=container]', output, 1
1430
1434
  assert_css 'article > para[role=container] > simpara', output, 1
1431
1435
  end
@@ -1437,7 +1441,7 @@ This is an open block.
1437
1441
  It holds stuff.
1438
1442
  EOS
1439
1443
 
1440
- output = render_string input, :backend => :docbook
1444
+ output = convert_string input, :backend => :docbook
1441
1445
  assert_css 'article > simpara[role=container]', output, 1
1442
1446
  end
1443
1447
  end
@@ -1468,7 +1472,7 @@ image:tiger.png[]
1468
1472
  EOS
1469
1473
 
1470
1474
  expected = %(This is a '{type}' block.\nhttp://asciidoc.org\nimage:tiger.png[])
1471
- output = render_embedded_string input
1475
+ output = convert_string_to_embedded input
1472
1476
  assert_equal expected, output.strip
1473
1477
  end
1474
1478
 
@@ -1485,7 +1489,7 @@ image:tiger.png[]
1485
1489
  EOS
1486
1490
 
1487
1491
  expected = %(This is a '{type}' block.\nhttp://asciidoc.org\nimage:tiger.png[])
1488
- output = render_embedded_string input
1492
+ output = convert_string_to_embedded input
1489
1493
  assert_equal expected, output.strip
1490
1494
  end
1491
1495
 
@@ -1501,11 +1505,11 @@ http://asciidoc.org
1501
1505
  EOS
1502
1506
 
1503
1507
  expected = %(This is a <em>passthrough</em> block.\n<a href="http://asciidoc.org" class="bare">http://asciidoc.org</a>)
1504
- output = render_embedded_string input
1508
+ output = convert_string_to_embedded input
1505
1509
  assert_equal expected, output.strip
1506
1510
  end
1507
1511
 
1508
- test 'should strip leading and trailing blank lines when rendering raw block' do
1512
+ test 'should strip leading and trailing blank lines when converting raw block' do
1509
1513
  input = <<-EOS
1510
1514
  ++++
1511
1515
  line above
@@ -1543,7 +1547,7 @@ line below
1543
1547
  ++++
1544
1548
  EOS
1545
1549
 
1546
- output = render_embedded_string input
1550
+ output = convert_string_to_embedded input
1547
1551
  assert_css '.stemblock', output, 1
1548
1552
  nodes = xmlnodes_at_xpath '//*[@class="content"]/child::text()', output
1549
1553
  assert_equal '\[\sqrt{3x-1}+(1+x)^2 &lt; y\]', nodes.first.to_s.strip
@@ -1557,13 +1561,13 @@ line below
1557
1561
  ++++
1558
1562
  EOS
1559
1563
 
1560
- output = render_embedded_string input
1564
+ output = convert_string_to_embedded input
1561
1565
  assert_css '.stemblock', output, 1
1562
1566
  nodes = xmlnodes_at_xpath '//*[@class="content"]/child::text()', output
1563
1567
  assert_equal '\[\sqrt{3x-1}+(1+x)^2 &lt; y\]', nodes.first.to_s.strip
1564
1568
  end
1565
1569
 
1566
- test 'should render latexmath block in alt of equation in DocBook backend' do
1570
+ test 'should display latexmath block in alt of equation in DocBook backend' do
1567
1571
  input = <<-'EOS'
1568
1572
  [latexmath]
1569
1573
  ++++
@@ -1578,7 +1582,7 @@ line below
1578
1582
  </informalequation>
1579
1583
  EOS
1580
1584
 
1581
- output = render_embedded_string input, :backend => :docbook
1585
+ output = convert_string_to_embedded input, :backend => :docbook
1582
1586
  assert_equal expect.strip, output.strip
1583
1587
  end
1584
1588
 
@@ -1595,7 +1599,7 @@ f: x |-> x + 1
1595
1599
  f: x |-&gt; x + 1\$
1596
1600
  EOS
1597
1601
 
1598
- output = render_embedded_string input
1602
+ output = convert_string_to_embedded input
1599
1603
  assert_css '.stemblock', output, 1
1600
1604
  nodes = xmlnodes_at_xpath '//*[@class="content"]', output
1601
1605
  assert_equal expected, nodes.first.inner_html.strip
@@ -1614,7 +1618,7 @@ f: x |-> x + 1
1614
1618
  \$f: x |-&gt; x + 1\$
1615
1619
  EOS
1616
1620
 
1617
- output = render_embedded_string input
1621
+ output = convert_string_to_embedded input
1618
1622
  assert_css '.stemblock', output, 1
1619
1623
  nodes = xmlnodes_at_xpath '//*[@class="content"]', output
1620
1624
  assert_equal expected, nodes.first.inner_html.strip
@@ -1635,7 +1639,7 @@ f: x |-> x + 1
1635
1639
  \$f: x |-&gt; x + 1\$
1636
1640
  EOS
1637
1641
 
1638
- output = render_embedded_string input
1642
+ output = convert_string_to_embedded input
1639
1643
  assert_css '.stemblock', output, 1
1640
1644
  nodes = xmlnodes_at_xpath '//*[@class="content"]', output
1641
1645
  assert_equal expected, nodes.first.inner_html.strip
@@ -1658,7 +1662,7 @@ f: x |-> x + 1
1658
1662
  \$f: x |-&gt; x + 1\$
1659
1663
  EOS
1660
1664
 
1661
- output = render_embedded_string input
1665
+ output = convert_string_to_embedded input
1662
1666
  assert_css '.stemblock', output, 1
1663
1667
  nodes = xmlnodes_at_xpath '//*[@class="content"]', output
1664
1668
  assert_equal expected, nodes.first.inner_html.strip
@@ -1672,7 +1676,7 @@ sqrt(3x-1)+(1+x)^2 < y
1672
1676
  ++++
1673
1677
  EOS
1674
1678
 
1675
- output = render_embedded_string input
1679
+ output = convert_string_to_embedded input
1676
1680
  assert_css '.stemblock', output, 1
1677
1681
  nodes = xmlnodes_at_xpath '//*[@class="content"]/child::text()', output
1678
1682
  assert_equal '\$sqrt(3x-1)+(1+x)^2 &lt; y\$', nodes.first.to_s.strip
@@ -1686,7 +1690,7 @@ sqrt(3x-1)+(1+x)^2 < y
1686
1690
  ++++
1687
1691
  EOS
1688
1692
 
1689
- output = render_embedded_string input
1693
+ output = convert_string_to_embedded input
1690
1694
  assert_css '.stemblock', output, 1
1691
1695
  nodes = xmlnodes_at_xpath '//*[@class="content"]/child::text()', output
1692
1696
  assert_equal '\$sqrt(3x-1)+(1+x)^2 &lt; y\$', nodes.first.to_s.strip
@@ -1731,7 +1735,7 @@ x+b/(2a)<+-sqrt((b^2)/(4a^2)-c/a)
1731
1735
  ++++
1732
1736
  EOS
1733
1737
 
1734
- output = render_embedded_string input
1738
+ output = convert_string_to_embedded input
1735
1739
  assert_css '.stemblock', output, 1
1736
1740
  assert_css '.stemblock .title', output, 1
1737
1741
  assert_xpath '//*[@class="title"][text()="The Lorenz Equations"]', output, 1
@@ -1746,7 +1750,7 @@ a//b
1746
1750
  ++++
1747
1751
  EOS
1748
1752
 
1749
- output = render_embedded_string input
1753
+ output = convert_string_to_embedded input
1750
1754
  assert_css '.stemblock', output, 1
1751
1755
  assert_css '.stemblock .title', output, 1
1752
1756
  assert_xpath '//*[@class="title"][text()="Simple fraction"]', output, 1
@@ -1766,7 +1770,7 @@ sqrt(3x-1)+(1+x)^2 < y
1766
1770
  {'stem' => 'asciimath'},
1767
1771
  {'stem' => 'bogus'}
1768
1772
  ].each do |attributes|
1769
- output = render_embedded_string input, :attributes => attributes
1773
+ output = convert_string_to_embedded input, :attributes => attributes
1770
1774
  assert_css '.stemblock', output, 1
1771
1775
  nodes = xmlnodes_at_xpath '//*[@class="content"]/child::text()', output
1772
1776
  assert_equal '\$sqrt(3x-1)+(1+x)^2 &lt; y\$', nodes.first.to_s.strip
@@ -1786,7 +1790,7 @@ sqrt(3x-1)+(1+x)^2 < y
1786
1790
  {'stem' => 'latex'},
1787
1791
  {'stem' => 'tex'}
1788
1792
  ].each do |attributes|
1789
- output = render_embedded_string input, :attributes => attributes
1793
+ output = convert_string_to_embedded input, :attributes => attributes
1790
1794
  assert_css '.stemblock', output, 1
1791
1795
  nodes = xmlnodes_at_xpath '//*[@class="content"]/child::text()', output
1792
1796
  assert_equal '\[\sqrt{3x-1}+(1+x)^2 &lt; y\]', nodes.first.to_s.strip
@@ -1822,7 +1826,7 @@ sqrt(3x-1)+(1+x)^2 < y
1822
1826
 
1823
1827
  paragraph
1824
1828
  EOS
1825
- output = render_string input
1829
+ output = convert_string input
1826
1830
  assert_xpath '//*[@class="paragraph"]', output, 1
1827
1831
  assert_xpath '//*[@class="paragraph"]/*[@class="title"][text() = "Title"]', output, 1
1828
1832
  assert_xpath '//*[@class="paragraph"]/p[text() = "paragraph"]', output, 1
@@ -1835,7 +1839,7 @@ paragraph
1835
1839
 
1836
1840
  section paragraph
1837
1841
  EOS
1838
- output = render_string input
1842
+ output = convert_string input
1839
1843
  assert_xpath '//*[@id="header"]/*', output, 0
1840
1844
  assert_xpath '//*[@id="preamble"]/*', output, 0
1841
1845
  assert_xpath '//*[@id="content"]/h1[text()="Section Title"]', output, 1
@@ -1869,7 +1873,7 @@ Block content
1869
1873
  --
1870
1874
  EOS
1871
1875
 
1872
- output = render_embedded_string input
1876
+ output = convert_string_to_embedded input
1873
1877
  assert_includes output, 'Block content'
1874
1878
  refute_includes output, '[]'
1875
1879
  end
@@ -1882,32 +1886,32 @@ Block content
1882
1886
  --
1883
1887
  EOS
1884
1888
 
1885
- output = render_embedded_string input
1889
+ output = convert_string_to_embedded input
1886
1890
  assert_includes output, 'Block content'
1887
1891
  refute_includes output, '[[]]'
1888
1892
  end
1889
1893
  end
1890
1894
 
1891
1895
  context 'Images' do
1892
- test 'can render block image with alt text defined in macro' do
1896
+ test 'can convert block image with alt text defined in macro' do
1893
1897
  input = <<-EOS
1894
1898
  image::images/tiger.png[Tiger]
1895
1899
  EOS
1896
1900
 
1897
- output = render_embedded_string input
1901
+ output = convert_string_to_embedded input
1898
1902
  assert_xpath '/*[@class="imageblock"]//img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
1899
1903
  end
1900
1904
 
1901
- test 'renders SVG image using img element by default' do
1905
+ test 'converts SVG image using img element by default' do
1902
1906
  input = <<-EOS
1903
1907
  image::tiger.svg[Tiger]
1904
1908
  EOS
1905
1909
 
1906
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SERVER
1910
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
1907
1911
  assert_xpath '/*[@class="imageblock"]//img[@src="tiger.svg"][@alt="Tiger"]', output, 1
1908
1912
  end
1909
1913
 
1910
- test 'renders interactive SVG image with alt text using object element' do
1914
+ test 'converts interactive SVG image with alt text using object element' do
1911
1915
  input = <<-EOS
1912
1916
  :imagesdir: images
1913
1917
 
@@ -1915,17 +1919,17 @@ image::tiger.svg[Tiger]
1915
1919
  image::tiger.svg[Tiger,100]
1916
1920
  EOS
1917
1921
 
1918
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SERVER
1922
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
1919
1923
  assert_xpath '/*[@class="imageblock"]//object[@type="image/svg+xml"][@data="images/tiger.svg"][@width="100"]/span[@class="alt"][text()="Tiger"]', output, 1
1920
1924
  end
1921
1925
 
1922
- test 'renders SVG image with alt text using img element when safe mode is secure' do
1926
+ test 'converts SVG image with alt text using img element when safe mode is secure' do
1923
1927
  input = <<-EOS
1924
1928
  [%interactive]
1925
1929
  image::images/tiger.svg[Tiger,100]
1926
1930
  EOS
1927
1931
 
1928
- output = render_embedded_string input
1932
+ output = convert_string_to_embedded input
1929
1933
  assert_xpath '/*[@class="imageblock"]//img[@src="images/tiger.svg"][@alt="Tiger"]', output, 1
1930
1934
  end
1931
1935
 
@@ -1937,7 +1941,7 @@ image::images/tiger.svg[Tiger,100]
1937
1941
  image::tiger.svg[Tiger,100,fallback=tiger.png]
1938
1942
  EOS
1939
1943
 
1940
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SERVER
1944
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
1941
1945
  assert_xpath '/*[@class="imageblock"]//object[@type="image/svg+xml"][@data="images/tiger.svg"][@width="100"]/img[@src="images/tiger.png"][@width="100"]', output, 1
1942
1946
  end
1943
1947
 
@@ -1949,7 +1953,7 @@ image::tiger.svg[Tiger,100,fallback=tiger.png]
1949
1953
  image::http://example.org/tiger.svg?foo=bar[Tiger,100]
1950
1954
  EOS
1951
1955
 
1952
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SERVER
1956
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
1953
1957
  assert_xpath '/*[@class="imageblock"]//object[@type="image/svg+xml"][@data="http://example.org/tiger.svg?foo=bar"][@width="100"]/span[@class="alt"][text()="Tiger"]', output, 1
1954
1958
  end
1955
1959
 
@@ -1961,11 +1965,11 @@ image::http://example.org/tiger.svg?foo=bar[Tiger,100]
1961
1965
  image::http://example.org/tiger-svg[Tiger,100,format=svg]
1962
1966
  EOS
1963
1967
 
1964
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SERVER
1968
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
1965
1969
  assert_xpath '/*[@class="imageblock"]//object[@type="image/svg+xml"][@data="http://example.org/tiger-svg"][@width="100"]/span[@class="alt"][text()="Tiger"]', output, 1
1966
1970
  end
1967
1971
 
1968
- test 'renders inline SVG image using svg element' do
1972
+ test 'converts inline SVG image using svg element' do
1969
1973
  input = <<-EOS
1970
1974
  :imagesdir: fixtures
1971
1975
 
@@ -1973,14 +1977,14 @@ image::http://example.org/tiger-svg[Tiger,100,format=svg]
1973
1977
  image::circle.svg[Tiger,100]
1974
1978
  EOS
1975
1979
 
1976
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SERVER, :attributes => { 'docdir' => testdir }
1980
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER, :attributes => { 'docdir' => testdir }
1977
1981
  assert_match(/<svg\s[^>]*width="100px"[^>]*>/, output, 1)
1978
1982
  refute_match(/<svg\s[^>]*width="500px"[^>]*>/, output)
1979
1983
  refute_match(/<svg\s[^>]*height="500px"[^>]*>/, output)
1980
1984
  refute_match(/<svg\s[^>]*style="width:500px;height:500px"[^>]*>/, output)
1981
1985
  end
1982
1986
 
1983
- test 'renders inline SVG image using svg element even when data-uri is set' do
1987
+ test 'converts inline SVG image using svg element even when data-uri is set' do
1984
1988
  input = <<-EOS
1985
1989
  :imagesdir: fixtures
1986
1990
  :data-uri:
@@ -1989,37 +1993,53 @@ image::circle.svg[Tiger,100]
1989
1993
  image::circle.svg[Tiger,100]
1990
1994
  EOS
1991
1995
 
1992
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SERVER, :attributes => { 'docdir' => testdir }
1996
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER, :attributes => { 'docdir' => testdir }
1993
1997
  assert_match(/<svg\s[^>]*width="100px">/, output, 1)
1994
1998
  end
1995
1999
 
1996
- test 'renders alt text for inline svg element if svg cannot be read' do
2000
+ test 'embeds remote inline SVG when allow-uri-read is set' do
2001
+ input = <<-EOS
2002
+ image::http://#{resolve_localhost}:9876/fixtures/circle.svg[Circle,100,100,opts=inline]
2003
+ EOS
2004
+
2005
+ output = using_test_webserver do
2006
+ convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
2007
+ end
2008
+
2009
+ assert_css 'svg', output, 1
2010
+ assert_css 'svg[style]', output, 0
2011
+ assert_css 'svg[width="100px"]', output, 1
2012
+ assert_css 'svg[height="100px"]', output, 1
2013
+ assert_css 'svg circle', output, 1
2014
+ end
2015
+
2016
+ test 'converts alt text for inline svg element if svg cannot be read' do
1997
2017
  input = <<-EOS
1998
2018
  [%inline]
1999
2019
  image::no-such-image.svg[Alt Text]
2000
2020
  EOS
2001
2021
 
2002
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SERVER
2022
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SERVER
2003
2023
  assert_xpath '//span[@class="alt"][text()="Alt Text"]', output, 1
2004
2024
  assert_message @logger, :WARN, '~SVG does not exist or cannot be read'
2005
2025
  end
2006
2026
 
2007
- test 'can render block image with alt text defined in macro containing square bracket' do
2027
+ test 'can convert block image with alt text defined in macro containing square bracket' do
2008
2028
  input = <<-EOS
2009
2029
  image::images/tiger.png[A [Bengal] Tiger]
2010
2030
  EOS
2011
2031
 
2012
- output = render_string input
2032
+ output = convert_string input
2013
2033
  img = xmlnodes_at_xpath '//img', output, 1
2014
2034
  assert_equal 'A [Bengal] Tiger', img.attr('alt')
2015
2035
  end
2016
2036
 
2017
- test 'can render block image with target containing spaces' do
2037
+ test 'can convert block image with target containing spaces' do
2018
2038
  input = <<-EOS
2019
2039
  image::images/big tiger.png[A Big Tiger]
2020
2040
  EOS
2021
2041
 
2022
- output = render_string input
2042
+ output = convert_string input
2023
2043
  img = xmlnodes_at_xpath '//img', output, 1
2024
2044
  assert_equal 'images/big%20tiger.png', img.attr('src')
2025
2045
  assert_equal 'A Big Tiger', img.attr('alt')
@@ -2029,18 +2049,18 @@ image::images/big tiger.png[A Big Tiger]
2029
2049
  [' tiger.png', 'tiger.png '].each do |target|
2030
2050
  input = %(image::#{target}[Tiger])
2031
2051
 
2032
- output = render_embedded_string input
2052
+ output = convert_string_to_embedded input
2033
2053
  assert_xpath '//img', output, 0
2034
2054
  end
2035
2055
  end
2036
2056
 
2037
- test 'can render block image with alt text defined in block attribute above macro' do
2057
+ test 'can convert block image with alt text defined in block attribute above macro' do
2038
2058
  input = <<-EOS
2039
2059
  [Tiger]
2040
2060
  image::images/tiger.png[]
2041
2061
  EOS
2042
2062
 
2043
- output = render_embedded_string input
2063
+ output = convert_string_to_embedded input
2044
2064
  assert_xpath '/*[@class="imageblock"]//img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
2045
2065
  end
2046
2066
 
@@ -2050,7 +2070,7 @@ image::images/tiger.png[]
2050
2070
  image::images/tiger.png[Tiger]
2051
2071
  EOS
2052
2072
 
2053
- output = render_embedded_string input
2073
+ output = convert_string_to_embedded input
2054
2074
  assert_xpath '/*[@class="imageblock"]//img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
2055
2075
  end
2056
2076
 
@@ -2060,10 +2080,32 @@ image::images/tiger.png[Tiger]
2060
2080
 
2061
2081
  image::images/tiger.png[{alt-text}]
2062
2082
  EOS
2063
- output = render_embedded_string input
2083
+ output = convert_string_to_embedded input
2064
2084
  assert_xpath '/*[@class="imageblock"]//img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
2065
2085
  end
2066
2086
 
2087
+ test 'should set direction CSS class on image if float attribute is set' do
2088
+ input = <<-EOS
2089
+ [float=left]
2090
+ image::images/tiger.png[Tiger]
2091
+ EOS
2092
+
2093
+ output = convert_string_to_embedded input
2094
+ assert_css '.imageblock.left', output, 1
2095
+ assert_css '.imageblock[style]', output, 0
2096
+ end
2097
+
2098
+ test 'should set text alignment CSS class on image if align attribute is set' do
2099
+ input = <<-EOS
2100
+ [align=center]
2101
+ image::images/tiger.png[Tiger]
2102
+ EOS
2103
+
2104
+ output = convert_string_to_embedded input
2105
+ assert_css '.imageblock.text-center', output, 1
2106
+ assert_css '.imageblock[style]', output, 0
2107
+ end
2108
+
2067
2109
  test 'style attribute is dropped from image macro' do
2068
2110
  input = <<-EOS
2069
2111
  [style=value]
@@ -2079,14 +2121,14 @@ image::images/tiger.png[Tiger]
2079
2121
  test 'should apply specialcharacters and replacement substitutions to alt text' do
2080
2122
  input = 'A tiger\'s "roar" is < a bear\'s "growl"'
2081
2123
  expected = 'A tiger&#8217;s &quot;roar&quot; is &lt; a bear&#8217;s &quot;growl&quot;'
2082
- result = render_embedded_string %(image::images/tiger-roar.png[#{input}])
2124
+ result = convert_string_to_embedded %(image::images/tiger-roar.png[#{input}])
2083
2125
  assert_includes result, %(alt="#{expected}")
2084
2126
  end
2085
2127
 
2086
2128
  test 'should not encode double quotes in alt text when converting to DocBook' do
2087
2129
  input = 'Select "File > Open"'
2088
2130
  expected = 'Select "File &gt; Open"'
2089
- result = render_embedded_string %(image::images/open.png[#{input}]), :backend => :docbook
2131
+ result = convert_string_to_embedded %(image::images/open.png[#{input}]), :backend => :docbook
2090
2132
  assert_includes result, %(<phrase>#{expected}</phrase>)
2091
2133
  end
2092
2134
 
@@ -2102,21 +2144,21 @@ image::images/lions-and-tigers.png[]
2102
2144
  assert_xpath '/*[@class="imageblock"]//img[@src="images/lions-and-tigers.png"][@alt="lions and tigers"]', output, 1
2103
2145
  end
2104
2146
 
2105
- test "can render block image with alt text and height and width" do
2147
+ test "can convert block image with alt text and height and width" do
2106
2148
  input = <<-EOS
2107
2149
  image::images/tiger.png[Tiger, 200, 300]
2108
2150
  EOS
2109
2151
 
2110
- output = render_embedded_string input
2152
+ output = convert_string_to_embedded input
2111
2153
  assert_xpath '/*[@class="imageblock"]//img[@src="images/tiger.png"][@alt="Tiger"][@width="200"][@height="300"]', output, 1
2112
2154
  end
2113
2155
 
2114
- test "can render block image with link" do
2156
+ test "can convert block image with link" do
2115
2157
  input = <<-EOS
2116
2158
  image::images/tiger.png[Tiger, link='http://en.wikipedia.org/wiki/Tiger']
2117
2159
  EOS
2118
2160
 
2119
- output = render_embedded_string input
2161
+ output = convert_string_to_embedded input
2120
2162
  assert_xpath '/*[@class="imageblock"]//a[@class="image"][@href="http://en.wikipedia.org/wiki/Tiger"]/img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
2121
2163
  end
2122
2164
 
@@ -2125,7 +2167,7 @@ image::images/tiger.png[Tiger, link='http://en.wikipedia.org/wiki/Tiger']
2125
2167
  image::images/tiger.png[Tiger,link=http://en.wikipedia.org/wiki/Tiger,window=_blank]
2126
2168
  EOS
2127
2169
 
2128
- output = render_embedded_string input
2170
+ output = convert_string_to_embedded input
2129
2171
  assert_xpath '/*[@class="imageblock"]//a[@class="image"][@href="http://en.wikipedia.org/wiki/Tiger"][@target="_blank"][@rel="noopener"]/img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
2130
2172
  end
2131
2173
 
@@ -2134,7 +2176,7 @@ image::images/tiger.png[Tiger,link=http://en.wikipedia.org/wiki/Tiger,window=_bl
2134
2176
  image::images/tiger.png[Tiger,link=http://en.wikipedia.org/wiki/Tiger,window=name,opts=noopener]
2135
2177
  EOS
2136
2178
 
2137
- output = render_embedded_string input
2179
+ output = convert_string_to_embedded input
2138
2180
  assert_xpath '/*[@class="imageblock"]//a[@class="image"][@href="http://en.wikipedia.org/wiki/Tiger"][@target="name"][@rel="noopener"]/img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
2139
2181
  end
2140
2182
 
@@ -2143,25 +2185,25 @@ image::images/tiger.png[Tiger,link=http://en.wikipedia.org/wiki/Tiger,window=nam
2143
2185
  image::images/tiger.png[Tiger,link=http://en.wikipedia.org/wiki/Tiger,opts=nofollow]
2144
2186
  EOS
2145
2187
 
2146
- output = render_embedded_string input
2188
+ output = convert_string_to_embedded input
2147
2189
  assert_xpath '/*[@class="imageblock"]//a[@class="image"][@href="http://en.wikipedia.org/wiki/Tiger"][@rel="nofollow"]/img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
2148
2190
  end
2149
2191
 
2150
- test 'can render block image with caption' do
2192
+ test 'can convert block image with caption' do
2151
2193
  input = <<-EOS
2152
2194
  .The AsciiDoc Tiger
2153
2195
  image::images/tiger.png[Tiger]
2154
2196
  EOS
2155
2197
 
2156
2198
  doc = document_from_string input
2157
- assert_equal 1, doc.blocks[0].number
2199
+ assert_equal 1, doc.blocks[0].numeral
2158
2200
  output = doc.convert
2159
2201
  assert_xpath '//*[@class="imageblock"]//img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
2160
2202
  assert_xpath '//*[@class="imageblock"]/*[@class="title"][text() = "Figure 1. The AsciiDoc Tiger"]', output, 1
2161
2203
  assert_equal 1, doc.attributes['figure-number']
2162
2204
  end
2163
2205
 
2164
- test 'can render block image with explicit caption' do
2206
+ test 'can convert block image with explicit caption' do
2165
2207
  input = <<-EOS
2166
2208
  [caption="Voila! "]
2167
2209
  .The AsciiDoc Tiger
@@ -2169,7 +2211,7 @@ image::images/tiger.png[Tiger]
2169
2211
  EOS
2170
2212
 
2171
2213
  doc = document_from_string input
2172
- assert_nil doc.blocks[0].number
2214
+ assert_nil doc.blocks[0].numeral
2173
2215
  output = doc.convert
2174
2216
  assert_xpath '//*[@class="imageblock"]//img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
2175
2217
  assert_xpath '//*[@class="imageblock"]/*[@class="title"][text() = "Voila! The AsciiDoc Tiger"]', output, 1
@@ -2181,7 +2223,7 @@ image::images/tiger.png[Tiger]
2181
2223
  image::images/sunset.jpg[Sunset,align=right]
2182
2224
  EOS
2183
2225
 
2184
- output = render_embedded_string input, :backend => :docbook
2226
+ output = convert_string_to_embedded input, :backend => :docbook
2185
2227
  assert_xpath '//imagedata', output, 1
2186
2228
  assert_xpath '//imagedata[@align="right"]', output, 1
2187
2229
  end
@@ -2191,7 +2233,7 @@ image::images/sunset.jpg[Sunset,align=right]
2191
2233
  image::images/sunset.jpg[Sunset,500,332]
2192
2234
  EOS
2193
2235
 
2194
- output = render_embedded_string input, :backend => :docbook
2236
+ output = convert_string_to_embedded input, :backend => :docbook
2195
2237
  assert_xpath '//imagedata', output, 1
2196
2238
  assert_xpath '//imagedata[@contentwidth="500"]', output, 1
2197
2239
  assert_xpath '//imagedata[@contentdepth="332"]', output, 1
@@ -2204,7 +2246,7 @@ image::images/sunset.jpg[Sunset,500,332]
2204
2246
  image::images/sunset.jpg[Sunset,500,332,scale=200]
2205
2247
  EOS
2206
2248
 
2207
- output = render_embedded_string input, :backend => :docbook
2249
+ output = convert_string_to_embedded input, :backend => :docbook
2208
2250
  assert_xpath '//imagedata', output, 1
2209
2251
  assert_xpath '//imagedata[@scale="200"]', output, 1
2210
2252
  assert_xpath '//imagedata[@width]', output, 0
@@ -2218,7 +2260,7 @@ image::images/sunset.jpg[Sunset,500,332,scale=200]
2218
2260
  image::images/sunset.jpg[Sunset,500,332,scaledwidth=25%]
2219
2261
  EOS
2220
2262
 
2221
- output = render_embedded_string input, :backend => :docbook
2263
+ output = convert_string_to_embedded input, :backend => :docbook
2222
2264
  assert_xpath '//imagedata', output, 1
2223
2265
  assert_xpath '//imagedata[@width="25%"]', output, 1
2224
2266
  assert_xpath '//imagedata[@depth]', output, 0
@@ -2231,7 +2273,7 @@ image::images/sunset.jpg[Sunset,500,332,scaledwidth=25%]
2231
2273
  image::images/sunset.jpg[Sunset,scaledwidth=25]
2232
2274
  EOS
2233
2275
 
2234
- output = render_embedded_string input, :backend => :docbook
2276
+ output = convert_string_to_embedded input, :backend => :docbook
2235
2277
  assert_xpath '//imagedata', output, 1
2236
2278
  assert_xpath '//imagedata[@width="25%"]', output, 1
2237
2279
  end
@@ -2243,7 +2285,7 @@ image::images/sunset.jpg[Sunset,scaledwidth=25]
2243
2285
  image::{bogus}[]
2244
2286
  EOS
2245
2287
 
2246
- output = render_embedded_string input
2288
+ output = convert_string_to_embedded input
2247
2289
  assert_includes output, 'image::{bogus}[]'
2248
2290
  assert_message @logger, :WARN, 'dropping line containing reference to missing attribute: bogus'
2249
2291
  end
@@ -2255,7 +2297,7 @@ image::{bogus}[]
2255
2297
  image::{bogus}[]
2256
2298
  EOS
2257
2299
 
2258
- output = render_embedded_string input
2300
+ output = convert_string_to_embedded input
2259
2301
  assert_empty output.strip
2260
2302
  assert_message @logger, :WARN, 'dropping line containing reference to missing attribute: bogus'
2261
2303
  end
@@ -2267,7 +2309,7 @@ image::{bogus}[]
2267
2309
  image::{bogus}[]
2268
2310
  EOS
2269
2311
 
2270
- output = render_embedded_string input
2312
+ output = convert_string_to_embedded input
2271
2313
  assert_empty output.strip
2272
2314
  assert_message @logger, :WARN, 'dropping line containing reference to missing attribute: bogus'
2273
2315
  end
@@ -2281,7 +2323,7 @@ image::{bogus}[]
2281
2323
  == Section Title
2282
2324
  EOS
2283
2325
 
2284
- output = render_embedded_string input
2326
+ output = convert_string_to_embedded input
2285
2327
  assert_css 'img', output, 0
2286
2328
  assert_css 'h2', output, 1
2287
2329
  refute_includes output, '== Section Title'
@@ -2295,7 +2337,7 @@ image::{bogus}[]
2295
2337
  image::http://asciidoc.org/images/tiger.png[Tiger]
2296
2338
  EOS
2297
2339
 
2298
- output = render_embedded_string input
2340
+ output = convert_string_to_embedded input
2299
2341
  assert_xpath '/*[@class="imageblock"]//img[@src="http://asciidoc.org/images/tiger.png"][@alt="Tiger"]', output, 1
2300
2342
  end
2301
2343
 
@@ -2304,7 +2346,7 @@ image::http://asciidoc.org/images/tiger.png[Tiger]
2304
2346
  image::http://example.org/svg?digraph=digraph G { a -> b; }[diagram]
2305
2347
  EOS
2306
2348
 
2307
- output = render_embedded_string input
2349
+ output = convert_string_to_embedded input
2308
2350
  assert_xpath %(/*[@class="imageblock"]//img[@src="http://example.org/svg?digraph=digraph%20G%20{%20a%20-#{decode_char 62}%20b;%20}"]), output, 1
2309
2351
  end
2310
2352
 
@@ -2315,7 +2357,7 @@ image::http://example.org/svg?digraph=digraph G { a -> b; }[diagram]
2315
2357
  image::tiger.png[Tiger]
2316
2358
  EOS
2317
2359
 
2318
- output = render_embedded_string input
2360
+ output = convert_string_to_embedded input
2319
2361
  assert_xpath '/*[@class="imageblock"]//img[@src="images/tiger.png"][@alt="Tiger"]', output, 1
2320
2362
  end
2321
2363
 
@@ -2356,7 +2398,7 @@ image::http://#{resolve_localhost}:9876/fixtures/dot.gif[Dot]
2356
2398
  EOS
2357
2399
 
2358
2400
  output = using_test_webserver do
2359
- render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
2401
+ convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
2360
2402
  end
2361
2403
 
2362
2404
  assert_xpath '//img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Dot"]', output, 1
@@ -2371,7 +2413,7 @@ image::dot.gif[Dot]
2371
2413
  EOS
2372
2414
 
2373
2415
  output = using_test_webserver do
2374
- render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
2416
+ convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
2375
2417
  end
2376
2418
 
2377
2419
  assert_xpath '//img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Dot"]', output, 1
@@ -2386,7 +2428,7 @@ image::#{image_uri}[Missing image]
2386
2428
  EOS
2387
2429
 
2388
2430
  output = using_test_webserver do
2389
- render_embedded_string input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
2431
+ convert_string_to_embedded input, :safe => :safe, :attributes => {'allow-uri-read' => ''}
2390
2432
  end
2391
2433
 
2392
2434
  assert_xpath %(/*[@class="imageblock"]//img[@src="#{image_uri}"][@alt="Missing image"]), output, 1
@@ -2402,7 +2444,7 @@ image::#{image_uri}[Dot]
2402
2444
  EOS
2403
2445
 
2404
2446
  output = using_test_webserver do
2405
- render_embedded_string input, :safe => :safe
2447
+ convert_string_to_embedded input, :safe => :safe
2406
2448
  end
2407
2449
 
2408
2450
  assert_xpath %(/*[@class="imageblock"]//img[@src="#{image_uri}"][@alt="Dot"]), output, 1
@@ -2413,7 +2455,7 @@ image::#{image_uri}[Dot]
2413
2455
  image::data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=[Dot]
2414
2456
  EOS
2415
2457
 
2416
- output = render_embedded_string input
2458
+ output = convert_string_to_embedded input
2417
2459
  assert_xpath '//img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Dot"]', output, 1
2418
2460
  end
2419
2461
 
@@ -2424,7 +2466,7 @@ image::data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=[Do
2424
2466
  image::data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=[Dot]
2425
2467
  EOS
2426
2468
 
2427
- output = render_embedded_string input
2469
+ output = convert_string_to_embedded input
2428
2470
  assert_xpath '//img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Dot"]', output, 1
2429
2471
  end
2430
2472
 
@@ -2464,22 +2506,22 @@ image::../..//fixtures/./../../fixtures/dot.gif[Dot]
2464
2506
  end
2465
2507
 
2466
2508
  context 'Media' do
2467
- test 'should detect and render video macro' do
2509
+ test 'should detect and convert video macro' do
2468
2510
  input = <<-EOS
2469
2511
  video::cats-vs-dogs.avi[]
2470
2512
  EOS
2471
2513
 
2472
- output = render_embedded_string input
2514
+ output = convert_string_to_embedded input
2473
2515
  assert_css 'video', output, 1
2474
2516
  assert_css 'video[src="cats-vs-dogs.avi"]', output, 1
2475
2517
  end
2476
2518
 
2477
- test 'should detect and render video macro with positional attributes for poster and dimensions' do
2519
+ test 'should detect and convert video macro with positional attributes for poster and dimensions' do
2478
2520
  input = <<-EOS
2479
2521
  video::cats-vs-dogs.avi[cats-and-dogs.png, 200, 300]
2480
2522
  EOS
2481
2523
 
2482
- output = render_embedded_string input
2524
+ output = convert_string_to_embedded input
2483
2525
  assert_css 'video', output, 1
2484
2526
  assert_css 'video[src="cats-vs-dogs.avi"]', output, 1
2485
2527
  assert_css 'video[poster="cats-and-dogs.png"]', output, 1
@@ -2487,12 +2529,34 @@ video::cats-vs-dogs.avi[cats-and-dogs.png, 200, 300]
2487
2529
  assert_css 'video[height="300"]', output, 1
2488
2530
  end
2489
2531
 
2532
+ test 'should set direction CSS class on video block if float attribute is set' do
2533
+ input = <<-EOS
2534
+ video::cats-vs-dogs.avi[cats-and-dogs.png,float=right]
2535
+ EOS
2536
+
2537
+ output = convert_string_to_embedded input
2538
+ assert_css 'video', output, 1
2539
+ assert_css 'video[src="cats-vs-dogs.avi"]', output, 1
2540
+ assert_css '.videoblock.right', output, 1
2541
+ end
2542
+
2543
+ test 'should set text alignment CSS class on video block if align attribute is set' do
2544
+ input = <<-EOS
2545
+ video::cats-vs-dogs.avi[cats-and-dogs.png,align=center]
2546
+ EOS
2547
+
2548
+ output = convert_string_to_embedded input
2549
+ assert_css 'video', output, 1
2550
+ assert_css 'video[src="cats-vs-dogs.avi"]', output, 1
2551
+ assert_css '.videoblock.text-center', output, 1
2552
+ end
2553
+
2490
2554
  test 'video macro should honor all options' do
2491
2555
  input = <<-EOS
2492
2556
  video::cats-vs-dogs.avi[options="autoplay,nocontrols,loop",preload="metadata"]
2493
2557
  EOS
2494
2558
 
2495
- output = render_embedded_string input
2559
+ output = convert_string_to_embedded input
2496
2560
  assert_css 'video', output, 1
2497
2561
  assert_css 'video[autoplay]', output, 1
2498
2562
  assert_css 'video:not([controls])', output, 1
@@ -2505,7 +2569,7 @@ video::cats-vs-dogs.avi[options="autoplay,nocontrols,loop",preload="metadata"]
2505
2569
  video::cats-vs-dogs.avi[start="30"]
2506
2570
  EOS
2507
2571
 
2508
- output = render_embedded_string input
2572
+ output = convert_string_to_embedded input
2509
2573
  assert_css 'video', output, 1
2510
2574
  assert_xpath '//video[@src="cats-vs-dogs.avi#t=30"]', output, 1
2511
2575
  end
@@ -2515,7 +2579,7 @@ video::cats-vs-dogs.avi[start="30"]
2515
2579
  video::cats-vs-dogs.avi[end="30"]
2516
2580
  EOS
2517
2581
 
2518
- output = render_embedded_string input
2582
+ output = convert_string_to_embedded input
2519
2583
  assert_css 'video', output, 1
2520
2584
  assert_xpath '//video[@src="cats-vs-dogs.avi#t=,30"]', output, 1
2521
2585
  end
@@ -2525,7 +2589,7 @@ video::cats-vs-dogs.avi[end="30"]
2525
2589
  video::cats-vs-dogs.avi[start="30",end="60"]
2526
2590
  EOS
2527
2591
 
2528
- output = render_embedded_string input
2592
+ output = convert_string_to_embedded input
2529
2593
  assert_css 'video', output, 1
2530
2594
  assert_xpath '//video[@src="cats-vs-dogs.avi#t=30,60"]', output, 1
2531
2595
  end
@@ -2537,7 +2601,7 @@ video::cats-vs-dogs.avi[start="30",end="60"]
2537
2601
  video::cats-vs-dogs.avi[cats-and-dogs.png, 200, 300]
2538
2602
  EOS
2539
2603
 
2540
- output = render_embedded_string input
2604
+ output = convert_string_to_embedded input
2541
2605
  assert_css 'video', output, 1
2542
2606
  assert_css 'video[src="assets/cats-vs-dogs.avi"]', output, 1
2543
2607
  assert_css 'video[poster="assets/cats-and-dogs.png"]', output, 1
@@ -2552,7 +2616,7 @@ video::cats-vs-dogs.avi[cats-and-dogs.png, 200, 300]
2552
2616
  video::http://example.org/videos/cats-vs-dogs.avi[]
2553
2617
  EOS
2554
2618
 
2555
- output = render_embedded_string input
2619
+ output = convert_string_to_embedded input
2556
2620
  assert_css 'video', output, 1
2557
2621
  assert_css 'video[src="http://example.org/videos/cats-vs-dogs.avi"]', output, 1
2558
2622
  end
@@ -2561,7 +2625,7 @@ video::http://example.org/videos/cats-vs-dogs.avi[]
2561
2625
  input = <<-EOS
2562
2626
  video::67480300[vimeo, 400, 300, start=60, options=autoplay]
2563
2627
  EOS
2564
- output = render_embedded_string input
2628
+ output = convert_string_to_embedded input
2565
2629
  assert_css 'video', output, 0
2566
2630
  assert_css 'iframe', output, 1
2567
2631
  assert_css 'iframe[src="https://player.vimeo.com/video/67480300#at=60?autoplay=1"]', output, 1
@@ -2573,7 +2637,7 @@ video::67480300[vimeo, 400, 300, start=60, options=autoplay]
2573
2637
  input = <<-EOS
2574
2638
  video::U8GBXvdmHT4/PLg7s6cbtAD15Das5LK9mXt_g59DLWxKUe[youtube, 640, 360, start=60, options="autoplay,modest", theme=light]
2575
2639
  EOS
2576
- output = render_embedded_string input
2640
+ output = convert_string_to_embedded input
2577
2641
  assert_css 'video', output, 0
2578
2642
  assert_css 'iframe', output, 1
2579
2643
  assert_css 'iframe[src="https://www.youtube.com/embed/U8GBXvdmHT4?rel=0&start=60&autoplay=1&list=PLg7s6cbtAD15Das5LK9mXt_g59DLWxKUe&modestbranding=1&theme=light"]', output, 1
@@ -2585,7 +2649,7 @@ video::U8GBXvdmHT4/PLg7s6cbtAD15Das5LK9mXt_g59DLWxKUe[youtube, 640, 360, start=6
2585
2649
  input = <<-EOS
2586
2650
  video::SCZF6I-Rc4I,AsKGOeonbIs,HwrPhOp6-aM[youtube, 640, 360, start=60, options=autoplay]
2587
2651
  EOS
2588
- output = render_embedded_string input
2652
+ output = convert_string_to_embedded input
2589
2653
  assert_css 'video', output, 0
2590
2654
  assert_css 'iframe', output, 1
2591
2655
  assert_css 'iframe[src="https://www.youtube.com/embed/SCZF6I-Rc4I?rel=0&start=60&autoplay=1&playlist=AsKGOeonbIs,HwrPhOp6-aM"]', output, 1
@@ -2593,12 +2657,12 @@ video::SCZF6I-Rc4I,AsKGOeonbIs,HwrPhOp6-aM[youtube, 640, 360, start=60, options=
2593
2657
  assert_css 'iframe[height="360"]', output, 1
2594
2658
  end
2595
2659
 
2596
- test 'should detect and render audio macro' do
2660
+ test 'should detect and convert audio macro' do
2597
2661
  input = <<-EOS
2598
2662
  audio::podcast.mp3[]
2599
2663
  EOS
2600
2664
 
2601
- output = render_embedded_string input
2665
+ output = convert_string_to_embedded input
2602
2666
  assert_css 'audio', output, 1
2603
2667
  assert_css 'audio[src="podcast.mp3"]', output, 1
2604
2668
  end
@@ -2610,7 +2674,7 @@ audio::podcast.mp3[]
2610
2674
  audio::podcast.mp3[]
2611
2675
  EOS
2612
2676
 
2613
- output = render_embedded_string input
2677
+ output = convert_string_to_embedded input
2614
2678
  assert_css 'audio', output, 1
2615
2679
  assert_css 'audio[src="assets/podcast.mp3"]', output, 1
2616
2680
  end
@@ -2622,7 +2686,7 @@ audio::podcast.mp3[]
2622
2686
  video::http://example.org/podcast.mp3[]
2623
2687
  EOS
2624
2688
 
2625
- output = render_embedded_string input
2689
+ output = convert_string_to_embedded input
2626
2690
  assert_css 'video', output, 1
2627
2691
  assert_css 'video[src="http://example.org/podcast.mp3"]', output, 1
2628
2692
  end
@@ -2632,7 +2696,7 @@ video::http://example.org/podcast.mp3[]
2632
2696
  audio::podcast.mp3[options="autoplay,nocontrols,loop"]
2633
2697
  EOS
2634
2698
 
2635
- output = render_embedded_string input
2699
+ output = convert_string_to_embedded input
2636
2700
  assert_css 'audio', output, 1
2637
2701
  assert_css 'audio[autoplay]', output, 1
2638
2702
  assert_css 'audio:not([controls])', output, 1
@@ -2644,7 +2708,7 @@ audio::podcast.mp3[options="autoplay,nocontrols,loop"]
2644
2708
  audio::podcast.mp3[start=1,end=2]
2645
2709
  EOS
2646
2710
 
2647
- output = render_embedded_string input
2711
+ output = convert_string_to_embedded input
2648
2712
  assert_css 'audio', output, 1
2649
2713
  assert_css 'audio[controls]', output, 1
2650
2714
  assert_css 'audio[src="podcast.mp3#t=1,2"]', output, 1
@@ -2660,7 +2724,7 @@ audio::podcast.mp3[start=1,end=2]
2660
2724
  You can use icons for admonitions by setting the 'icons' attribute.
2661
2725
  EOS
2662
2726
 
2663
- output = render_string input, :safe => Asciidoctor::SafeMode::SERVER
2727
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SERVER
2664
2728
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="./images/icons/tip.png"][@alt="Tip"]', output, 1
2665
2729
  end
2666
2730
 
@@ -2673,7 +2737,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
2673
2737
  You can use icons for admonitions by setting the 'icons' attribute.
2674
2738
  EOS
2675
2739
 
2676
- output = render_string input, :safe => Asciidoctor::SafeMode::SERVER
2740
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SERVER
2677
2741
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="icons/tip.png"][@alt="Tip"]', output, 1
2678
2742
  end
2679
2743
 
@@ -2686,7 +2750,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
2686
2750
  Override the icon of an admonition block using an attribute
2687
2751
  EOS
2688
2752
 
2689
- output = render_string input, :safe => Asciidoctor::SafeMode::SERVER
2753
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SERVER
2690
2754
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="images/icons/a.png"]', output, 1
2691
2755
  end
2692
2756
 
@@ -2701,7 +2765,7 @@ Override the icon of an admonition block using an attribute
2701
2765
  You can use icons for admonitions by setting the 'icons' attribute.
2702
2766
  EOS
2703
2767
 
2704
- output = render_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'docdir' => testdir }
2768
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'docdir' => testdir }
2705
2769
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Tip"]', output, 1
2706
2770
  end
2707
2771
 
@@ -2716,7 +2780,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
2716
2780
  You can set a custom icon using the icon attribute on the block.
2717
2781
  EOS
2718
2782
 
2719
- output = render_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'docdir' => testdir }
2783
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'docdir' => testdir }
2720
2784
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Tip"]', output, 1
2721
2785
  end
2722
2786
 
@@ -2731,7 +2795,7 @@ You can set a custom icon using the icon attribute on the block.
2731
2795
  You can use icons for admonitions by setting the 'icons' attribute.
2732
2796
  EOS
2733
2797
 
2734
- output = render_string input, :attributes => {'icons' => ''}
2798
+ output = convert_string input, :attributes => {'icons' => ''}
2735
2799
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="fixtures/tip.gif"][@alt="Tip"]', output, 1
2736
2800
  end
2737
2801
 
@@ -2746,7 +2810,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
2746
2810
  You can use icons for admonitions by setting the 'icons' attribute.
2747
2811
  EOS
2748
2812
 
2749
- output = render_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'docdir' => testdir }
2813
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'docdir' => testdir }
2750
2814
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="][@alt="Tip"]', output, 1
2751
2815
  assert_message @logger, :WARN, 'image has illegal reference to ancestor of jail; recovering automatically'
2752
2816
  end
@@ -2759,7 +2823,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
2759
2823
  You can use icons for admonitions by setting the 'icons' attribute.
2760
2824
  EOS
2761
2825
 
2762
- output = render_string input, :safe => Asciidoctor::SafeMode::SERVER
2826
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SERVER
2763
2827
  assert_css %(html > head > link[rel="stylesheet"][href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/#{Asciidoctor::FONT_AWESOME_VERSION}/css/font-awesome.min.css"]), output, 1
2764
2828
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/i[@class="fa icon-tip"]', output, 1
2765
2829
  end
@@ -2773,7 +2837,7 @@ You can use icons for admonitions by setting the 'icons' attribute.
2773
2837
  Override the icon of an admonition block using an attribute
2774
2838
  EOS
2775
2839
 
2776
- output = render_string input, :safe => Asciidoctor::SafeMode::SERVER
2840
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SERVER
2777
2841
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/i[@class="fa icon-tip"]', output, 0
2778
2842
  assert_xpath '//*[@class="admonitionblock tip"]//*[@class="icon"]/img[@src="images/icons/a.png"]', output, 1
2779
2843
  end
@@ -2790,9 +2854,9 @@ TIP: You can control the URI scheme used for assets with the asset-uri-scheme at
2790
2854
  puts "AsciiDoc, FTW!"
2791
2855
  EOS
2792
2856
 
2793
- output = render_string input, :safe => Asciidoctor::SafeMode::SAFE
2857
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE
2794
2858
  assert_css %(html > head > link[rel="stylesheet"][href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/#{Asciidoctor::FONT_AWESOME_VERSION}/css/font-awesome.min.css"]), output, 1
2795
- assert_css 'html > body > script[src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"]', output, 1
2859
+ assert_css 'html > body > script[src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"]', output, 1
2796
2860
  end
2797
2861
 
2798
2862
  test 'should use no uri scheme for assets when asset-uri-scheme is blank' do
@@ -2807,9 +2871,9 @@ TIP: You can control the URI scheme used for assets with the asset-uri-scheme at
2807
2871
  puts "AsciiDoc, FTW!"
2808
2872
  EOS
2809
2873
 
2810
- output = render_string input, :safe => Asciidoctor::SafeMode::SAFE
2874
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE
2811
2875
  assert_css %(html > head > link[rel="stylesheet"][href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/#{Asciidoctor::FONT_AWESOME_VERSION}/css/font-awesome.min.css"]), output, 1
2812
- assert_css 'html > body > script[src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"]', output, 1
2876
+ assert_css 'html > body > script[src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.13.1/highlight.min.js"]', output, 1
2813
2877
  end
2814
2878
  end
2815
2879
 
@@ -2853,7 +2917,7 @@ puts "Hello, World!"
2853
2917
  ```
2854
2918
  EOS
2855
2919
 
2856
- output = render_embedded_string input
2920
+ output = convert_string_to_embedded input
2857
2921
  assert_css '.listingblock', output, 1
2858
2922
  assert_css '.listingblock pre code', output, 1
2859
2923
  assert_css '.listingblock pre code:not([class])', output, 1
@@ -2870,7 +2934,7 @@ alert("Hello, World!")
2870
2934
  ~~~~
2871
2935
  EOS
2872
2936
 
2873
- output = render_embedded_string input
2937
+ output = convert_string_to_embedded input
2874
2938
  assert_css '.listingblock', output, 0
2875
2939
  end
2876
2940
 
@@ -2885,7 +2949,7 @@ alert("Hello, World!")
2885
2949
  ```
2886
2950
  EOS
2887
2951
 
2888
- output = render_embedded_string input
2952
+ output = convert_string_to_embedded input
2889
2953
  assert_css '.listingblock', output, 2
2890
2954
  assert_css '.listingblock pre code.language-ruby[data-lang=ruby]', output, 1
2891
2955
  assert_css '.listingblock pre code.language-javascript[data-lang=javascript]', output, 1
@@ -2902,7 +2966,7 @@ alert("Hello, World!")
2902
2966
  ```
2903
2967
  EOS
2904
2968
 
2905
- output = render_embedded_string input
2969
+ output = convert_string_to_embedded input
2906
2970
  assert_css '.listingblock', output, 2
2907
2971
  assert_css '.listingblock pre code.language-ruby[data-lang=ruby]', output, 1
2908
2972
  assert_css '.listingblock pre code.language-javascript[data-lang=javascript]', output, 1
@@ -2919,7 +2983,7 @@ require 'coderay'
2919
2983
  html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
2920
2984
  ----
2921
2985
  EOS
2922
- output = render_string input, :safe => Asciidoctor::SafeMode::SAFE, :linkcss_default => true
2986
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :linkcss_default => true
2923
2987
  assert_xpath '//pre[@class="CodeRay highlight"]/code[@data-lang="ruby"]//span[@class = "constant"][text() = "CodeRay"]', output, 1
2924
2988
  assert_match(/\.CodeRay *\{/, output)
2925
2989
  end
@@ -2933,7 +2997,7 @@ html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
2933
2997
  puts 'Hello, World!'
2934
2998
  ----
2935
2999
  EOS
2936
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SAFE
3000
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
2937
3001
  assert_xpath '//td[@class="line-numbers"]', output, 1
2938
3002
  end
2939
3003
 
@@ -2946,7 +3010,7 @@ puts 'Hello, World!'
2946
3010
  puts 'Hello, World!'
2947
3011
  ----
2948
3012
  EOS
2949
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SAFE
3013
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
2950
3014
  assert_xpath '//td[@class="line-numbers"]', output, 1
2951
3015
  end
2952
3016
 
@@ -2960,10 +3024,70 @@ puts 'Hello, World!'
2960
3024
  puts 'Hello, World!'
2961
3025
  ----
2962
3026
  EOS
2963
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SAFE
3027
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
2964
3028
  assert_xpath '//td[@class="line-numbers"]', output, 1
2965
3029
  end
2966
3030
 
3031
+ test 'should set starting line number in HTML output if linenums option is enabled and start attribute is set' do
3032
+ input = <<-EOS
3033
+ :source-highlighter: coderay
3034
+ :coderay-linenums-mode: inline
3035
+
3036
+ [source%linenums,ruby,start=10]
3037
+ ----
3038
+ puts 'Hello, World!'
3039
+ ----
3040
+ EOS
3041
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
3042
+ assert_xpath '//span[@class="line-numbers"]', output, 1
3043
+ assert_xpath '//span[@class="line-numbers"][text()="10"]', output, 1
3044
+ end
3045
+
3046
+ test 'should set starting line number in DocBook output if linenums option is enabled and start attribute is set' do
3047
+ input = <<-EOS
3048
+ [source%linenums,java,start=3]
3049
+ ----
3050
+ public class HelloWorld {
3051
+ public static void main(String[] args) {
3052
+ out.println("Hello, World!");
3053
+ }
3054
+ }
3055
+ ----
3056
+ EOS
3057
+
3058
+ output = convert_string_to_embedded input, :backend => :docbook, :safe => Asciidoctor::SafeMode::SAFE
3059
+ assert_css 'programlisting[startinglinenumber]', output, 1
3060
+ assert_css 'programlisting[startinglinenumber="3"]', output, 1
3061
+ end
3062
+
3063
+ test 'should highlight lines specified in highlight attribute if linenums is set and source-highlighter is coderay' do
3064
+ %w(highlight="1,4-6" highlight=1;4..6 highlight=1;4..;!7).each do |highlight_attr|
3065
+ input = <<-EOS
3066
+ :source-highlighter: coderay
3067
+
3068
+ [source%linenums,java,#{highlight_attr}]
3069
+ ----
3070
+ import static java.lang.System.out;
3071
+
3072
+ public class HelloWorld {
3073
+ public static void main(String[] args) {
3074
+ out.println("Hello, World!");
3075
+ }
3076
+ }
3077
+ ----
3078
+ EOS
3079
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
3080
+ assert_css 'strong.highlighted', output, 4
3081
+ assert_xpath '//strong[@class="highlighted"][text()="1"]', output, 1
3082
+ assert_xpath '//strong[@class="highlighted"][text()="2"]', output, 0
3083
+ assert_xpath '//strong[@class="highlighted"][text()="3"]', output, 0
3084
+ assert_xpath '//strong[@class="highlighted"][text()="4"]', output, 1
3085
+ assert_xpath '//strong[@class="highlighted"][text()="5"]', output, 1
3086
+ assert_xpath '//strong[@class="highlighted"][text()="6"]', output, 1
3087
+ assert_xpath '//strong[@class="highlighted"][text()="7"]', output, 0
3088
+ end
3089
+ end
3090
+
2967
3091
  test 'should read source language from source-language document attribute if not specified on source block' do
2968
3092
  input = <<-EOS
2969
3093
  :source-highlighter: coderay
@@ -2976,7 +3100,7 @@ require 'coderay'
2976
3100
  html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
2977
3101
  ----
2978
3102
  EOS
2979
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SAFE, :linkcss_default => true
3103
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE, :linkcss_default => true
2980
3104
  assert_xpath '//pre[@class="CodeRay highlight"]/code[@data-lang="ruby"]//span[@class = "constant"][text() = "CodeRay"]', output, 1
2981
3105
  end
2982
3106
 
@@ -2987,7 +3111,7 @@ html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
2987
3111
  {source-language}
2988
3112
  EOS
2989
3113
 
2990
- assert_equal 'ruby', render_string(input, :doctype => :inline, :attributes => {'compat-mode' => ''})
3114
+ assert_equal 'ruby', (convert_inline_string input, :attributes => {'compat-mode' => ''})
2991
3115
 
2992
3116
  input = <<-EOS
2993
3117
  :language: ruby
@@ -2995,7 +3119,7 @@ html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
2995
3119
  {source-language}
2996
3120
  EOS
2997
3121
 
2998
- assert_equal '{source-language}', render_string(input, :doctype => :inline)
3122
+ assert_equal '{source-language}', (convert_inline_string input)
2999
3123
  end
3000
3124
 
3001
3125
  test 'should replace callout marks but not highlight them if source-highlighter attribute is coderay' do
@@ -3017,11 +3141,35 @@ exit 0 # <5><6>
3017
3141
  <5> Exit program
3018
3142
  <6> Reports success
3019
3143
  EOS
3020
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SAFE
3021
- assert_match(/<span class="content">coderay<\/span>.* <b class="conum">\(1\)<\/b>$/, output)
3022
- assert_match(/<span class="content">puts 'Hello, world!'<\/span>.* <b class="conum">\(2\)<\/b>$/, output)
3023
- assert_match(/puts html * <b class="conum">\(3\)<\/b> <b class="conum">\(4\)<\/b>$/, output)
3024
- assert_match(/exit.* <b class="conum">\(5\)<\/b> <b class="conum">\(6\)<\/b><\/code>/, output)
3144
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
3145
+ assert_match(/<span class="content">coderay<\/span>.* # <b class="conum">\(1\)<\/b>$/, output)
3146
+ assert_match(/<span class="content">puts 'Hello, world!'<\/span>.* # <b class="conum">\(2\)<\/b>$/, output)
3147
+ assert_match(/puts html.* # <b class="conum">\(3\)<\/b> <b class="conum">\(4\)<\/b>$/, output)
3148
+ assert_match(/exit.* # <b class="conum">\(5\)<\/b> <b class="conum">\(6\)<\/b><\/code>/, output)
3149
+ end
3150
+
3151
+ test 'should support autonumbered callout marks if source-highlighter attribute is coderay' do
3152
+ input = <<-EOS
3153
+ :source-highlighter: coderay
3154
+
3155
+ [source, ruby]
3156
+ ----
3157
+ require 'coderay' # <.><.>
3158
+
3159
+ html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table) # <.>
3160
+ puts html # <.>
3161
+ ----
3162
+ <.> Load library
3163
+ <.> Gem must be installed
3164
+ <.> Highlight source
3165
+ <.> Print to stdout
3166
+ EOS
3167
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
3168
+ assert_match(/<span class="content">coderay<\/span>.* # <b class="conum">\(1\)<\/b> <b class="conum">\(2\)<\/b>$/, output)
3169
+ assert_match(/<span class="content">puts 'Hello, world!'<\/span>.* # <b class="conum">\(3\)<\/b>$/, output)
3170
+ assert_match(/puts html.* # <b class="conum">\(4\)<\/b><\/code>/, output)
3171
+ assert_css '.colist ol', output, 1
3172
+ assert_css '.colist ol li', output, 4
3025
3173
  end
3026
3174
 
3027
3175
  test 'should restore callout marks to correct lines if source highlighter is coderay and table line numbering is enabled' do
@@ -3044,11 +3192,11 @@ exit 0 # <5><6>
3044
3192
  <5> Exit program
3045
3193
  <6> Reports success
3046
3194
  EOS
3047
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SAFE
3048
- assert_match(/<span class="content">coderay<\/span>.* <b class="conum">\(1\)<\/b>$/, output)
3049
- assert_match(/<span class="content">puts 'Hello, world!'<\/span>.* <b class="conum">\(2\)<\/b>$/, output)
3050
- assert_match(/puts html * <b class="conum">\(3\)<\/b> <b class="conum">\(4\)<\/b>$/, output)
3051
- assert_match(/exit.* <b class="conum">\(5\)<\/b> <b class="conum">\(6\)<\/b><\/pre>/, output)
3195
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE
3196
+ assert_match(/<span class="content">coderay<\/span>.* # <b class="conum">\(1\)<\/b>$/, output)
3197
+ assert_match(/<span class="content">puts 'Hello, world!'<\/span>.* # <b class="conum">\(2\)<\/b>$/, output)
3198
+ assert_match(/puts html.* # <b class="conum">\(3\)<\/b> <b class="conum">\(4\)<\/b>$/, output)
3199
+ assert_match(/exit.* # <b class="conum">\(5\)<\/b> <b class="conum">\(6\)<\/b><\/pre>/, output)
3052
3200
  end
3053
3201
 
3054
3202
  test 'should preserve space before callout on final line' do
@@ -3082,9 +3230,9 @@ print 'value' #<1>
3082
3230
  EOS
3083
3231
 
3084
3232
  inputs.each do |input|
3085
- output = render_embedded_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'source-highlighter' => 'coderay' }
3233
+ output = convert_string_to_embedded input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => { 'source-highlighter' => 'coderay' }
3086
3234
  output = output.gsub(/<\/?span.*?>/, '')
3087
- assert_includes output, '\'value\' <b class="conum">(1)</b>'
3235
+ assert_includes output, '\'value\' #<b class="conum">(1)</b>'
3088
3236
  end
3089
3237
  end
3090
3238
 
@@ -3102,7 +3250,7 @@ public class Printer {
3102
3250
  }
3103
3251
  ----
3104
3252
  EOS
3105
- output = render_string input, :safe => Asciidoctor::SafeMode::SAFE
3253
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE
3106
3254
  assert_match(/\.<em>out<\/em>\./, output, 1)
3107
3255
  assert_match(/\*asterisks\*/, output, 1)
3108
3256
  assert_match(/<strong>bold<\/strong>/, output, 1)
@@ -3120,7 +3268,7 @@ require 'coderay'
3120
3268
  html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
3121
3269
  ----
3122
3270
  EOS
3123
- output = render_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'linkcss' => ''}
3271
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :attributes => {'linkcss' => ''}
3124
3272
  assert_xpath '//pre[@class="CodeRay highlight"]/code[@data-lang="ruby"]//span[@class = "constant"][text() = "CodeRay"]', output, 1
3125
3273
  assert_css 'link[rel="stylesheet"][href="./coderay-asciidoctor.css"]', output, 1
3126
3274
  end
@@ -3137,7 +3285,7 @@ require 'coderay'
3137
3285
  html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
3138
3286
  ----
3139
3287
  EOS
3140
- output = render_string input, :safe => Asciidoctor::SafeMode::SAFE, :linkcss_default => true
3288
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE, :linkcss_default => true
3141
3289
  assert_xpath '//pre[@class="CodeRay highlight"]/code[@data-lang="ruby"]//span[@style = "color:#036;font-weight:bold"][text() = "CodeRay"]', output, 1
3142
3290
  refute_match(/\.CodeRay \{/, output)
3143
3291
  end
@@ -3153,7 +3301,7 @@ html = CodeRay.scan("puts 'Hello, world!'", :ruby).div(:line_numbers => :table)
3153
3301
  <script>hljs.initHighlightingOnLoad();</script>
3154
3302
  ----
3155
3303
  EOS
3156
- output = render_string input, :safe => Asciidoctor::SafeMode::SAFE
3304
+ output = convert_string input, :safe => Asciidoctor::SafeMode::SAFE
3157
3305
  assert_match(/<link .*highlight\.js/, output)
3158
3306
  assert_match(/<script .*highlight\.js/, output)
3159
3307
  assert_match(/hljs.initHighlightingOnLoad/, output)
@@ -3167,7 +3315,7 @@ puts "foo"
3167
3315
  ----
3168
3316
  EOS
3169
3317
 
3170
- output = render_embedded_string input, :attributes => {'source-highlighter' => 'prettify'}
3318
+ output = convert_string_to_embedded input, :attributes => {'source-highlighter' => 'prettify'}
3171
3319
  assert_css 'pre[class="prettyprint highlight"]', output, 1
3172
3320
  assert_css 'pre > code.language-ruby[data-lang="ruby"]', output, 1
3173
3321
  end
@@ -3186,7 +3334,7 @@ puts HTML::Pipeline.new(filters, {}).call(input)[:output]
3186
3334
  ----
3187
3335
  EOS
3188
3336
 
3189
- output = render_string input, :attributes => {'source-highlighter' => 'html-pipeline'}
3337
+ output = convert_string input, :attributes => {'source-highlighter' => 'html-pipeline'}
3190
3338
  assert_css 'pre[lang="ruby"]', output, 1
3191
3339
  assert_css 'pre[lang="ruby"] > code', output, 1
3192
3340
  assert_css 'pre[class]', output, 0
@@ -3213,7 +3361,7 @@ still inside
3213
3361
  eof
3214
3362
  EOS
3215
3363
 
3216
- output = render_embedded_string input
3364
+ output = convert_string_to_embedded input
3217
3365
  assert_xpath '/*[@class="listingblock"]', output, 1
3218
3366
  assert_message @logger, :WARN, '<stdin>: line 3: unterminated listing block', Hash
3219
3367
  end
@@ -3236,7 +3384,7 @@ And other stuff.
3236
3384
  content
3237
3385
  EOS
3238
3386
 
3239
- output = render_string input
3387
+ output = convert_string input
3240
3388
  assert_css '.quoteblock', output, 1
3241
3389
  assert_css '.quoteblock.abstract', output, 1
3242
3390
  assert_css '#preamble .quoteblock', output, 1
@@ -3259,7 +3407,7 @@ This article is about stuff.
3259
3407
  content
3260
3408
  EOS
3261
3409
 
3262
- output = render_string input
3410
+ output = convert_string input
3263
3411
  assert_css '.quoteblock', output, 1
3264
3412
  assert_css '.quoteblock.abstract', output, 1
3265
3413
  assert_css '#preamble .quoteblock', output, 1
@@ -3277,7 +3425,7 @@ content
3277
3425
  Abstract for book with title is valid
3278
3426
  EOS
3279
3427
 
3280
- output = render_string input
3428
+ output = convert_string input
3281
3429
  assert_css '.abstract', output, 1
3282
3430
  end
3283
3431
 
@@ -3289,12 +3437,12 @@ Abstract for book with title is valid
3289
3437
  Abstract for book without title is invalid.
3290
3438
  EOS
3291
3439
 
3292
- output = render_string input
3440
+ output = convert_string input
3293
3441
  assert_css '.abstract', output, 0
3294
3442
  assert_message @logger, :WARN, 'abstract block cannot be used in a document without a title when doctype is book. Excluding block content.'
3295
3443
  end
3296
3444
 
3297
- test 'should make abstract on open block without title rendered to DocBook' do
3445
+ test 'should make abstract on open block without title converted to DocBook' do
3298
3446
  input = <<-EOS
3299
3447
  = Article
3300
3448
 
@@ -3306,12 +3454,12 @@ And other stuff.
3306
3454
  --
3307
3455
  EOS
3308
3456
 
3309
- output = render_string input, :backend => 'docbook'
3457
+ output = convert_string input, :backend => 'docbook'
3310
3458
  assert_css 'abstract', output, 1
3311
3459
  assert_css 'abstract > simpara', output, 2
3312
3460
  end
3313
3461
 
3314
- test 'should make abstract on open block with title rendered to DocBook' do
3462
+ test 'should make abstract on open block with title converted to DocBook' do
3315
3463
  input = <<-EOS
3316
3464
  = Article
3317
3465
 
@@ -3322,13 +3470,13 @@ This article is about stuff.
3322
3470
  --
3323
3471
  EOS
3324
3472
 
3325
- output = render_string input, :backend => 'docbook'
3473
+ output = convert_string input, :backend => 'docbook'
3326
3474
  assert_css 'abstract', output, 1
3327
3475
  assert_css 'abstract > title', output, 1
3328
3476
  assert_css 'abstract > title + simpara', output, 1
3329
3477
  end
3330
3478
 
3331
- test 'should allow abstract in document with title if doctype is book rendered to DocBook' do
3479
+ test 'should allow abstract in document with title if doctype is book converted to DocBook' do
3332
3480
  input = <<-EOS
3333
3481
  = Book
3334
3482
  :doctype: book
@@ -3337,11 +3485,11 @@ This article is about stuff.
3337
3485
  Abstract for book with title is valid
3338
3486
  EOS
3339
3487
 
3340
- output = render_string input, :backend => 'docbook'
3488
+ output = convert_string input, :backend => 'docbook'
3341
3489
  assert_css 'abstract', output, 1
3342
3490
  end
3343
3491
 
3344
- test 'should not allow abstract as direct child of document if doctype is book rendered to DocBook' do
3492
+ test 'should not allow abstract as direct child of document if doctype is book converted to DocBook' do
3345
3493
  input = <<-EOS
3346
3494
  :doctype: book
3347
3495
 
@@ -3349,7 +3497,7 @@ Abstract for book with title is valid
3349
3497
  Abstract for book is invalid.
3350
3498
  EOS
3351
3499
 
3352
- output = render_string input, :backend => 'docbook'
3500
+ output = convert_string input, :backend => 'docbook'
3353
3501
  assert_css 'abstract', output, 0
3354
3502
  assert_message @logger, :WARN, 'abstract block cannot be used in a document without a title when doctype is book. Excluding block content.'
3355
3503
  end
@@ -3374,7 +3522,7 @@ It can have multiple paragraphs.
3374
3522
  content
3375
3523
  EOS
3376
3524
 
3377
- output = render_string input
3525
+ output = convert_string input
3378
3526
  assert_css '.openblock', output, 1
3379
3527
  assert_css '.openblock.partintro', output, 1
3380
3528
  assert_css '.openblock .title', output, 0
@@ -3401,7 +3549,7 @@ This is a part intro with a title.
3401
3549
  content
3402
3550
  EOS
3403
3551
 
3404
- output = render_string input
3552
+ output = convert_string input
3405
3553
  assert_css '.openblock', output, 1
3406
3554
  assert_css '.openblock.partintro', output, 1
3407
3555
  assert_css '.openblock .title', output, 1
@@ -3420,7 +3568,7 @@ content
3420
3568
  part intro paragraph
3421
3569
  EOS
3422
3570
 
3423
- output = render_string input
3571
+ output = convert_string input
3424
3572
  assert_css '.partintro', output, 0
3425
3573
  assert_message @logger, :ERROR, 'partintro block can only be used when doctype is book and must be a child of a book part. Excluding block content.'
3426
3574
  end
@@ -3431,12 +3579,12 @@ part intro paragraph
3431
3579
  part intro paragraph
3432
3580
  EOS
3433
3581
 
3434
- output = render_string input
3582
+ output = convert_string input
3435
3583
  assert_css '.partintro', output, 0
3436
3584
  assert_message @logger, :ERROR, 'partintro block can only be used when doctype is book and must be a child of a book part. Excluding block content.'
3437
3585
  end
3438
3586
 
3439
- test 'should accept partintro on open block without title rendered to DocBook' do
3587
+ test 'should accept partintro on open block without title converted to DocBook' do
3440
3588
  input = <<-EOS
3441
3589
  = Book
3442
3590
  :doctype: book
@@ -3455,13 +3603,13 @@ It can have multiple paragraphs.
3455
3603
  content
3456
3604
  EOS
3457
3605
 
3458
- output = render_string input, :backend => 'docbook45'
3606
+ output = convert_string input, :backend => 'docbook45'
3459
3607
  assert_css 'partintro', output, 1
3460
3608
  assert_css 'part#_part_1 > partintro', output, 1
3461
3609
  assert_css 'partintro > simpara', output, 2
3462
3610
  end
3463
3611
 
3464
- test 'should accept partintro on open block with title rendered to DocBook' do
3612
+ test 'should accept partintro on open block with title converted to DocBook' do
3465
3613
  input = <<-EOS
3466
3614
  = Book
3467
3615
  :doctype: book
@@ -3479,14 +3627,14 @@ This is a part intro with a title.
3479
3627
  content
3480
3628
  EOS
3481
3629
 
3482
- output = render_string input, :backend => 'docbook45'
3630
+ output = convert_string input, :backend => 'docbook45'
3483
3631
  assert_css 'partintro', output, 1
3484
3632
  assert_css 'part#_part_1 > partintro', output, 1
3485
3633
  assert_css 'partintro > title', output, 1
3486
3634
  assert_css 'partintro > title + simpara', output, 1
3487
3635
  end
3488
3636
 
3489
- test 'should exclude partintro if not a child of part rendered to DocBook' do
3637
+ test 'should exclude partintro if not a child of part converted to DocBook' do
3490
3638
  input = <<-EOS
3491
3639
  = Book
3492
3640
  :doctype: book
@@ -3495,18 +3643,18 @@ content
3495
3643
  part intro paragraph
3496
3644
  EOS
3497
3645
 
3498
- output = render_string input, :backend => 'docbook'
3646
+ output = convert_string input, :backend => 'docbook'
3499
3647
  assert_css 'partintro', output, 0
3500
3648
  assert_message @logger, :ERROR, 'partintro block can only be used when doctype is book and must be a child of a book part. Excluding block content.'
3501
3649
  end
3502
3650
 
3503
- test 'should not allow partintro unless doctype is book rendered to DocBook' do
3651
+ test 'should not allow partintro unless doctype is book converted to DocBook' do
3504
3652
  input = <<-EOS
3505
3653
  [partintro]
3506
3654
  part intro paragraph
3507
3655
  EOS
3508
3656
 
3509
- output = render_string input, :backend => 'docbook'
3657
+ output = convert_string input, :backend => 'docbook'
3510
3658
  assert_css 'partintro', output, 0
3511
3659
  assert_message @logger, :ERROR, 'partintro block can only be used when doctype is book and must be a child of a book part. Excluding block content.'
3512
3660
  end
@@ -3622,7 +3770,7 @@ see how they run
3622
3770
  --
3623
3771
  EOS
3624
3772
 
3625
- output = render_embedded_string input
3773
+ output = convert_string_to_embedded input
3626
3774
  assert_includes output, '[[3-blind-mice]]'
3627
3775
  assert_xpath '/*[@id = ":3-blind-mice"]', output, 0
3628
3776
  end
@@ -3635,7 +3783,7 @@ content
3635
3783
  --
3636
3784
  EOS
3637
3785
 
3638
- output = render_embedded_string input
3786
+ output = convert_string_to_embedded input
3639
3787
  assert_xpath '/*[@id = ":idname"]', output, 1
3640
3788
  end
3641
3789