From e3c0d3e208c80daca2c9fbb68f125f060cd30fc3 Mon Sep 17 00:00:00 2001 From: Lakshyajeet Singh Goyal <74810454+DarkMatter-999@users.noreply.github.com> Date: Tue, 7 Oct 2025 08:49:22 +0530 Subject: [PATCH] fix: fix links with square brackets in inline code break wrapping italics (#3785) --- src/rules.ts | 2 +- test/specs/new/em_link_brackets.html | 1 + test/specs/new/em_link_brackets.md | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 test/specs/new/em_link_brackets.html create mode 100644 test/specs/new/em_link_brackets.md diff --git a/src/rules.ts b/src/rules.ts index 36b50062..f05eedc6 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -267,7 +267,7 @@ const _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u; const _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u; // sequences em should skip over [title](link), `code`, -const blockSkip = /\[[^\[\]]*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g; +const blockSkip = /\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g; const emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/; diff --git a/test/specs/new/em_link_brackets.html b/test/specs/new/em_link_brackets.html new file mode 100644 index 00000000..af18d51d --- /dev/null +++ b/test/specs/new/em_link_brackets.html @@ -0,0 +1 @@ +

a[b]c

\ No newline at end of file diff --git a/test/specs/new/em_link_brackets.md b/test/specs/new/em_link_brackets.md new file mode 100644 index 00000000..ed630703 --- /dev/null +++ b/test/specs/new/em_link_brackets.md @@ -0,0 +1 @@ +_[`a[b]c`](http://example.com/_/path)_ \ No newline at end of file