diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2017-07-22 03:07:29 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2017-07-22 03:08:29 -0600 |
| commit | ee1f18ba1934613f267a6503bfa5ea51c67484b5 (patch) | |
| tree | a03fc68926f3bcd65350f453c3da44a6fac5d9e2 | |
| parent | fb51f83f2d85f5d64271ead3d1fb8b69c56014fe (diff) | |
remove unnecessary nil_or_empty? checks in Substitutor; add missing test
| -rw-r--r-- | lib/asciidoctor/substitutors.rb | 8 | ||||
| -rw-r--r-- | test/text_test.rb | 22 |
2 files changed, 16 insertions, 14 deletions
diff --git a/lib/asciidoctor/substitutors.rb b/lib/asciidoctor/substitutors.rb index 39776305..f7fc6fb6 100644 --- a/lib/asciidoctor/substitutors.rb +++ b/lib/asciidoctor/substitutors.rb @@ -192,9 +192,9 @@ module Substitutors if (boundary = m[4]) # $$, ++, or +++ # skip ++ in compat mode, handled as normal quoted text if compat_mode && boundary == '++' - next m[2].nil_or_empty? ? - %(#{m[1]}#{m[3]}++#{extract_passthroughs m[5]}++) : - %(#{m[1]}[#{m[2]}]#{m[3]}++#{extract_passthroughs m[5]}++) + next m[2] ? + %(#{m[1]}[#{m[2]}]#{m[3]}++#{extract_passthroughs m[5]}++) : + %(#{m[1]}#{m[3]}++#{extract_passthroughs m[5]}++) end attributes = m[2] @@ -1098,7 +1098,7 @@ module Substitutors # Returns The converted String text for the quoted text region def convert_quoted_text(match, type, scope) if match[0].start_with? RS - if scope == :constrained && !(attrs = match[2]).nil_or_empty? + if scope == :constrained && (attrs = match[2]) unescaped_attrs = %([#{attrs}]) else return match[0][1..-1] diff --git a/test/text_test.rb b/test/text_test.rb index e03f2b18..5774c97f 100644 --- a/test/text_test.rb +++ b/test/text_test.rb @@ -286,16 +286,18 @@ This line is separated by something that is not a horizontal rule... assert_xpath "//code/strong", rendered end - test "unconstrained quotes" do - rendered_chars = render_string("**B**__I__++M++", :attributes => {'compat-mode' => ''}) - assert_xpath "//strong", rendered_chars - assert_xpath "//em", rendered_chars - assert_xpath "//code", rendered_chars - - rendered_chars = render_string("**B**__I__``M``") - assert_xpath "//strong", rendered_chars - assert_xpath "//em", rendered_chars - assert_xpath "//code", rendered_chars + 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 + + 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 end end |
