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))_