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: fix emstrong unicode #3070

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 2 additions & 3 deletions src/Tokenizer.ts
Original file line number Diff line number Diff line change
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,7 @@ 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('');
const raw = src.slice(0, lLength + match.index + rLength + [...match[0]][0].length);
Copy link
Member

Choose a reason for hiding this comment

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

Is the spread necessary here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that is so unicode character length is calculated correctly.

Copy link
Member

Choose a reason for hiding this comment

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

It might be good to add a comment here since it’s not obvious


// 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading