diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-03-08 19:32:31 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-03-31 19:19:46 -0300 |
commit | 651f3b51df11e6be6ab85dd793ec6eb91d1ddf57 (patch) | |
tree | 504c8b9120c329ce44c052b878eaff97bcbd1514 | |
parent | eb08810727e3a3cba6e9947869d45d92173d196d (diff) |
replacer: use pedantic external link matching
-rw-r--r-- | src/util/replacer.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/util/replacer.js b/src/util/replacer.js index 4bd99988..d1b0a269 100644 --- a/src/util/replacer.js +++ b/src/util/replacer.js @@ -613,9 +613,16 @@ export function postprocessExternalLinks(inputNodes) { while (plausibleMatch = plausibleLinkRegexp.exec(node.data)) { textContent += node.data.slice(parseFrom, plausibleMatch.index); + // Pedantic rules use more particular parentheses detection in link + // destinations - they allow one level of balanced parentheses, and + // otherwise, parentheses must be escaped. This allows for entire links + // to be wrapped in parentheses, e.g below: + // + // This is so cool. ([You know??](https://example.com)) + // const definiteMatch = - marked.Lexer.rules.inline.link.exec( - node.data.slice(plausibleMatch.index)); + marked.Lexer.rules.inline.pedantic.link + .exec(node.data.slice(plausibleMatch.index)); if (definiteMatch) { const {1: label, 2: href} = definiteMatch; |