fix: fix emstrong inside escaped backticks (#3652)

* fix: fix emstrong inside escaped backticks

* add tests

* lint
This commit is contained in:
Tony Brix 2025-04-07 09:02:11 -06:00 committed by GitHub
parent 1ac6bc1f83
commit 721dc58ceb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 4 deletions

View File

@ -312,16 +312,17 @@ export class _Lexer {
}
}
}
// Mask out other blocks
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
}
// Mask out escaped characters
while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
}
// Mask out other blocks
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
}
let keepPrevChar = false;
let prevChar = '';
while (src) {

View File

@ -0,0 +1,9 @@
<p><em>italics</em></p>
<p><strong>bold</strong></p>
<p><em><strong>bold italics</strong></em></p>
<p><code>*quoted italics*</code></p>
<p><code>**quoted bold**</code></p>
<p><code>***quoted bold italics***</code></p>
<p>`<em>escaped quoted italics</em>`</p>
<p>`<strong>escaped quoted bold</strong>`</p>
<p>`<em><strong>escaped quoted bold italics</strong></em>`</p>

View File

@ -0,0 +1,17 @@
*italics*
**bold**
***bold italics***
`*quoted italics*`
`**quoted bold**`
`***quoted bold italics***`
\`*escaped quoted italics*\`
\`**escaped quoted bold**\`
\`***escaped quoted bold italics***\`