Skip to content

Commit

Permalink
fix: fix emstrong unicode (#3070)
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Nov 2, 2023
1 parent 77ca546 commit 54b6d1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Tokenizer.ts
Expand Up @@ -629,7 +629,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) {
rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
Expand All @@ -654,8 +654,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
2 changes: 2 additions & 0 deletions test/specs/new/emoji_inline.html
Expand Up @@ -18,3 +18,5 @@
<p><strong>⚠️ test</strong></p>
<p>Here, the emoji rendering works, but the text doesn't get rendered in italic.</p>
<p><em>💁 test</em></p>
<p><em>t💁t</em> test</p>
<p><strong>t💁t</strong> test</p>
4 changes: 4 additions & 0 deletions test/specs/new/emoji_inline.md
Expand Up @@ -37,3 +37,7 @@ Situations where it works:
Here, the emoji rendering works, but the text doesn't get rendered in italic.

*💁 test*

*t💁t* test

**t💁t** test

1 comment on commit 54b6d1c

@vercel
Copy link

@vercel vercel bot commented on 54b6d1c Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.