From cbff5242d1442ab5c2d6034d0ed06159cbd049c1 Mon Sep 17 00:00:00 2001 From: wallpants <47203170+wallpants@users.noreply.github.com> Date: Mon, 6 Nov 2023 03:16:07 -0600 Subject: [PATCH] fix(marked): fix emstrong unicode https://github.com/markedjs/marked/pull/3070 re #63 --- src/tokenizer.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tokenizer.ts b/src/tokenizer.ts index 4f93a03..cc2f55c 100644 --- a/src/tokenizer.ts +++ b/src/tokenizer.ts @@ -725,7 +725,7 @@ export class Tokenizer { endReg.lastIndex = 0; // Clip maskedSrc to same section of string as src (move to lexer?) - maskedSrc = maskedSrc.slice(-1 * src.length + match[0].length - 1); + maskedSrc = maskedSrc.slice(-1 * src.length + lLength); while ((match = endReg.exec(maskedSrc)) != null) { // eslint-disable-next-line @@ -755,8 +755,9 @@ export class Tokenizer { // Remove extra characters. *a*** -> *a* rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal); - - const raw = [...src].slice(0, lLength + match.index + rLength + 1).join(""); + // char length can be >1 for unicode characters; + const lastCharLength = [...match[0]]![0]!.length; + const raw = src.slice(0, lLength + match.index + lastCharLength + rLength); // Create `em` if smallest delimiter has odd char count. *a*** if (Math.min(lLength, rLength) % 2) {