-
-
Notifications
You must be signed in to change notification settings - Fork 200
refactor(ssg-md): redesign the remarkSplitMdx split logic #2903
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
Conversation
✅ Deploy Preview for rspress-v2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Rsdoctor Bundle Diff AnalysisFound 3 project(s) in monorepo. 📊 Quick Summary (Click to expand)
📋 Detailed Reports (Click to expand)📁 nodePath:
📁 node_mdPath:
📁 webPath:
Generated by Rsdoctor GitHub Action |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refreshes the remarkSplitMdx plugin to improve MDX-to-markdown conversion for LLMs. The key improvement is that users no longer need to manually configure remark and rehype plugins to handle LLM content extraction—the system now automatically preserves MDX content while converting only non-whitelisted TSX components to markdown.
Key Changes
- Refactored
remarkSplitMdxto recursively process JSX elements and their children, with new helper functions for component name extraction, fragment building, and tag serialization - Added SSR_MD environment handling in Tabs and CodeBlock components to render simplified markdown-friendly output
- Enhanced code block rendering with support for nested markdown fences and proper language/title metadata preservation
Reviewed changes
Copilot reviewed 20 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
pnpm-lock.yaml |
Added new ssg-md fixture entry to lockfile |
packages/core/src/theme/components/Tabs/index.tsx |
Added SSR_MD mode to render tabs as markdown with bold labels |
packages/core/src/theme/components/DocContent/docComponents/pre.tsx |
Added data-lang and data-title attributes for SSG-MD metadata preservation |
packages/core/src/theme/components/CodeBlock/index.tsx |
Added SSR_MD mode to bypass CodeBlock wrapper and render raw children |
packages/core/src/node/ssg-md/remarkSplitMdx.ts |
Major refactor: added recursive JSX processing, improved import handling with visit utility, added helper functions for component name extraction and tag serialization |
packages/core/src/node/ssg-md/remarkSplitMdx.test.ts |
Updated test snapshots to reflect cleaner output without extra newlines |
packages/core/src/node/ssg-md/react/render.ts |
Enhanced pre/code rendering with nested backtick handling and metadata support, improved error handling |
packages/core/src/node/ssg-md/react/render.test.tsx |
Added tests for nested code blocks and mdx language fence handling |
packages/core/src/node/mdx/options.ts |
Added __base config to remarkLink for SSG-MD mode, disabled user remark/rehype plugins in SSG-MD mode |
e2e/fixtures/ssg-md/* |
Added comprehensive e2e test fixture with MDX fragments, TSX components, and build verification |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
chore(ssg-md): refresh remarkSplitMdx
依赖于 remarkSplitMdx, 我们不需要用户配置任何 remark 和 rehype plugin 来单独处理 llms 相关,除了 MDX 中的 TSX 组件,会最大限度的保留 MDX 文件中的内容
Relying on remarkSplitMdx, we do not need users to configure any remark and rehype plugin, except for the TSX components in MDX, which will retain the content in the MDX file to the maximum extent.
llms: truebefore
Pseudocode
after
Related Issue
close #2894
Checklist