From 84a17cd0658126ddbde470bc8f9d81b151936c94 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Thu, 3 Oct 2024 00:14:20 -0600 Subject: [PATCH] fix: include single nested parens in emStrong link mask --- 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 83bc8b3f1f..0dd0f84770 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 0000000000..4efd952096 --- /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 0000000000..ecea167a66 --- /dev/null +++ b/test/specs/new/underscore_link.md @@ -0,0 +1 @@ +_[test](https://example.com?link=with_(underscore))_