Skip to content

Commit cbff524

Browse files
committed
fix(marked): fix emstrong unicode
markedjs/marked#3070 re #63
1 parent 60817c5 commit cbff524

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/tokenizer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ export class Tokenizer {
725725
endReg.lastIndex = 0;
726726

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

730730
while ((match = endReg.exec(maskedSrc)) != null) {
731731
// eslint-disable-next-line
@@ -755,8 +755,9 @@ export class Tokenizer {
755755

756756
// Remove extra characters. *a*** -> *a*
757757
rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
758-
759-
const raw = [...src].slice(0, lLength + match.index + rLength + 1).join("");
758+
// char length can be >1 for unicode characters;
759+
const lastCharLength = [...match[0]]![0]!.length;
760+
const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
760761

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

0 commit comments

Comments
 (0)