test/text_test.rb in asciidoctor-1.5.7.1 vs test/text_test.rb in asciidoctor-1.5.8

- old
+ new

@@ -51,43 +51,43 @@ assert_css '.paragraph', output, 1 end test 'escaped text markup' do assert_match(/All your &lt;em&gt;inline&lt;\/em&gt; markup belongs to &lt;strong&gt;us&lt;\/strong&gt;!/, - render_string('All your <em>inline</em> markup belongs to <strong>us</strong>!')) + convert_string('All your <em>inline</em> markup belongs to <strong>us</strong>!')) end test "line breaks" do - assert_xpath "//br", render_string("Well this is +\njust fine and dandy, isn't it?"), 1 + assert_xpath "//br", convert_string("Well this is +\njust fine and dandy, isn't it?"), 1 end test 'single- and double-quoted text' do - rendered = render_embedded_string(%q(``Where?,'' she said, flipping through her copy of `The New Yorker.'), :attributes => {'compat-mode' => ''}) - assert_match(/&#8220;Where\?,&#8221;/, rendered) - assert_match(/&#8216;The New Yorker.&#8217;/, rendered) + output = convert_string_to_embedded(%q(``Where?,'' she said, flipping through her copy of `The New Yorker.'), :attributes => {'compat-mode' => ''}) + assert_match(/&#8220;Where\?,&#8221;/, output) + assert_match(/&#8216;The New Yorker.&#8217;/, output) - rendered = render_embedded_string(%q("`Where?,`" she said, flipping through her copy of '`The New Yorker.`')) - assert_match(/&#8220;Where\?,&#8221;/, rendered) - assert_match(/&#8216;The New Yorker.&#8217;/, rendered) + output = convert_string_to_embedded(%q("`Where?,`" she said, flipping through her copy of '`The New Yorker.`')) + assert_match(/&#8220;Where\?,&#8221;/, output) + assert_match(/&#8216;The New Yorker.&#8217;/, output) end test 'multiple double-quoted text on a single line' do assert_equal '&#8220;Our business is constantly changing&#8221; or &#8220;We need faster time to market.&#8221;', - render_embedded_string(%q(``Our business is constantly changing'' or ``We need faster time to market.''), :doctype => :inline, :attributes => {'compat-mode' => ''}) + convert_inline_string(%q(``Our business is constantly changing'' or ``We need faster time to market.''), :attributes => {'compat-mode' => ''}) assert_equal '&#8220;Our business is constantly changing&#8221; or &#8220;We need faster time to market.&#8221;', - render_embedded_string(%q("`Our business is constantly changing`" or "`We need faster time to market.`"), :doctype => :inline) + convert_inline_string(%q("`Our business is constantly changing`" or "`We need faster time to market.`")) end test 'horizontal rule' do input = <<-EOS This line is separated by a horizontal rule... ''' ...from this line. EOS - output = render_embedded_string input + output = convert_string_to_embedded input assert_xpath "//hr", output, 1 assert_xpath "/*[@class='paragraph']", output, 2 assert_xpath "(/*[@class='paragraph'])[1]/following-sibling::hr", output, 1 assert_xpath "/hr/following-sibling::*[@class='paragraph']", output, 1 end @@ -116,11 +116,11 @@ #{offset}#{variant} ...from this line. EOS - output = render_embedded_string input + output = convert_string_to_embedded input assert_xpath "//hr", output, 1 assert_xpath "/*[@class='paragraph']", output, 2 assert_xpath "(/*[@class='paragraph'])[1]/following-sibling::hr", output, 1 assert_xpath "/hr/following-sibling::*[@class='paragraph']", output, 1 end @@ -149,11 +149,11 @@ #{offset}#{variant} ...from this line. EOS - output = render_embedded_string input + output = convert_string_to_embedded input assert_xpath '//hr', output, 0 end end good_variants = [ @@ -174,136 +174,136 @@ #{offset}#{variant} ...from this line. EOS - output = render_embedded_string input + output = convert_string_to_embedded input assert_xpath '//hr', output, 0 end end end test "emphasized text using underscore characters" do - assert_xpath "//em", render_string("An _emphatic_ no") + assert_xpath "//em", convert_string("An _emphatic_ no") end test 'emphasized text with single quote using apostrophe characters' do rsquo = decode_char 8217 - assert_xpath %(//em[text()="Johnny#{rsquo}s"]), render_string(%q(It's 'Johnny's' phone), :attributes => {'compat-mode' => ''}) - assert_xpath %(//p[text()="It#{rsquo}s 'Johnny#{rsquo}s' phone"]), render_string(%q(It's 'Johnny's' phone)) + assert_xpath %(//em[text()="Johnny#{rsquo}s"]), convert_string(%q(It's 'Johnny's' phone), :attributes => {'compat-mode' => ''}) + assert_xpath %(//p[text()="It#{rsquo}s 'Johnny#{rsquo}s' phone"]), convert_string(%q(It's 'Johnny's' phone)) end test 'emphasized text with escaped single quote using apostrophe characters' do - assert_xpath %(//em[text()="Johnny's"]), render_string(%q(It's 'Johnny\\'s' phone), :attributes => {'compat-mode' => ''}) - assert_xpath %(//p[text()="It's 'Johnny's' phone"]), render_string(%q(It\\'s 'Johnny\\'s' phone)) + assert_xpath %(//em[text()="Johnny's"]), convert_string(%q(It's 'Johnny\\'s' phone), :attributes => {'compat-mode' => ''}) + assert_xpath %(//p[text()="It's 'Johnny's' phone"]), convert_string(%q(It\\'s 'Johnny\\'s' phone)) end test "escaped single quote is restored as single quote" do - assert_xpath "//p[contains(text(), \"Let's do it!\")]", render_string("Let\\'s do it!") + assert_xpath "//p[contains(text(), \"Let's do it!\")]", convert_string("Let\\'s do it!") end test 'unescape escaped single quote emphasis in compat mode only' do - assert_xpath %(//p[text()="A 'single quoted string' example"]), render_embedded_string(%(A \\'single quoted string' example), :attributes => {'compat-mode' => ''}) - assert_xpath %(//p[text()="'single quoted string'"]), render_embedded_string(%(\\'single quoted string'), :attributes => {'compat-mode' => ''}) + assert_xpath %(//p[text()="A 'single quoted string' example"]), convert_string_to_embedded(%(A \\'single quoted string' example), :attributes => {'compat-mode' => ''}) + assert_xpath %(//p[text()="'single quoted string'"]), convert_string_to_embedded(%(\\'single quoted string'), :attributes => {'compat-mode' => ''}) - assert_xpath %(//p[text()="A \\'single quoted string' example"]), render_embedded_string(%(A \\'single quoted string' example)) - assert_xpath %(//p[text()="\\'single quoted string'"]), render_embedded_string(%(\\'single quoted string')) + assert_xpath %(//p[text()="A \\'single quoted string' example"]), convert_string_to_embedded(%(A \\'single quoted string' example)) + assert_xpath %(//p[text()="\\'single quoted string'"]), convert_string_to_embedded(%(\\'single quoted string')) end test "emphasized text at end of line" do - assert_xpath "//em", render_string("This library is _awesome_") + assert_xpath "//em", convert_string("This library is _awesome_") end test "emphasized text at beginning of line" do - assert_xpath "//em", render_string("_drop_ it") + assert_xpath "//em", convert_string("_drop_ it") end test "emphasized text across line" do - assert_xpath "//em", render_string("_check it_") + assert_xpath "//em", convert_string("_check it_") end test "unquoted text" do - refute_match(/#/, render_string("An #unquoted# word")) + refute_match(/#/, convert_string("An #unquoted# word")) end test 'backticks and straight quotes in text' do backslash = '\\' - assert_equal %q(run <code>foo</code> <em>dog</em>), render_embedded_string(%q(run `foo` 'dog'), :doctype => :inline, :attributes => {'compat-mode' => ''}) - assert_equal %q(run <code>foo</code> 'dog'), render_embedded_string(%q(run `foo` 'dog'), :doctype => :inline) - assert_equal %q(run `foo` 'dog'), render_embedded_string(%(run #{backslash}`foo` 'dog'), :doctype => :inline) - assert_equal %q(run &#8216;foo` 'dog&#8217;), render_embedded_string(%q(run '`foo` 'dog`'), :doctype => :inline) - assert_equal %q(run '`foo` 'dog`'), render_embedded_string(%(run #{backslash}'`foo` 'dog#{backslash}`'), :doctype => :inline) + assert_equal %q(run <code>foo</code> <em>dog</em>), convert_inline_string(%q(run `foo` 'dog'), :attributes => {'compat-mode' => ''}) + assert_equal %q(run <code>foo</code> 'dog'), convert_inline_string(%q(run `foo` 'dog')) + assert_equal %q(run `foo` 'dog'), convert_inline_string(%(run #{backslash}`foo` 'dog')) + assert_equal %q(run &#8216;foo` 'dog&#8217;), convert_inline_string(%q(run '`foo` 'dog`')) + assert_equal %q(run '`foo` 'dog`'), convert_inline_string(%(run #{backslash}'`foo` 'dog#{backslash}`')) end test 'plus characters inside single plus passthrough' do - assert_xpath '//p[text()="+"]', render_embedded_string('+++') - assert_xpath '//p[text()="+="]', render_embedded_string('++=+') + assert_xpath '//p[text()="+"]', convert_string_to_embedded('+++') + assert_xpath '//p[text()="+="]', convert_string_to_embedded('++=+') end test 'plus passthrough escapes entity reference' do - assert_match(/&amp;#44;/, render_embedded_string('+&#44;+')) - assert_match(/one&amp;#44;two/, render_embedded_string('one++&#44;++two')) + assert_match(/&amp;#44;/, convert_string_to_embedded('+&#44;+')) + assert_match(/one&amp;#44;two/, convert_string_to_embedded('one++&#44;++two')) end context "basic styling" do setup do - @rendered = render_string("A *BOLD* word. An _italic_ word. A `mono` word. ^superscript!^ and some ~subscript~.") + @output = convert_string("A *BOLD* word. An _italic_ word. A `mono` word. ^superscript!^ and some ~subscript~.") end test "strong" do - assert_xpath "//strong", @rendered, 1 + assert_xpath "//strong", @output, 1 end test "italic" do - assert_xpath "//em", @rendered, 1 + assert_xpath "//em", @output, 1 end test "monospaced" do - assert_xpath "//code", @rendered, 1 + assert_xpath "//code", @output, 1 end test "superscript" do - assert_xpath "//sup", @rendered, 1 + assert_xpath "//sup", @output, 1 end test "subscript" do - assert_xpath "//sub", @rendered, 1 + assert_xpath "//sub", @output, 1 end test "passthrough" do - assert_xpath "//code", render_string("This is +passed through+."), 0 - assert_xpath "//code", render_string("This is +passed through and monospaced+.", :attributes => {'compat-mode' => ''}), 1 + assert_xpath "//code", convert_string("This is +passed through+."), 0 + assert_xpath "//code", convert_string("This is +passed through and monospaced+.", :attributes => {'compat-mode' => ''}), 1 end test "nested styles" do - rendered = render_string("Winning *big _time_* in the +city *boyeeee*+.", :attributes => {'compat-mode' => ''}) + output = convert_string("Winning *big _time_* in the +city *boyeeee*+.", :attributes => {'compat-mode' => ''}) - assert_xpath "//strong/em", rendered - assert_xpath "//code/strong", rendered + assert_xpath "//strong/em", output + assert_xpath "//code/strong", output - rendered = render_string("Winning *big _time_* in the `city *boyeeee*`.") + output = convert_string("Winning *big _time_* in the `city *boyeeee*`.") - assert_xpath "//strong/em", rendered - assert_xpath "//code/strong", rendered + assert_xpath "//strong/em", output + assert_xpath "//code/strong", output end test 'unconstrained quotes' do - rendered_chars = render_string('**B**__I__++M++[role]++M++', :attributes => {'compat-mode' => ''}) - assert_xpath '//strong', rendered_chars, 1 - assert_xpath '//em', rendered_chars, 1 - assert_xpath '//code[not(@class)]', rendered_chars, 1 - assert_xpath '//code[@class="role"]', rendered_chars, 1 + output = convert_string('**B**__I__++M++[role]++M++', :attributes => {'compat-mode' => ''}) + assert_xpath '//strong', output, 1 + assert_xpath '//em', output, 1 + assert_xpath '//code[not(@class)]', output, 1 + assert_xpath '//code[@class="role"]', output, 1 - rendered_chars = render_string('**B**__I__``M``[role]``M``') - assert_xpath '//strong', rendered_chars, 1 - assert_xpath '//em', rendered_chars, 1 - assert_xpath '//code[not(@class)]', rendered_chars, 1 - assert_xpath '//code[@class="role"]', rendered_chars, 1 + output = convert_string('**B**__I__``M``[role]``M``') + assert_xpath '//strong', output, 1 + assert_xpath '//em', output, 1 + assert_xpath '//code[not(@class)]', output, 1 + assert_xpath '//code[@class="role"]', output, 1 end end test 'should format Asian characters as words' do - assert_xpath '//strong', (render_embedded_string 'bold *要* bold') - assert_xpath '//strong', (render_embedded_string 'bold *素* bold') - assert_xpath '//strong', (render_embedded_string 'bold *要素* bold') + assert_xpath '//strong', (convert_string_to_embedded 'bold *要* bold') + assert_xpath '//strong', (convert_string_to_embedded 'bold *素* bold') + assert_xpath '//strong', (convert_string_to_embedded 'bold *要素* bold') end end