« get me outta code hell

replacer: use pedantic external link matching - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
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
commit651f3b51df11e6be6ab85dd793ec6eb91d1ddf57 (patch)
tree504c8b9120c329ce44c052b878eaff97bcbd1514 /src
parenteb08810727e3a3cba6e9947869d45d92173d196d (diff)
replacer: use pedantic external link matching
Diffstat (limited to 'src')
-rw-r--r--src/util/replacer.js11
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;