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
@@ -4,4 +4,3 @@ v1.0, 2013-01-01
4
4
  :bootstrap-version: 3.2.0
5
5
 
6
6
  Body content.
7
-
@@ -7,7 +7,7 @@ require 'asciidoctor/cli/options'
7
7
  require 'asciidoctor/cli/invoker'
8
8
 
9
9
  context 'Invoker' do
10
- test 'should parse source and render as html5 article by default' do
10
+ test 'should parse source and convert to html5 article by default' do
11
11
  invoker = nil
12
12
  output = nil
13
13
  redirect_streams do |out, err|
@@ -49,12 +49,12 @@ context 'Invoker' do
49
49
 
50
50
  test 'should allow docdate and doctime to be overridden' do
51
51
  sample_filepath = fixture_path 'sample.asciidoc'
52
- invoker = invoke_cli_to_buffer %w(-o /dev/null -a docdate=2015-01-01 -a doctime=10:00:00-07:00), sample_filepath
52
+ invoker = invoke_cli_to_buffer %w(-o /dev/null -a docdate=2015-01-01 -a doctime=10:00:00-0700), sample_filepath
53
53
  doc = invoker.document
54
54
  assert doc.attr?('docdate', '2015-01-01')
55
55
  assert doc.attr?('docyear', '2015')
56
- assert doc.attr?('doctime', '10:00:00-07:00')
57
- assert doc.attr?('docdatetime', '2015-01-01 10:00:00-07:00')
56
+ assert doc.attr?('doctime', '10:00:00-0700')
57
+ assert doc.attr?('docdatetime', '2015-01-01 10:00:00-0700')
58
58
  end
59
59
 
60
60
  test 'should accept document from stdin and write to stdout' do
@@ -362,7 +362,7 @@ context 'Invoker' do
362
362
  end
363
363
  end
364
364
 
365
- test 'should render all passed files' do
365
+ test 'should convert all passed files' do
366
366
  basic_outpath = fixture_path 'basic.html'
367
367
  sample_outpath = fixture_path 'sample.html'
368
368
  begin
@@ -390,7 +390,7 @@ context 'Invoker' do
390
390
  end
391
391
  end
392
392
 
393
- test 'should render all files that matches a glob expression' do
393
+ test 'should convert all files that matches a glob expression' do
394
394
  basic_outpath = fixture_path 'basic.html'
395
395
  begin
396
396
  invoke_cli_to_buffer [], "ba*.asciidoc"
@@ -400,7 +400,7 @@ context 'Invoker' do
400
400
  end
401
401
  end
402
402
 
403
- test 'should render all files that matches an absolute path glob expression' do
403
+ test 'should convert all files that matches an absolute path glob expression' do
404
404
  basic_outpath = fixture_path 'basic.html'
405
405
  glob = fixture_path 'ba*.asciidoc'
406
406
  # test Windows using backslash-style pathname
@@ -629,6 +629,7 @@ eve, islifeform - analyzes an image to determine if it's a picture of a life for
629
629
  end
630
630
 
631
631
  test 'should force default external encoding to UTF-8' do
632
+ ruby = File.join RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']
632
633
  executable = File.join ASCIIDOCTOR_PROJECT_DIR, 'bin', 'asciidoctor'
633
634
  input_path = fixture_path 'encoding.asciidoc'
634
635
  old_lang = ENV['LANG']
@@ -636,14 +637,9 @@ eve, islifeform - analyzes an image to determine if it's a picture of a life for
636
637
  begin
637
638
  # using open3 to work around a bug in JRuby process_manager.rb,
638
639
  # which tries to run a gsub on stdout prematurely breaking the test
