summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2023-05-16 23:53:01 -0600
committerDan Allen <dan.j.allen@gmail.com>2023-05-17 17:03:45 -0600
commit62749721b795140ca19b63ac0af5a0d8233e6f44 (patch)
treed7daa8d42cbe965cfb673fe92dc7993ac33b56ff
parent76ea8d84ab3c1ed2247d1cb495e0675f7b741bd8 (diff)
only match transitional role (x-) that this distinct from other roles
-rw-r--r--lib/asciidoctor/substitutors.rb14
-rw-r--r--test/substitutions_test.rb6
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/asciidoctor/substitutors.rb b/lib/asciidoctor/substitutors.rb
index c0faf636..74f6086c 100644
--- a/lib/asciidoctor/substitutors.rb
+++ b/lib/asciidoctor/substitutors.rb
@@ -1019,11 +1019,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
@@ -1065,7 +1071,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 7e3bb1ca..26c58fac 100644
--- a/test/substitutions_test.rb
+++ b/test/substitutions_test.rb
@@ -334,6 +334,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)