From 2b7efa8dda034181932c9c3810fef7d73a81eb9b Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Mon, 14 Oct 2024 22:24:34 -0600 Subject: [PATCH] fix: include single nested parens in emStrong link mask (#3475) --- src/rules.ts | 2 +- test/specs/new/underscore_link.html | 1 + test/specs/new/underscore_link.md | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 test/specs/new/underscore_link.html create mode 100644 test/specs/new/underscore_link.md diff --git a/src/rules.ts b/src/rules.ts index 83bc8b3f..0dd0f847 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -175,7 +175,7 @@ const punctuation = edit(/^((?![*_])[\spunctuation])/, 'u') .replace(/punctuation/g, _punctuation).getRegex(); // sequences em should skip over [title](link), `code`, -const blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g; +const blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g; const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, 'u') .replace(/punct/g, _punctuation) diff --git a/test/specs/new/underscore_link.html b/test/specs/new/underscore_link.html new file mode 100644 index 00000000..4efd9520 --- /dev/null +++ b/test/specs/new/underscore_link.html @@ -0,0 +1 @@ +

test

diff --git a/test/specs/new/underscore_link.md b/test/specs/new/underscore_link.md new file mode 100644 index 00000000..ecea167a --- /dev/null +++ b/test/specs/new/underscore_link.md @@ -0,0 +1 @@ +_[test](https://example.com?link=with_(underscore))_