Skip to content

Commit

Permalink
fix(marked): fix emstrong unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
wallpants committed Nov 6, 2023
1 parent 60817c5 commit cbff524
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/tokenizer.ts
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit cbff524

Please sign in to comment.