Skip to content
Merged
4 changes: 3 additions & 1 deletion src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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_]))/;

Expand Down
9 changes: 9 additions & 0 deletions test/specs/new/issue_3776_backtick_precedence.html
Original file line number Diff line number Diff line change
@@ -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>
17 changes: 17 additions & 0 deletions test/specs/new/issue_3776_backtick_precedence.md
Original file line number Diff line number Diff line change
@@ -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**