Skip to content

fix(theme-common): fix extractLeadingEmoji() edge case with digits#12072

Open
ian-rehwinkel-lablions wants to merge 2 commits into
facebook:mainfrom
ian-rehwinkel-lablions:doccard-number-fix
Open

fix(theme-common): fix extractLeadingEmoji() edge case with digits#12072
ian-rehwinkel-lablions wants to merge 2 commits into
facebook:mainfrom
ian-rehwinkel-lablions:doccard-number-fix

Conversation

@ian-rehwinkel-lablions
Copy link
Copy Markdown

Pre-flight checklist

Motivation

This fixes this issue.

Test Plan

A simple Unit-Test checks that numbers are no longer recognized as emoji.

@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 27, 2026

Hi @ian-rehwinkel-lablions!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@netlify
Copy link
Copy Markdown

netlify Bot commented May 27, 2026

[V2]

Name Link
🔨 Latest commit fec07e4
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6a1833c6398dc800081341f4
😎 Deploy Preview https://deploy-preview-12072--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@slorber slorber changed the title Fixed numbers being erroneously recognized as emojis fix(theme-common): fix extractLeadingEmoji()edge case with digits May 28, 2026
@slorber slorber changed the title fix(theme-common): fix extractLeadingEmoji()edge case with digits fix(theme-common): fix extractLeadingEmoji() edge case with digits May 28, 2026
@slorber slorber added pr: bug fix This PR fixes a bug in a past release. to backport This PR is planned to be backported to a stable version of Docusaurus labels May 28, 2026
Copy link
Copy Markdown
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM 👍

FYI I replaced your impl with {RGI_Emoji} unicode set, which apparently conveys the intent better, and now has enough browser/server runtime support to be used.


Please sign the CLA: I can't merge PRs without that, and would need to re-recreate one to merge it

});

it('extract emoji digits', () => {
expect(extractLeadingEmoji('1️⃣ Hello World')).toEqual({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I added this extra test case, that was failing with your impl

// Leading grapheme contains an emoji
// Covers flags/ZWJ/skin tones, excludes digits
// See https://github.com/facebook/docusaurus/pull/12072
if (!/^\p{RGI_Emoji}$/v.test(grapheme)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here's a better option, apparently, both our test cases now pass successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: bug fix This PR fixes a bug in a past release. to backport This PR is planned to be backported to a stable version of Docusaurus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DocCard automatically detects digits as emoji, causing weird rendering

2 participants