diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2024-03-15 14:14:03 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2024-03-15 14:14:03 -0600 |
| commit | 603582a1b2230f0180b67e7e2efb79658a5ea015 (patch) | |
| tree | 9dc1976b17dd11f0acc10efce911fc8135c9916e | |
| parent | c2f296bb4faf6d474adcee1f5482f607e141081c (diff) | |
apply workaround to get InlineLinkRx to work as expected in Asciidoctor.js
| -rw-r--r-- | lib/asciidoctor/rx.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/asciidoctor/rx.rb b/lib/asciidoctor/rx.rb index f7293636..5ba6ba1f 100644 --- a/lib/asciidoctor/rx.rb +++ b/lib/asciidoctor/rx.rb @@ -520,7 +520,12 @@ module Asciidoctor # "https://github.com[]" # (https://github.com) <= parenthesis not included in autolink # - InlineLinkRx = %r((^|link:|#{CG_BLANK}|\\?<()|[>\(\)\[\];"'])(\\?(?:https?|file|ftp|irc)://)(?:([^\s\[\]]+)\[(|#{CC_ALL}*?[^\\])\]|\2([^\s]*?)>|([^\s\[\]<]*([^\s,.?!\[\]<\)]))))m + if RUBY_ENGINE == 'opal' + # NOTE In JavaScript, a back reference succeeds if not set; invert the logic to give it a match to refute + InlineLinkRx = %r((^|link:|#{CG_BLANK}|\\?<(?=\\?(?:https?|file|ftp|irc)(:))|[>\(\)\[\];"'])(\\?(?:https?|file|ftp|irc)://)(?:([^\s\[\]]+)\[(|#{CC_ALL}*?[^\\])\]|(?!\2)([^\s]*?)>|([^\s\[\]<]*([^\s,.?!\[\]<\)])))) + else + InlineLinkRx = %r((^|link:|#{CG_BLANK}|\\?<()|[>\(\)\[\];"'])(\\?(?:https?|file|ftp|irc)://)(?:([^\s\[\]]+)\[(|#{CC_ALL}*?[^\\])\]|\2([^\s]*?)>|([^\s\[\]<]*([^\s,.?!\[\]<\)]))))m + end # Match a link or e-mail inline macro. # |
