Skip to content

Commit 54b6d1c

Browse files
authored
fix: fix emstrong unicode (#3070)
1 parent 77ca546 commit 54b6d1c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/Tokenizer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ export class _Tokenizer {
629629
endReg.lastIndex = 0;
630630

631631
// Clip maskedSrc to same section of string as src (move to lexer?)
632-
maskedSrc = maskedSrc.slice(-1 * src.length + match[0].length - 1);
632+
maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
633633

634634
while ((match = endReg.exec(maskedSrc)) != null) {
635635
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
@@ -654,8 +654,9 @@ export class _Tokenizer {
654654

655655
// Remove extra characters. *a*** -> *a*
656656
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
657-
658-
const raw = [...src].slice(0, lLength + match.index + rLength + 1).join('');
657+
// char length can be >1 for unicode characters;
658+
const lastCharLength = [...match[0]][0].length;
659+
const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
659660

660661
// Create `em` if smallest delimiter has odd char count. *a***
661662
if (Math.min(lLength, rLength) % 2) {

test/specs/new/emoji_inline.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818
<p><strong>⚠️ test</strong></p>
1919
<p>Here, the emoji rendering works, but the text doesn't get rendered in italic.</p>
2020
<p><em>💁 test</em></p>
21+
<p><em>t💁t</em> test</p>
22+
<p><strong>t💁t</strong> test</p>

test/specs/new/emoji_inline.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ Situations where it works:
3737
Here, the emoji rendering works, but the text doesn't get rendered in italic.
3838

3939
*💁 test*
40+
41+
*t💁t* test
42+
43+
**t💁t** test

0 commit comments

Comments
 (0)