639
- require 'open3'
640
- #cmd = "#{executable} -o - --trace #{input_path}"
641
- cmd = "#{File.join RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']} #{executable} -o - --trace #{input_path}"
642
- _, out, _ = Open3.popen3 cmd
643
- #stderr_lines = stderr.readlines
640
+ cmd = %(#{ruby} #{executable} -o - --trace #{input_path})
644
641
  # warnings may be issued, so don't assert on stderr
645
- #assert_empty stderr_lines, 'Command failed. Expected to receive a rendered document.'
646
- stdout_lines = out.readlines
642
+ stdout_lines = Open3.popen3(cmd) {|_, out| out.readlines }
647
643
  refute_empty stdout_lines
648
644
  stdout_lines.each {|l| l.force_encoding Encoding::UTF_8 } if Asciidoctor::FORCE_ENCODING
649
645
  stdout_str = stdout_lines.join
@@ -655,11 +651,11 @@ eve, islifeform - analyzes an image to determine if it's a picture of a life for
655
651
 
656
652
  test 'should print timings when -t flag is specified' do
657
653
  input = <<-EOS
658
- Sample *AsciiDoc*
654
+ Sample *AsciiDoc*
659
655
  EOS
660
656
  invoker = nil
661
657
  error = nil
662
- redirect_streams do |out, err|
658
+ redirect_streams do |_, err|
663
659
  invoker = invoke_cli(%w(-t -o /dev/null), '-') { input }
664
660
  error = err.string
665
661
  end
@@ -668,6 +664,48 @@ eve, islifeform - analyzes an image to determine if it's a picture of a life for
668
664
  assert_match(/Total time/, error)
669
665
  end
670
666
 
667
+ test 'should show timezone as UTC if system TZ is set to UTC' do
668
+ ruby = File.join RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']
669
+ executable = File.join ASCIIDOCTOR_PROJECT_DIR, 'bin', 'asciidoctor'
670
+ input_path = fixture_path 'doctime-localtime.adoc'
671
+ cmd = %(#{ruby} #{executable} -d inline -o - -s #{input_path})
672
+ old_tz = ENV['TZ']
673
+ begin
674
+ ENV['TZ'] = 'UTC'
675
+ result = Open3.popen3(cmd) {|_, out| out.read }
676
+ doctime, localtime = result.lines.map {|l| l.chomp }
677
+ assert doctime.end_with?(' UTC')
678
+ assert localtime.end_with?(' UTC')
679
+ rescue
680
+ if old_tz
681
+ ENV['TZ'] = old_tz
682
+ else
683
+ ENV.delete 'TZ'
684
+ end
685
+ end
686
+ end
687
+
688
+ test 'should show timezone as offset if system TZ is not set to UTC' do
689
+ ruby = File.join RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']
690
+ executable = File.join ASCIIDOCTOR_PROJECT_DIR, 'bin', 'asciidoctor'
691
+ input_path = fixture_path 'doctime-localtime.adoc'
692
+ cmd = %(#{ruby} #{executable} -d inline -o - -s #{input_path})
693
+ old_tz = ENV['TZ']
694
+ begin
695
+ ENV['TZ'] = 'EST+5'
696
+ result = Open3.popen3(cmd) {|_, out| out.read }
697
+ doctime, localtime = result.lines.map {|l| l.chomp }
698
+ assert doctime.end_with?(' -0500')
699
+ assert localtime.end_with?(' -0500')
700
+ ensure
701
+ if old_tz
702
+ ENV['TZ'] = old_tz
703
+ else
704
+ ENV.delete 'TZ'
705
+ end
706
+ end
707
+ end
708
+
671
709
  test 'should use SOURCE_DATE_EPOCH as modified time of input file and local time' do
672
710
  old_source_date_epoch = ENV.delete 'SOURCE_DATE_EPOCH'
673
711
  begin
@@ -677,10 +715,10 @@ eve, islifeform - analyzes an image to determine if it's a picture of a life for
677
715
  doc = invoker.document
678
716
  assert_equal '2009-02-08', (doc.attr 'docdate')
679
717
  assert_equal '2009', (doc.attr 'docyear')
680
- assert_match(/2009-02-08 20:03:32 (GMT|UTC)/, (doc.attr 'docdatetime'))
718
+ assert_match(/2009-02-08 20:03:32 UTC/, (doc.attr 'docdatetime'))
681
719
  assert_equal '2009-02-08', (doc.attr 'localdate')
682
720
  assert_equal '2009', (doc.attr 'localyear')
683
- assert_match(/2009-02-08 20:03:32 (GMT|UTC)/, (doc.attr 'localdatetime'))
721
+ assert_match(/2009-02-08 20:03:32 UTC/, (doc.attr 'localdatetime'))
684
722
  ensure
685
723
  if old_source_date_epoch
686
724
  ENV['SOURCE_DATE_EPOCH'] = old_source_date_epoch
@@ -7,47 +7,56 @@ end
7
7
  context 'Links' do
8
8
 
9
9
  test 'qualified url inline with text' do
10
- assert_xpath "//a[@href='http://asciidoc.org'][@class='bare'][text() = 'http://asciidoc.org']", render_string("The AsciiDoc project is located at http://asciidoc.org.")
10
+ assert_xpath "//a[@href='http://asciidoc.org'][@class='bare'][text() = 'http://asciidoc.org']", convert_string("The AsciiDoc project is located at http://asciidoc.org.")
11
11
  end
12
12
 
13
13
  test 'qualified url with role inline with text' do
14
- assert_xpath "//a[@href='http://asciidoc.org'][@class='bare project'][text() = 'http://asciidoc.org']", render_string("The AsciiDoc project is located at http://asciidoc.org[role=project].")
14
+ assert_xpath "//a[@href='http://asciidoc.org'][@class='bare project'][text() = 'http://asciidoc.org']", convert_string("The AsciiDoc project is located at http://asciidoc.org[role=project].")
15
15
  end
16
16
 
17
17
  test 'qualified http url inline with hide-uri-scheme set' do
18
- assert_xpath "//a[@href='http://asciidoc.org'][@class='bare'][text() = 'asciidoc.org']", render_string("The AsciiDoc project is located at http://asciidoc.org.", :attributes => {'hide-uri-scheme' => ''})
18
+ assert_xpath "//a[@href='http://asciidoc.org'][@class='bare'][text() = 'asciidoc.org']", convert_string("The AsciiDoc project is located at http://asciidoc.org.", :attributes => {'hide-uri-scheme' => ''})
19
19
  end
20
20
 
21
21
  test 'qualified file url inline with label' do
22
- assert_xpath "//a[@href='file:///home/user/bookmarks.html'][text() = 'My Bookmarks']", render_embedded_string('file:///home/user/bookmarks.html[My Bookmarks]')
22
+ assert_xpath "//a[@href='file:///home/user/bookmarks.html'][text() = 'My Bookmarks']", convert_string_to_embedded('file:///home/user/bookmarks.html[My Bookmarks]')
23
23
  end
24
24
 
25
25
  test 'qualified file url inline with hide-uri-scheme set' do
26
- assert_xpath "//a[@href='file:///etc/app.conf'][text() = '/etc/app.conf']", render_string('Edit the configuration file link:file:///etc/app.conf[]', :attributes => {'hide-uri-scheme' => ''})
26
+ assert_xpath "//a[@href='file:///etc/app.conf'][text() = '/etc/app.conf']", convert_string('Edit the configuration file link:file:///etc/app.conf[]', :attributes => {'hide-uri-scheme' => ''})
27
+ end
28
+
29
+ test 'should not hide bare URI scheme in implicit text of link macro when hide-uri-scheme is set' do
30
+ {
31
+ 'link:https://[]' => 'https://',
32
+ 'link:ssh://[]' => 'ssh://'
33
+ }.each do |input, expected|
34
+ assert_xpath %(/a[text() = "#{expected}"]), (convert_inline_string input, :attributes => { 'hide-uri-scheme' => '' })
35
+ end
27
36
  end
28
37
 
29
38
  test 'qualified url with label' do
30
- assert_xpath "//a[@href='http://asciidoc.org'][text() = 'AsciiDoc']", render_string("We're parsing http://asciidoc.org[AsciiDoc] markup")
39
+ assert_xpath "//a[@href='http://asciidoc.org'][text() = 'AsciiDoc']", convert_string("We're parsing http://asciidoc.org[AsciiDoc] markup")
31
40
  end
32
41
 
33
42
  test 'qualified url with label containing escaped right square bracket' do
34
- assert_xpath "//a[@href='http://asciidoc.org'][text() = '[Ascii]Doc']", render_string("We're parsing http://asciidoc.org[[Ascii\\]Doc] markup")
43
+ assert_xpath "//a[@href='http://asciidoc.org'][text() = '[Ascii]Doc']", convert_string("We're parsing http://asciidoc.org[[Ascii\\]Doc] markup")
35
44
  end
36
45
 
37
46
  test 'qualified url with backslash label' do
38
- assert_xpath "//a[@href='https://google.com'][text() = 'Google for \\']", render_string("I advise you to https://google.com[Google for +\\+]")
47
+ assert_xpath "//a[@href='https://google.com'][text() = 'Google for \\']", convert_string("I advise you to https://google.com[Google for +\\+]")
39
48
  end
40
49
 
41
50
  test 'qualified url with label using link macro' do
42
- assert_xpath "//a[@href='http://asciidoc.org'][text() = 'AsciiDoc']", render_string("We're parsing link:http://asciidoc.org[AsciiDoc] markup")
51
+ assert_xpath "//a[@href='http://asciidoc.org'][text() = 'AsciiDoc']", convert_string("We're parsing link:http://asciidoc.org[AsciiDoc] markup")
43
52
  end
44
53
 
45
54
  test 'qualified url with role using link macro' do
46
- assert_xpath "//a[@href='http://asciidoc.org'][@class='bare project'][text() = 'http://asciidoc.org']", render_string("We're parsing link:http://asciidoc.org[role=project] markup")
55
+ assert_xpath "//a[@href='http://asciidoc.org'][@class='bare project'][text() = 'http://asciidoc.org']", convert_string("We're parsing link:http://asciidoc.org[role=project] markup")
47
56
  end
48
57
 
49
58
  test 'qualified url using macro syntax with multi-line label inline with text' do
50
- assert_xpath %{//a[@href='http://asciidoc.org'][text() = 'AsciiDoc\nmarkup']}, render_string("We're parsing link:http://asciidoc.org[AsciiDoc\nmarkup]")
59
+ assert_xpath %{//a[@href='http://asciidoc.org'][text() = 'AsciiDoc\nmarkup']}, convert_string("We're parsing link:http://asciidoc.org[AsciiDoc\nmarkup]")
51
60
  end
52
61
 
53
62
  test 'qualified url with label containing square brackets using link macro' do
@@ -62,54 +71,54 @@ context 'Links' do
62
71
 
63
72
  test 'link macro with empty target' do
64
73
  input = 'Link to link:[this page].'
65
- output = render_embedded_string input
74
+ output = convert_string_to_embedded input
66
75
  assert_xpath '//a', output, 1
67
76
  assert_xpath '//a[@href=""]', output, 1
68
77
  end
69
78
 
70
79
  test 'should not recognize link macro with double colons' do
71
80
  input = 'The link::http://example.org[example domain] is reserved for tests and documentation.'
72
- output = render_embedded_string input
81
+ output = convert_string_to_embedded input
73
82
  assert_includes output, 'link::http://example.org[example domain]'
74
83
  end
75
84
 
76
85
  test 'qualified url surrounded by angled brackets' do
77
- assert_xpath '//a[@href="http://asciidoc.org"][text()="http://asciidoc.org"]', render_string('<http://asciidoc.org> is the project page for AsciiDoc.'), 1
86
+ assert_xpath '//a[@href="http://asciidoc.org"][text()="http://asciidoc.org"]', convert_string('<http://asciidoc.org> is the project page for AsciiDoc.'), 1
78
87
  end
79
88
 
80
89
  test 'qualified url surrounded by round brackets' do
81
- assert_xpath '//a[@href="http://asciidoc.org"][text()="http://asciidoc.org"]', render_string('(http://asciidoc.org) is the project page for AsciiDoc.'), 1
90
+ assert_xpath '//a[@href="http://asciidoc.org"][text()="http://asciidoc.org"]', convert_string('(http://asciidoc.org) is the project page for AsciiDoc.'), 1
82
91
  end
83
92
 
84
93
  test 'qualified url with trailing round bracket' do
85
- assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', render_string('Asciidoctor is a Ruby-based AsciiDoc processor (see https://asciidoctor.org)'), 1
94
+ assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', convert_string('Asciidoctor is a Ruby-based AsciiDoc processor (see https://asciidoctor.org)'), 1
86
95
  end
87
96
 
88
97
  test 'qualified url with trailing semi-colon' do
89
- assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', render_string('https://asciidoctor.org; where text gets parsed'), 1
98
+ assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', convert_string('https://asciidoctor.org; where text gets parsed'), 1
90
99
  end
91
100
 
92
101
  test 'qualified url with trailing colon' do
93
- assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', render_string('https://asciidoctor.org: where text gets parsed'), 1
102
+ assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', convert_string('https://asciidoctor.org: where text gets parsed'), 1
94
103
  end
95
104
 
96
105
  test 'qualified url in round brackets with trailing colon' do
97
- assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', render_string('(https://asciidoctor.org): where text gets parsed'), 1
106
+ assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', convert_string('(https://asciidoctor.org): where text gets parsed'), 1
98
107
  end
99
108
 
100
109
  test 'qualified url with trailing round bracket followed by colon' do
101
- result = render_embedded_string '(from https://asciidoctor.org): where text gets parsed'
110
+ result = convert_string_to_embedded '(from https://asciidoctor.org): where text gets parsed'
102
111
  assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', result, 1
103
112
  assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]/preceding-sibling::text()[.="(from "]', result, 1
104
113
  assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]/following-sibling::text()[.="): where text gets parsed"]', result, 1
105
114
  end
106
115
 
107
116
  test 'qualified url in round brackets with trailing semi-colon' do
108
- assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', render_string('(https://asciidoctor.org); where text gets parsed'), 1
117
+ assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', convert_string('(https://asciidoctor.org); where text gets parsed'), 1
109
118
  end
110
119
 
111
120
  test 'qualified url with trailing round bracket followed by semi-colon' do
112
- result = render_embedded_string '(from https://asciidoctor.org); where text gets parsed'
121
+ result = convert_string_to_embedded '(from https://asciidoctor.org); where text gets parsed'
113
122
  assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]', result, 1
114
123
  assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]/preceding-sibling::text()[.="(from "]', result, 1
115
124
  assert_xpath '//a[@href="https://asciidoctor.org"][text()="https://asciidoctor.org"]/following-sibling::text()[.="); where text gets parsed"]', result, 1
@@ -136,133 +145,133 @@ context 'Links' do
136
145
  end
137
146
 
138
147
  test 'qualified url containing round brackets' do
139
- assert_xpath '//a[@href="http://jruby.org/apidocs/org/jruby/Ruby.html#addModule(org.jruby.RubyModule)"][text()="addModule() adds a Ruby module"]', render_string('http://jruby.org/apidocs/org/jruby/Ruby.html#addModule(org.jruby.RubyModule)[addModule() adds a Ruby module]'), 1
148
+ assert_xpath '//a[@href="http://jruby.org/apidocs/org/jruby/Ruby.html#addModule(org.jruby.RubyModule)"][text()="addModule() adds a Ruby module"]', convert_string('http://jruby.org/apidocs/org/jruby/Ruby.html#addModule(org.jruby.RubyModule)[addModule() adds a Ruby module]'), 1
140
149
  end
141
150
 
142
151
  test 'qualified url adjacent to text in square brackets' do
143
- assert_xpath '//a[@href="http://asciidoc.org"][text()="AsciiDoc"]', render_string(']http://asciidoc.org[AsciiDoc] project page.'), 1
152
+ assert_xpath '//a[@href="http://asciidoc.org"][text()="AsciiDoc"]', convert_string(']http://asciidoc.org[AsciiDoc] project page.'), 1
144
153
  end
145
154
 
146
155
  test 'qualified url adjacent to text in round brackets' do
147
- assert_xpath '//a[@href="http://asciidoc.org"][text()="AsciiDoc"]', render_string(')http://asciidoc.org[AsciiDoc] project page.'), 1
156
+ assert_xpath '//a[@href="http://asciidoc.org"][text()="AsciiDoc"]', convert_string(')http://asciidoc.org[AsciiDoc] project page.'), 1
148
157
  end
149
158
 
150
159
  test 'qualified url following no-break space' do
151
- assert_xpath '//a[@href="http://asciidoc.org"][text()="AsciiDoc"]', render_string(%(#{[0xa0].pack 'U1'}http://asciidoc.org[AsciiDoc] project page.)), 1
160
+ assert_xpath '//a[@href="http://asciidoc.org"][text()="AsciiDoc"]', convert_string(%(#{[0xa0].pack 'U1'}http://asciidoc.org[AsciiDoc] project page.)), 1
152
161
  end if ::RUBY_MIN_VERSION_1_9
153
162
 
154
163
  test 'qualified url following smart apostrophe' do
155
- output = render_embedded_string("l&#8217;http://www.irit.fr[IRIT]")
164
+ output = convert_string_to_embedded("l&#8217;http://www.irit.fr[IRIT]")
156
165
  assert_match(/l&#8217;<a href=/, output)
157
166
  end
158
167
 
159
168
  test 'qualified url using invalid link macro should not create link' do
160
- assert_xpath '//a', render_string('link:http://asciidoc.org is the project page for AsciiDoc.'), 0
169
+ assert_xpath '//a', convert_string('link:http://asciidoc.org is the project page for AsciiDoc.'), 0
161
170
  end
162
171
 
163
172
  test 'escaped inline qualified url should not create link' do
164
- assert_xpath '//a', render_string('\http://asciidoc.org is the project page for AsciiDoc.'), 0
173
+ assert_xpath '//a', convert_string('\http://asciidoc.org is the project page for AsciiDoc.'), 0
165
174
  end
166
175
 
167
176
  test 'url in link macro with at (@) sign should not create mailto link' do
168
- assert_xpath '//a[@href="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"][text()="subscribe"]', render_string('http://xircles.codehaus.org/lists/dev@geb.codehaus.org[subscribe]')
177
+ assert_xpath '//a[@href="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"][text()="subscribe"]', convert_string('http://xircles.codehaus.org/lists/dev@geb.codehaus.org[subscribe]')
169
178
  end
170
179
 
171
180
  test 'implicit url with at (@) sign should not create mailto link' do
172
- assert_xpath '//a[@href="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"][text()="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"]', render_string('http://xircles.codehaus.org/lists/dev@geb.codehaus.org')
181
+ assert_xpath '//a[@href="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"][text()="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"]', convert_string('http://xircles.codehaus.org/lists/dev@geb.codehaus.org')
173
182
  end
174
183
 
175
184
  test 'escaped inline qualified url using macro syntax should not create link' do
176
- assert_xpath '//a', render_string('\http://asciidoc.org[AsciiDoc] is the key to good docs.'), 0
185
+ assert_xpath '//a', convert_string('\http://asciidoc.org[AsciiDoc] is the key to good docs.'), 0
177
186
  end
178
187
 
179
188
  test 'inline qualified url followed by an endline should not include endline in link' do
180
- assert_xpath '//a[@href="https://github.com/asciidoctor"]', render_string("The source code for Asciidoctor can be found at https://github.com/asciidoctor\nwhich is a GitHub organization."), 1
189
+ assert_xpath '//a[@href="https://github.com/asciidoctor"]', convert_string("The source code for Asciidoctor can be found at https://github.com/asciidoctor\nwhich is a GitHub organization."), 1
181
190
  end
182
191
 
183
192
  test 'qualified url divided by endline using macro syntax should not create link' do
184
- assert_xpath '//a', render_string("The source code for Asciidoctor can be found at link:https://github.com/asciidoctor\n[]which is a GitHub organization."), 0
193
+ assert_xpath '//a', convert_string("The source code for Asciidoctor can be found at link:https://github.com/asciidoctor\n[]which is a GitHub organization."), 0
185
194
  end
186
195
 
187
196
  test 'qualified url containing whitespace using macro syntax should not create link' do
188
- assert_xpath '//a', render_string('I often need to refer to the chapter on link:http://asciidoc.org?q=attribute references[Attribute References].'), 0
197
+ assert_xpath '//a', convert_string('I often need to refer to the chapter on link:http://asciidoc.org?q=attribute references[Attribute References].'), 0
189
198
  end
190
199
 
191
200
  test 'qualified url containing an encoded space using macro syntax should create a link' do
192
- assert_xpath '//a', render_string('I often need to refer to the chapter on link:http://asciidoc.org?q=attribute%20references[Attribute References].'), 1
201
+ assert_xpath '//a', convert_string('I often need to refer to the chapter on link:http://asciidoc.org?q=attribute%20references[Attribute References].'), 1
193
202
  end
194
203
 
195
204
  test 'inline quoted qualified url should not consume surrounding angled brackets' do
196
- assert_xpath '//a[@href="https://github.com/asciidoctor"]', render_string('Asciidoctor GitHub organization: <**https://github.com/asciidoctor**>'), 1
205
+ assert_xpath '//a[@href="https://github.com/asciidoctor"]', convert_string('Asciidoctor GitHub organization: <**https://github.com/asciidoctor**>'), 1
197
206
  end
198
207
 
199
208
  test 'link with quoted text should not be separated into attributes when text contains an equal sign' do
200
- assert_xpath '//a[@href="http://search.example.com"][text()="Google, Yahoo, Bing = Search Engines"]', render_embedded_string('http://search.example.com["Google, Yahoo, Bing = Search Engines"]'), 1
209
+ assert_xpath '//a[@href="http://search.example.com"][text()="Google, Yahoo, Bing = Search Engines"]', convert_string_to_embedded('http://search.example.com["Google, Yahoo, Bing = Search Engines"]'), 1
201
210
  end
202
211
 
203
212
  test 'link with quoted text but no equal sign should carry quotes over to output' do
204
- assert_xpath %(//a[@href="http://search.example.com"][text()='"Google, Yahoo, Bing"']), render_embedded_string('http://search.example.com["Google, Yahoo, Bing"]'), 1
213
+ assert_xpath %(//a[@href="http://search.example.com"][text()='"Google, Yahoo, Bing"']), convert_string_to_embedded('http://search.example.com["Google, Yahoo, Bing"]'), 1
205
214
  end
206
215
 
207
216
  test 'link with comma in text but no equal sign should not be separated into attributes' do
208
- assert_xpath '//a[@href="http://search.example.com"][text()="Google, Yahoo, Bing"]', render_embedded_string('http://search.example.com[Google, Yahoo, Bing]'), 1
217
+ assert_xpath '//a[@href="http://search.example.com"][text()="Google, Yahoo, Bing"]', convert_string_to_embedded('http://search.example.com[Google, Yahoo, Bing]'), 1
209
218
  end
210
219
 
211
220
  test 'role and window attributes on link are processed' do
212
- assert_xpath '//a[@href="http://google.com"][@class="external"][@target="_blank"]', render_embedded_string('http://google.com[Google, role=external, window="_blank"]'), 1
221
+ assert_xpath '//a[@href="http://google.com"][@class="external"][@target="_blank"]', convert_string_to_embedded('http://google.com[Google, role=external, window="_blank"]'), 1
213
222
  end
214
223
 
215
224
  test 'link macro with attributes but no text should use URL as text' do
216
225
  url = 'https://fonts.googleapis.com/css?family=Roboto:400,400italic,'
217
- assert_xpath %(//a[@href="#{url}"][text()="#{url}"]), render_embedded_string(%(link:#{url}[family=Roboto,weight=400])), 1
226
+ assert_xpath %(//a[@href="#{url}"][text()="#{url}"]), convert_string_to_embedded(%(link:#{url}[family=Roboto,weight=400])), 1
218
227
  end
219
228
 
220
229
  test 'link macro with attributes but blank text should use URL as text' do
221
230
  url = 'https://fonts.googleapis.com/css?family=Roboto:400,400italic,'
222
- assert_xpath %(//a[@href="#{url}"][text()="#{url}"]), render_embedded_string(%(link:#{url}[,family=Roboto,weight=400])), 1
231
+ assert_xpath %(//a[@href="#{url}"][text()="#{url}"]), convert_string_to_embedded(%(link:#{url}[,family=Roboto,weight=400])), 1
223
232
  end
224
233
 
225
234
  test 'link macro with comma but no explicit attributes in text should not parse text' do
226
235
  url = 'https://fonts.googleapis.com/css?family=Roboto:400,400italic,'
227
- assert_xpath %(//a[@href="#{url}"][text()="Roboto,400"]), render_embedded_string(%(link:#{url}[Roboto,400])), 1
236
+ assert_xpath %(//a[@href="#{url}"][text()="Roboto,400"]), convert_string_to_embedded(%(link:#{url}[Roboto,400])), 1
228
237
  end
229
238
 
230
239
  test 'link text that ends in ^ should set link window to _blank' do
231
- assert_xpath '//a[@href="http://google.com"][@target="_blank"]', render_embedded_string('http://google.com[Google^]'), 1
240
+ assert_xpath '//a[@href="http://google.com"][@target="_blank"]', convert_string_to_embedded('http://google.com[Google^]'), 1
232
241
  end
233
242
 
234
243
  test 'rel=noopener should be added to a link that targets the _blank window' do
235
- assert_xpath '//a[@href="http://google.com"][@target="_blank"][@rel="noopener"]', render_embedded_string('http://google.com[Google^]'), 1
244
+ assert_xpath '//a[@href="http://google.com"][@target="_blank"][@rel="noopener"]', convert_string_to_embedded('http://google.com[Google^]'), 1
236
245
  end
237
246
 
238
247
  test 'rel=noopener should be added to a link that targets a named window when the noopener option is set' do
239
- assert_xpath '//a[@href="http://google.com"][@target="name"][@rel="noopener"]', render_embedded_string('http://google.com[Google,window=name,opts=noopener]'), 1
248
+ assert_xpath '//a[@href="http://google.com"][@target="name"][@rel="noopener"]', convert_string_to_embedded('http://google.com[Google,window=name,opts=noopener]'), 1
240
249
  end
241
250
 
242
251
  test 'rel=noopener should not be added to a link if it does not target a window' do
243
- result = render_embedded_string 'http://google.com[Google,opts=noopener]'
252
+ result = convert_string_to_embedded 'http://google.com[Google,opts=noopener]'
244
253
  assert_xpath '//a[@href="http://google.com"]', result, 1
245
254
  assert_xpath '//a[@href="http://google.com"][@rel="noopener"]', result, 0
246
255
  end
247
256
 
248
257
  test 'rel=nofollow should be added to a link when the nofollow option is set' do
249
- assert_xpath '//a[@href="http://google.com"][@target="name"][@rel="nofollow noopener"]', render_embedded_string('http://google.com[Google,window=name,opts="nofollow,noopener"]'), 1
258
+ assert_xpath '//a[@href="http://google.com"][@target="name"][@rel="nofollow noopener"]', convert_string_to_embedded('http://google.com[Google,window=name,opts="nofollow,noopener"]'), 1
250
259
  end
251
260
 
252
261
  test 'id attribute on link is processed' do
253
- assert_xpath '//a[@href="http://google.com"][@id="link-1"]', render_embedded_string('http://google.com[Google, id="link-1"]'), 1
262
+ assert_xpath '//a[@href="http://google.com"][@id="link-1"]', convert_string_to_embedded('http://google.com[Google, id="link-1"]'), 1
254
263
  end
255
264
 
256
265
  test 'title attribute on link is processed' do
257
- assert_xpath '//a[@href="http://google.com"][@title="title-1"]', render_embedded_string('http://google.com[Google, title="title-1"]'), 1
266
+ assert_xpath '//a[@href="http://google.com"][@title="title-1"]', convert_string_to_embedded('http://google.com[Google, title="title-1"]'), 1
258
267
  end
259
268
 
260
269
  test 'inline irc link' do
261
- assert_xpath '//a[@href="irc://irc.freenode.net"][text()="irc://irc.freenode.net"]', render_embedded_string('irc://irc.freenode.net'), 1
270
+ assert_xpath '//a[@href="irc://irc.freenode.net"][text()="irc://irc.freenode.net"]', convert_string_to_embedded('irc://irc.freenode.net'), 1
262
271
  end
263
272
 
264
273
  test 'inline irc link with text' do
265
- assert_xpath '//a[@href="irc://irc.freenode.net"][text()="Freenode IRC"]', render_embedded_string('irc://irc.freenode.net[Freenode IRC]'), 1
274
+ assert_xpath '//a[@href="irc://irc.freenode.net"][text()="Freenode IRC"]', convert_string_to_embedded('irc://irc.freenode.net[Freenode IRC]'), 1
266
275
  end
267
276
 
268
277
  test 'inline ref' do
@@ -291,13 +300,13 @@ context 'Links' do
291
300
 
292
301
  test 'inline ref can start with colon' do
293
302
  input = '[[:idname]] text'
294
- output = render_embedded_string input
303
+ output = convert_string_to_embedded input
295
304
  assert_xpath '//a[@id = ":idname"]', output, 1
296
305
  end
297
306
 
298
307
  test 'inline ref cannot start with digit' do
299
308
  input = '[[1-install]] text'
300
- output = render_embedded_string input
309
+ output = convert_string_to_embedded input
301
310
  assert_includes output, '[[1-install]]'
302
311
  assert_xpath '//a[@id = "1-install"]', output, 0
303
312
  end
@@ -316,7 +325,7 @@ context 'Links' do
316
325
 
317
326
  test 'should encode double quotes in reftext of anchor macro in DocBook output' do
318
327
  input = 'anchor:uncola[the "un"-cola]'
319
- result = render_inline_string input, :backend => :docbook
328
+ result = convert_inline_string input, :backend => :docbook
320
329
  assert_equal '<anchor xml:id="uncola" xreflabel="the &quot;un&quot;-cola"/>', result
321
330
  end
322
331
 
@@ -349,19 +358,19 @@ context 'Links' do
349
358
 
350
359
  test 'repeating inline anchor macro with empty reftext' do
351
360
  input = 'anchor:one[] anchor:two[] anchor:three[]'
352
- result = render_inline_string input
361
+ result = convert_inline_string input
353
362
  assert_equal '<a id="one"></a> <a id="two"></a> <a id="three"></a>', result
354
363
  end
355
364
 
356
365
  test 'mixed inline anchor macro and anchor shorthand with empty reftext' do
357
366
  input = 'anchor:one[][[two]]anchor:three[][[four]]anchor:five[]'
358
- result = render_inline_string input
367
+ result = convert_inline_string input
359
368
  assert_equal '<a id="one"></a><a id="two"></a><a id="three"></a><a id="four"></a><a id="five"></a>', result
360
369
  end
361
370
 
362
371
  test 'assigns xreflabel value for anchor macro without reftext in DocBook output' do
363
372
  input = 'anchor:foo[]'
364
- result = render_inline_string input, :backend => :docbook
373
+ result = convert_inline_string input, :backend => :docbook
365
374
  assert_equal '<anchor xml:id="foo" xreflabel="[foo]"/>', result
366
375
  end
367
376
 
@@ -369,13 +378,13 @@ context 'Links' do
369
378
  input = 'see <<foo>>
370
379
 
371
380
  anchor:foo[b[a\]r]text'
372
- result = render_embedded_string input
381
+ result = convert_string_to_embedded input
373
382
  assert_includes result, 'see <a href="#foo">b[a]r</a>'
374
383
  end
375
384
 
376
385
  test 'unescapes square bracket in reftext of anchor macro in DocBook output' do
377
386
  input = 'anchor:foo[b[a\]r]'
378
- result = render_inline_string input, :backend => :docbook
387
+ result = convert_inline_string input, :backend => :docbook
379
388
  assert_equal '<anchor xml:id="foo" xreflabel="b[a]r"/>', result
380
389
  end
381
390
 
@@ -398,7 +407,7 @@ anchor:foo[b[a\]r]text'
398
407
  [#tigers]
399
408
  == Tigers
400
409
  EOS
401
- assert_xpath '//a[@href="#tigers"][text() = "About Tigers"]', render_string(input), 1
410
+ assert_xpath '//a[@href="#tigers"][text() = "About Tigers"]', convert_string(input), 1
402
411
  end
403
412
 
404
413
  test 'xref using angled bracket syntax with quoted label' do
@@ -408,7 +417,7 @@ anchor:foo[b[a\]r]text'
408
417
  [#tigers]
409
418
  == Tigers
410
419
  EOS
411
- assert_xpath %q(//a[@href="#tigers"][text() = '"About Tigers"']), render_string(input), 1
420
+ assert_xpath %q(//a[@href="#tigers"][text() = '"About Tigers"']), convert_string(input), 1
412
421
  end
413
422
 
414
423
  test 'should not interpret path sans extension in xref with angled bracket syntax in compat mode' do
@@ -428,13 +437,13 @@ anchor:foo[b[a\]r]text'
428
437
  'using-.net-web-services' => 'Using .NET web services',
429
438
  '../file.pdf' => 'Download the .pdf file'
430
439
  }.each do |path, text|
431
- result = render_embedded_string %(<<#{path}#,#{text}>>)
440
+ result = convert_string_to_embedded %(<<#{path}#,#{text}>>)
432
441
  assert_xpath %(//a[@href="#{path}"][text() = "#{text}"]), result, 1
433
442
  end
434
443
  end
435
444
 
436
445
  test 'inter-document xref should only remove the file extension part if the path contains a period elsewhere' do
437
- result = render_embedded_string '<<using-.net-web-services.adoc#,Using .NET web services>>'
446
+ result = convert_string_to_embedded '<<using-.net-web-services.adoc#,Using .NET web services>>'
438
447
  assert_xpath '//a[@href="using-.net-web-services.html"][text() = "Using .NET web services"]', result, 1
439
448
  end
440
449
 
@@ -537,7 +546,7 @@ Want to learn <<tigers,about tigers>>?
537
546
  [#tigers]
538
547
  == Tigers
539
548
  EOS
540
- assert_xpath '//a[@href="#tigers"][text() = "about tigers"]', render_string(input), 1
549
+ assert_xpath '//a[@href="#tigers"][text() = "about tigers"]', convert_string(input), 1
541
550
  end
542
551
 
543
552
  test 'xref using angled bracket syntax with multi-line label inline with text' do
@@ -548,7 +557,7 @@ tigers>>?
548
557
  [#tigers]
549
558
  == Tigers
550
559
  EOS
551
- assert_xpath %{//a[@href="#tigers"][normalize-space(text()) = "about tigers"]}, render_string(input), 1
560
+ assert_xpath %{//a[@href="#tigers"][normalize-space(text()) = "about tigers"]}, convert_string(input), 1
552
561
  end
553
562
 
554
563
  test 'xref with escaped text' do
@@ -560,7 +569,7 @@ See the <<tigers, `+[tigers]+`>> section for details about tigers.
560
569
  [#tigers]
561
570
  == Tigers
562
571
  EOS
563
- output = render_embedded_string input
572
+ output = convert_string_to_embedded input
564
573
  assert_xpath %(//a[@href="#tigers"]/code[text()="[tigers]"]), output, 1
565
574
  end
566
575
 
@@ -575,7 +584,7 @@ See the <<tigers, `+[tigers]+`>> section for details about tigers.
575
584
  A summary of the first lesson.
576
585
  EOS
577
586
 
578
- output = render_embedded_string input
587
+ output = convert_string_to_embedded input
579
588
  assert_xpath '//h2/a[@href="lessons/lesson-1.html"]', output, 1
580
589
  end
581
590
  end
@@ -596,7 +605,7 @@ This document has two sections, xref:sect-a[] and xref:sect-b[].
596
605
  [#sect-b]
597
606
  == Section B
598
607
  EOS
599
- result = render_embedded_string input
608
+ result = convert_string_to_embedded input
600
609
  assert_xpath '//a[@href="#sect-a"][text() = "Section A"]', result, 1
601
610
  assert_xpath '//a[@href="#sect-b"][text() = "Section B"]', result, 1
602
611
  end
@@ -614,7 +623,7 @@ xref:tigers[About Tigers]
614
623
  [#tigers]
615
624
  == Tigers
616
625
  EOS
617
- assert_xpath '//a[@href="#tigers"][text() = "About Tigers"]', render_string(input), 1
626
+ assert_xpath '//a[@href="#tigers"][text() = "About Tigers"]', convert_string(input), 1
618
627
  end
619
628
 
620
629
  test 'xref using macro syntax inline with text' do
@@ -625,7 +634,7 @@ Want to learn xref:tigers[about tigers]?
625
634
  == Tigers
626
635
  EOS
627
636
 
628
- assert_xpath '//a[@href="#tigers"][text() = "about tigers"]', render_string(input), 1
637
+ assert_xpath '//a[@href="#tigers"][text() = "about tigers"]', convert_string(input), 1
629
638
  end
630
639
 
631
640
  test 'xref using macro syntax with multi-line label inline with text' do
@@ -636,7 +645,7 @@ tigers]?
636
645
  [#tigers]
637
646
  == Tigers
638
647
  EOS
639
- assert_xpath %{//a[@href="#tigers"][normalize-space(text()) = "about tigers"]}, render_string(input), 1
648
+ assert_xpath %{//a[@href="#tigers"][normalize-space(text()) = "about tigers"]}, convert_string(input), 1
640
649
  end
641
650
 
642
651
  test 'xref using macro syntax with text that ends with an escaped closing bracket' do
@@ -646,7 +655,7 @@ xref:tigers[[tigers\\]]
646
655
  [#tigers]
647
656
  == Tigers
648
657
  EOS
649
- assert_xpath '//a[@href="#tigers"][text() = "[tigers]"]', render_embedded_string(input), 1
658
+ assert_xpath '//a[@href="#tigers"][text() = "[tigers]"]', convert_string_to_embedded(input), 1
650
659
  end
651
660
 
652
661
  test 'xref using macro syntax with text that contains an escaped closing bracket' do
@@ -656,14 +665,14 @@ xref:tigers[[tigers\\] are cats]
656
665
  [#tigers]
657
666
  == Tigers
658
667
  EOS
659
- assert_xpath '//a[@href="#tigers"][text() = "[tigers] are cats"]', render_embedded_string(input), 1
668
+ assert_xpath '//a[@href="#tigers"][text() = "[tigers] are cats"]', convert_string_to_embedded(input), 1
660
669
  end
661
670
 
662
671
  test 'unescapes square bracket in reftext used by xref' do
663
672
  input = 'anchor:foo[b[a\]r]about
664
673
 
665
674
  see <<foo>>'
666
- result = render_embedded_string input
675
+ result = convert_string_to_embedded input
667
676
  assert_xpath '//a[@href="#foo"]', result, 1
668
677
  assert_xpath '//a[@href="#foo"][text()="b[a]r"]', result, 1
669
678
  end
@@ -685,7 +694,7 @@ See <<foobaz>>.
685
694
  EOS
686
695
  using_memory_logger do |logger|
687
696
  in_verbose_mode do
688
- output = render_embedded_string input
697
+ output = convert_string_to_embedded input
689
698
  assert_xpath '//a[@href="#foobaz"][text() = "[foobaz]"]', output, 1
690
699
  assert_message logger, :WARN, 'invalid reference: foobaz'
691
700
  end
@@ -703,7 +712,7 @@ See <<#foobaz>>.
703
712
  EOS
704
713
  using_memory_logger do |logger|
705
714
  in_verbose_mode do
706
- output = render_embedded_string input
715
+ output = convert_string_to_embedded input
707
716
  assert_xpath '//a[@href="#foobaz"][text() = "[foobaz]"]', output, 1
708
717
  assert_message logger, :WARN, 'invalid reference: foobaz'
709
718
  end
@@ -747,7 +756,7 @@ Read <<other-chapters.adoc#ch2>> to find out what happens next!
747
756
  include::other-chapters.adoc[tags=**]
748
757
  EOS
749
758
 
750
- output = render_embedded_string input, :safe => :safe, :base_dir => fixturedir
759
+ output = convert_string_to_embedded input, :safe => :safe, :base_dir => fixturedir
751
760
  assert_xpath '//a[@href="#ch2"][text()="Chapter 2"]', output, 1
752
761
  end
753
762
 
@@ -784,13 +793,28 @@ See <<test.adoc#foobaz>>.
784
793
  EOS
785
794
  using_memory_logger do |logger|
786
795
  in_verbose_mode do
787
- output = render_embedded_string input, :attributes => { 'docname' => 'test' }
796
+ output = convert_string_to_embedded input, :attributes => { 'docname' => 'test' }
788
797
  assert_xpath '//a[@href="#foobaz"][text() = "[foobaz]"]', output, 1
789
798
  assert_message logger, :WARN, 'invalid reference: foobaz'
790
799
  end
791
800
  end
792
801
  end
793
802
 
803
+ test 'should produce an internal anchor for inter-document xref to file outside of base directory' do
804
+ input = <<-EOS
805
+ = Document Title
806
+
807
+ See <<../section-a.adoc#section-a>>.
808
+
809
+ include::../section-a.adoc[]
810
+ EOS
811
+
812
+ doc = document_from_string input, :safe => :unsafe, :base_dir => (File.join fixturedir, 'subdir')
813
+ assert_includes doc.catalog[:includes], '../section-a'
814
+ output = doc.convert :header_footer => false
815
+ assert_xpath '//a[@href="#section-a"][text()="Section A"]', output, 1
816
+ end
817
+
794
818
  test 'xref uses title of target as label for forward and backward references in html output' do
795
819
  input = <<-EOS
796
820
  == Section A
@@ -802,7 +826,7 @@ See <<test.adoc#foobaz>>.
802
826
  <<_section_a>>
803
827
  EOS
804
828
 
805
- output = render_embedded_string input
829
+ output = convert_string_to_embedded input
806
830
  assert_xpath '//h2[@id="_section_a"][text()="Section A"]', output, 1
807
831
  assert_xpath '//a[@href="#_section_a"][text()="Section A"]', output, 1
808
832
  assert_xpath '//h2[@id="_section_b"][text()="Section B"]', output, 1