From f717cc76330eedfc627995437409ab2e8385cefa Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Tue, 16 May 2023 23:53:01 -0600 Subject: only match transitional role (x-) that this distinct from other roles --- lib/asciidoctor/substitutors.rb | 14 ++++++++++---- 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 @@ -344,6 +344,12 @@ context 'Substitutions' do assert_equal %(#{BACKSLASH}[input]`a few <monospaced> words`), para.apply_subs(para.source) 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 'leave it alone', 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`) -- cgit v1.2.3