fix: resolve even-numbered backtick precedence issue (#3776) (#3786)

Co-authored-by: Tony Brix <tony@brix.ninja>
This commit is contained in:
Sankalp Tripathi
2025-10-17 01:05:03 -06:00
committed by GitHub
co-authored by Tony Brix
parent 28528ff259
commit 1da8fb5da9
3 changed files with 29 additions and 1 deletions
+3 -1
View File
@@ -267,7 +267,9 @@ const _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
const _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
// sequences em should skip over [title](link), `code`, <html>
const blockSkip = /\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g;
const blockSkip = edit(/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|codePattern|<(?! )[^<>]*?>/, 'g')
.replace('codePattern', /(?<!`)(`+)[^`]+\1(?!`)/)
.getRegex();
const emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
@@ -0,0 +1,9 @@
<p>**You might think this should be bold, but: <code>**</code></p>
<p>**You might think this should be bold, but: <code>**</code></p>
<p>**You might think this should be bold, but: <code>**</code></p>
<p>**You might think this should be bold, but: <code>**</code></p>
<p><strong>This should be bold</strong> and <code>this should be code</code></p>
<p><strong>start <code>contains **</code> end</strong></p>
<p><strong>This should be bold ``</strong>`</p>
<p><strong>This should be bold `</strong>``</p>
<p><strong>start <code>contains **</code> end</strong></p>
@@ -0,0 +1,17 @@
**You might think this should be bold, but: `**`
**You might think this should be bold, but: ``**``
**You might think this should be bold, but: ```**```
**You might think this should be bold, but: ````**````
**This should be bold** and `this should be code`
**start `contains **` end**
**This should be bold ``**`
**This should be bold `**``
**start ``contains **`` end**