Skip to content

Commit 721dc58

Browse files
authored
fix: fix emstrong inside escaped backticks (#3652)
* fix: fix emstrong inside escaped backticks * add tests * lint
1 parent 1ac6bc1 commit 721dc58

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

src/Lexer.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,16 +312,17 @@ export class _Lexer {
312312
}
313313
}
314314
}
315-
// Mask out other blocks
316-
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
317-
maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
318-
}
319315

320316
// Mask out escaped characters
321317
while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
322318
maskedSrc = maskedSrc.slice(0, match.index) + '++' + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
323319
}
324320

321+
// Mask out other blocks
322+
while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
323+
maskedSrc = maskedSrc.slice(0, match.index) + '[' + 'a'.repeat(match[0].length - 2) + ']' + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
324+
}
325+
325326
let keepPrevChar = false;
326327
let prevChar = '';
327328
while (src) {

test/specs/new/escape_tick.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<p><em>italics</em></p>
2+
<p><strong>bold</strong></p>
3+
<p><em><strong>bold italics</strong></em></p>
4+
<p><code>*quoted italics*</code></p>
5+
<p><code>**quoted bold**</code></p>
6+
<p><code>***quoted bold italics***</code></p>
7+
<p>`<em>escaped quoted italics</em>`</p>
8+
<p>`<strong>escaped quoted bold</strong>`</p>
9+
<p>`<em><strong>escaped quoted bold italics</strong></em>`</p>

test/specs/new/escape_tick.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
*italics*
2+
3+
**bold**
4+
5+
***bold italics***
6+
7+
`*quoted italics*`
8+
9+
`**quoted bold**`
10+
11+
`***quoted bold italics***`
12+
13+
\`*escaped quoted italics*\`
14+
15+
\`**escaped quoted bold**\`
16+
17+
\`***escaped quoted bold italics***\`

0 commit comments

Comments
 (0)