Repository navigation
fix(mdx-loader): parse markdown.mdx1Compat comments to AST so explicit heading IDs are recognized - #12928
Draft
Aryan9891 wants to merge 1 commit into
Draft
fix(mdx-loader): parse markdown.mdx1Compat comments to AST so explicit heading IDs are recognized#12928Aryan9891 wants to merge 1 commit into
Aryan9891 wants to merge 1 commit into
Conversation
…mments (meta#12927) Signed-off-by: Aryan Sachin <aryansachinixd@gmail.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Aryan9891
added a commit
to Aryan9891/Aryan9891
that referenced
this pull request
Nov 7, 2026
Signed-off-by: Aryan Sachin <aryansachinixd@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-flight checklist
Motivation
Fixes #12927.
When
markdown.mdx1Compat.comments: trueis configured indocusaurus.config.js, standard HTML comment syntax (<!-- #my-id -->) in Markdown headings was failing to extract explicit heading IDs:processor.ts,remarkCommentwas loaded without{ ast: true }, leaving comment nodes as unparsed raw text rather than structured AST comment nodes.packages/docusaurus-mdx-loader/src/remark/headings/index.ts,getHeadingIdonly inspectedlastChild.type === 'mdxJsxTextElement'. When MDX1 comment compatibility is enabled, comments are represented as AST nodes withtype: 'comment'.getHeadingText,commentnodes were not excluded, which could allow comment syntax to leak into heading titles and table of contents.This PR:
{ ast: true }toremarkCommentinprocessor.tswhenmdx1Compat.commentsis enabled.headings/index.tsto recognizelastChild.type === 'comment'and extract explicit#idcomments fromlastChild.value.getHeadingTextfilters outnode.type === 'comment'so the heading title string remains clean.headings/__tests__/index.test.tscovering explicit#idHTML comments, non-id comments, and clean heading title extraction with MDX1 comment compatibility enabled.Test Plan
Local unit test verification:
``bash
npx vitest run packages/docusaurus-mdx-loader/src/remark/headings/tests/index.test.ts
Result: 33/33 tests passed
``
Test links
Deploy preview: https://deploy-preview-12928--docusaurus-2.netlify.app/
Related issues/PRs
Closes #12927