Skip to content

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

Closed

Description

@PatelN123

Have you read the Contributing Guidelines on issues?

Prerequisites

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.

Activity

  1. added
    bug
    status: needs triage
    on Jan 4, 2022
  2. removed
    status: needs triage
    on Jan 4, 2022
  3. Josh-Cena commented on Jan 4, 2022

    @Josh-Cena
    Collaborator

    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.

  4. PatelN123 commented on Jan 4, 2022

    @PatelN123
    ContributorAuthor

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

    Thanks!

  5. added
    domain: markdown
    on Mar 29, 2022
  6. slorber commented on Oct 16, 2026

    @slorber
    Collaborator

    This is fixed. The keycap emoji #️⃣ starts with an ASCII #, and the old title regex treated it as a closing heading marker. That regex was replaced in #6906 (March 2022).

    Verified on current main with a throwaway docs site:

    • # #️⃣ Support → <title> "#️⃣ Support | Verify 6260", <h1> "#️⃣ Support", sidebar label "#️⃣ Support"
    • # Get #️⃣ help → <title> "Get #️⃣ help | Verify 6260", <h1> "Get #️⃣ help", sidebar label "Get #️⃣ help"
    • front matter title: "#️⃣ Quoted" → <title> "#️⃣ Quoted | Verify 6260", <h1> "#️⃣ Quoted", sidebar label "#️⃣ Quoted"

    parseMarkdownContentTitle before and after #6906:

    before: "# #️⃣ Support" => undefined   (regex matched "# #" with an empty title)
    main:   "# #️⃣ Support" => "#️⃣ Support"
    

    Note for front matter: quote the value (title: "#️⃣ Support"). Unquoted, YAML reads # as the start of a comment, so the title becomes null and the build fails with a validation error.

    (AI-assisted)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdomain: markdown

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions