diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2023-05-16 23:53:01 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2023-05-17 00:33:14 -0600 |
| commit | f717cc76330eedfc627995437409ab2e8385cefa (patch) | |
| tree | 6602b59a0abee73d07d0775f5b50a58f0a9548b4 | |
| parent | 5b9f1225a68ba983f2486cd5be8fb47a7dc15570 (diff) | |
only match transitional role (x-) that this distinct from other roles
| -rw-r--r-- | lib/asciidoctor/substitutors.rb | 14 | ||||
| -rw-r--r-- | test/substitutions_test.rb | 6 |
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/asciidoctor/substitutors.rb b/lib/asciidoctor/substitutors.rb index 2fc5f9d9..af850790 100644 --- a/lib/asciidoctor/substitutors.rb +++ b/lib/asciidoctor/substitutors.rb @@ -1020,11 +1020,17 @@ module Substitutors next %(#{$1}[#{attrlist}]#{RS * (escape_count - 1)}#{boundary}#{$5}#{boundary}) elsif $1 == RS preceding = %([#{attrlist}]) - else - if boundary == '++' && (attrlist.end_with? 'x-') + elsif boundary == '++' + if attrlist == 'x-' + old_behavior = true + attributes = {} + elsif attrlist.end_with? ' x-' old_behavior = true - attrlist = attrlist.slice 0, attrlist.length - 2 + attributes = parse_quoted_text_attributes attrlist.slice 0, attrlist.length - 3 + else + attributes = parse_quoted_text_attributes attrlist end + else attributes = parse_quoted_text_attributes attrlist end elsif (escape_count = $3.length) > 0 @@ -1066,7 +1072,7 @@ module Substitutors if compat_mode old_behavior = true - elsif attrlist && (attrlist.end_with? 'x-') + elsif attrlist && (attrlist == 'x-' || (attrlist.end_with? ' x-')) old_behavior = old_behavior_forced = true end diff --git a/test/substitutions_test.rb b/test/substitutions_test.rb index 47a7bf6c..7b57c6d8 100644 --- a/test/substitutions_test.rb +++ b/test/substitutions_test.rb @@ -345,6 +345,12 @@ context 'Substitutions' do end # NOTE must use apply_subs because constrained monospaced is handled as a passthrough + test 'should ignore role that ends with transitional role on constrained monospace span' do + para = block_from_string %([foox-]`leave it alone`) + assert_equal '<code class="foox-">leave it alone</code>', para.apply_subs(para.source) + end + + # NOTE must use apply_subs because constrained monospaced is handled as a passthrough test 'escaped single-line constrained monospace string with forced compat role' do para = block_from_string %([x-]#{BACKSLASH}`leave it alone`) assert_equal '[x-]`leave it alone`', para.apply_subs(para.source) |
