Skip to content

Commit 1da8fb5

Browse files
sanki92UziTech
andauthored
fix: resolve even-numbered backtick precedence issue (#3776) (#3786)
Co-authored-by: Tony Brix <[email protected]>
1 parent 28528ff commit 1da8fb5

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/rules.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ const _punctuationOrSpaceGfmStrongEm = /(?!~)[\s\p{P}\p{S}]/u;
267267
const _notPunctuationOrSpaceGfmStrongEm = /(?:[^\s\p{P}\p{S}]|~)/u;
268268

269269
// sequences em should skip over [title](link), `code`, <html>
270-
const blockSkip = /\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g;
270+
const blockSkip = edit(/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|codePattern|<(?! )[^<>]*?>/, 'g')
271+
.replace('codePattern', /(?<!`)(`+)[^`]+\1(?!`)/)
272+
.getRegex();
271273

272274
const emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
273275

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<p>**You might think this should be bold, but: <code>**</code></p>
2+
<p>**You might think this should be bold, but: <code>**</code></p>
3+
<p>**You might think this should be bold, but: <code>**</code></p>
4+
<p>**You might think this should be bold, but: <code>**</code></p>
5+
<p><strong>This should be bold</strong> and <code>this should be code</code></p>
6+
<p><strong>start <code>contains **</code> end</strong></p>
7+
<p><strong>This should be bold ``</strong>`</p>
8+
<p><strong>This should be bold `</strong>``</p>
9+
<p><strong>start <code>contains **</code> end</strong></p>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
**You might think this should be bold, but: `**`
2+
3+
**You might think this should be bold, but: ``**``
4+
5+
**You might think this should be bold, but: ```**```
6+
7+
**You might think this should be bold, but: ````**````
8+
9+
**This should be bold** and `this should be code`
10+
11+
**start `contains **` end**
12+
13+
**This should be bold ``**`
14+
15+
**This should be bold `**``
16+
17+
**start ``contains **`` end**

0 commit comments

Comments
 (0)