From 651f3b51df11e6be6ab85dd793ec6eb91d1ddf57 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 8 Mar 2024 19:32:31 -0400 Subject: replacer: use pedantic external link matching --- src/util/replacer.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') 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; -- cgit 1.3.0-6-gf8a5