Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(marked): fix emstrong unicode #66

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/tokenizer.ts
Original file line number Diff line number Diff line change
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