summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2023-04-25 00:34:30 -0600
committerDan Allen <dan.j.allen@gmail.com>2023-04-25 01:39:30 -0600
commit384ccd8492a02b0bb7c56d1e18967c79f63db466 (patch)
treee8a34a7047d3726241c4cd3545deb4c44b37d592 /lib
parentb3a03af9fea232f4112e8af9d39e23ba84ec1a59 (diff)
slightly simplify implicit link processing by separating implicit and explicit match
Diffstat (limited to 'lib')
-rw-r--r--lib/asciidoctor/rx.rb4
-rw-r--r--lib/asciidoctor/substitutors.rb12
2 files changed, 4 insertions, 12 deletions
diff --git a/lib/asciidoctor/rx.rb b/lib/asciidoctor/rx.rb
index b81b0f56..39fb0fd3 100644
--- a/lib/asciidoctor/rx.rb
+++ b/lib/asciidoctor/rx.rb
@@ -517,9 +517,9 @@ module Asciidoctor
# <https://github.com>
# link:https://github.com[]
# "https://github.com[]"
+ # (https://github.com) <= parenthesis not included in autolink
#
- # FIXME revisit! the main issue is we need different rules for implicit vs explicit
- InlineLinkRx = %r((^|link:|#{CG_BLANK}|&lt;|[>\(\)\[\];"'])(\\?(?:https?|file|ftp|irc)://[^\s\[\]<]*([^\s.,\[\]<]))(?:\[(|#{CC_ALL}*?[^\\])\])?)m
+ InlineLinkRx = %r((^|link:|#{CG_BLANK}|&lt;|[>\(\)\[\];"'])(\\?(?:https?|file|ftp|irc)://)(?:([^\s\[\]]+)\[(|#{CC_ALL}*?[^\\])\]|([^\s\[\]<]*([^\s,.?!\[\]<\)]))))m
# Match a link or e-mail inline macro.
#
diff --git a/lib/asciidoctor/substitutors.rb b/lib/asciidoctor/substitutors.rb
index 49f0a092..8ae6b92c 100644
--- a/lib/asciidoctor/substitutors.rb
+++ b/lib/asciidoctor/substitutors.rb
@@ -527,7 +527,7 @@ module Substitutors
if found_colon && (text.include? '://')
# inline urls, target[text] (optionally prefixed with link: and optionally surrounded by <>)
text = text.gsub InlineLinkRx do
- if (target = $2).start_with? RS
+ if (target = $2 + ($3 || $5)).start_with? RS
# honor the escape
next ($&.slice 0, (rs_idx = $1.length)) + ($&.slice rs_idx + 1, $&.length)
end
@@ -544,15 +544,7 @@ module Substitutors
when 'link:', ?", ?'
next $&
end
- case $3
- when ')', '?', '!'
- target = target.chop
- if (suffix = $3) == ')' && (target.end_with? '.', '?', '!')
- suffix = target[-1] + suffix
- target = target.chop
- end
- # NOTE handle case when modified target is a URI scheme (e.g., http://)
- next $& if target.end_with? '://'
+ case $6
when ';'
if (prefix.start_with? '&lt;') && (target.end_with? '&gt;')
# move surrounding <> out of URL