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

#️⃣ Hash emoji causes errors in title. #6260

Open
5 of 7 tasks
PatelN123 opened this issue Jan 4, 2022 · 2 comments
Open
5 of 7 tasks

#️⃣ Hash emoji causes errors in title. #6260

PatelN123 opened this issue Jan 4, 2022 · 2 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution domain: markdown Related to Markdown parsing or syntax

Comments

@PatelN123
Copy link
Contributor

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

The #️⃣ emoji causes errors.
When using the hash emoji as a title (# #️⃣ text) in a page at the beginning, it uses the ID of the page as the title instead.

Steps to reproduce

  1. Create a new docusaurus page
  2. Set the title to something with the #️⃣
  3. Build the site, the title will be the ID rather than what you specified with the title you specified under it.

Expected behavior

Put the correct title

Actual behavior

Already written ^^

Your environment

Reproducible demo

No response

Self-service

  • I'd be willing to fix this bug myself.
@PatelN123 PatelN123 added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jan 4, 2022
@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Jan 4, 2022
@Josh-Cena
Copy link
Collaborator

Josh-Cena commented Jan 4, 2022

I figured it out. #️⃣ actually includes # as its first character (because emojis are just a sequence of UTF-16 characters).

String.fromCharCode('#️⃣'.charCodeAt(0))
// << '#'
/#/.test('#️⃣')
// << true

Therefore, our title-parsing regex actually sees:

/(?<pattern>#\s*(?<title>[^#\n{]*)+[ \t]*(?<suffix>({#*[\w-]+})|#)?\n*?)/.exec('# #️⃣ Support')

// << (5) ['# #', '# #', '', '#', undefined, index: 0, input: '# #️⃣ Support', groups: {pattern: '# #', title: '', suffix: '#'}]

This would, once again, be solved once we use Remark for Markdown parsing. ref #5659.

@PatelN123
Copy link
Contributor Author

Ah yes!
I did think this would be the cause but I didn't know how to explain it.

Thanks!

@Josh-Cena Josh-Cena added the domain: markdown Related to Markdown parsing or syntax label Mar 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution domain: markdown Related to Markdown parsing or syntax
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants