Skip to content

Commit

Permalink
don't swallow square brackets when processing escaped URL macro
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Apr 25, 2023
1 parent 36b4d18 commit b3a03af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Bug Fixes::
* Manify alt text of block image in manpage output (#4401)
* Adjust font size of term in horizontal dlist to match font size of term in regular dlist
* Implicitly attach nested list that starts with block attribute lines to dlist entry (#4268)
* Don't swallow square brackets when processing escaped URL macro

== 2.0.18 (2022-10-15) - @mojavelinux

Expand Down
2 changes: 1 addition & 1 deletion lib/asciidoctor/substitutors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def sub_macros text
text = text.gsub InlineLinkRx do
if (target = $2).start_with? RS
# honor the escape
next %(#{$1}#{target.slice 1, target.length}#{$4})
next ($&.slice 0, (rs_idx = $1.length)) + ($&.slice rs_idx + 1, $&.length)
end

prefix, suffix = $1, ''
Expand Down
6 changes: 6 additions & 0 deletions test/links_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@
assert_xpath '//a', convert_string('\http://asciidoc.org is the project page for AsciiDoc.'), 0
end

test 'escaped inline qualified url as macro should not create link' do
output = convert_string '\http://asciidoc.org[asciidoc.org] is the project page for AsciiDoc.'
assert_xpath '//a', output, 0
assert_xpath '//p[starts-with(text(), "http://asciidoc.org[asciidoc.org]")]', output, 1
end

test 'url in link macro with at (@) sign should not create mailto link' do
assert_xpath '//a[@href="http://xircles.codehaus.org/lists/dev@geb.codehaus.org"][text()="subscribe"]', convert_string('http://xircles.codehaus.org/lists/dev@geb.codehaus.org[subscribe]')
end
Expand Down

0 comments on commit b3a03af

Please sign in to comment.