Skip to content

docs: add note about escaping heading IDs#11783

Open
mitre88 wants to merge 1 commit intofacebook:mainfrom
mitre88:docs/add-note-escaping-heading-ids
Open

docs: add note about escaping heading IDs#11783
mitre88 wants to merge 1 commit intofacebook:mainfrom
mitre88:docs/add-note-escaping-heading-ids

Conversation

@mitre88
Copy link

@mitre88 mitre88 commented Mar 6, 2026

Motivation

Closes #9725

As mentioned in this comment, it's possible to escape the {#id} heading ID syntax using a backslash, but this isn't documented anywhere.

Changes

Added a tip admonition in the Heading IDs section of the TOC docs page explaining that users can escape {#..} sequences with a backslash when they want the text to be rendered literally.

Test Plan

The change is documentation-only (no code changes).

Add a tip explaining how to escape the {#id} syntax in heading text using a backslash, so it is rendered literally instead of being interpreted as a custom heading ID.

Closes facebook#9725
@meta-cla
Copy link

meta-cla bot commented Mar 6, 2026

Hi @mitre88!

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

netlify bot commented Mar 6, 2026

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 6670950
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/69aae2f8bb216800082b4a6e
😎 Deploy Preview https://deploy-preview-11783--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.

Copy link
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, ok to document this but not in a new tip blog, this should be part of the warning just above


:::

:::tip Escaping heading IDs
Copy link
Collaborator

Choose a reason for hiding this comment

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

Work in underway regarding heading ids, see recent PRs

As the warning above says, you should avoid this syntax with MDX now.

In practice, the markdown.mdx1Compat.headingIds option automatically escapes, so my proposal would be to update the warning above to mention manual escaping is also possible

It is only supported in Docusaurus for backward compatibility, thanks to the markdown.mdx1Compat.headingIds config option, or by manually escaping the JSX expression: \{#id}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add note about escaping header ids

2 participants