Skip to content

Conversation

@SoonIter
Copy link
Member

@SoonIter SoonIter commented Dec 17, 2025

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: true

// index.mdx
# Hello

import { Tabs, Tab} from './Button.mdx';


<Tabs>
<Tab label="hello.tsx">

```tsx
```

</Tab>
</Tabs>

before

Pseudocode

const MDX = `# Hello` + jsxs(Tabs, { jsx(Tab, { jsx(Pre, { children })} ) })


export default () => {
   return MDX()
}

after

const MDX = 
`# Hello` + 

jsxs(Tabs, { jsx(Tab, { jsx(` \`\`\`tsx \`\`\```) })


export default () => {
   return MDX()
}

Related Issue

close #2894

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link

netlify bot commented Dec 17, 2025

Deploy Preview for rspress-v2 ready!

Name Link
🔨 Latest commit 97c3a0c
🔍 Latest deploy log https://app.netlify.com/projects/rspress-v2/deploys/69439c0d162e7a000803f714
😎 Deploy Preview https://deploy-preview-2903--rspress-v2.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.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

Rsdoctor Bundle Diff Analysis

Found 3 project(s) in monorepo.

📊 Quick Summary (Click to expand)
Project Total Size Change
node 8.9 MB -
node_md 1.1 MB -
web 14.9 MB -
📋 Detailed Reports (Click to expand)

📁 node

Path: website/doc_build/diff-rsdoctor/node/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 8.9 MB - -
📄 JavaScript 0 B - -
🎨 CSS 0 B - -
🌐 HTML 8.9 MB - -
📁 Other Assets 0 B - -

📁 node_md

Path: website/doc_build/diff-rsdoctor/node_md/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 1.1 MB - -
📄 JavaScript 0 B - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 1.1 MB - -

📁 web

Path: website/doc_build/diff-rsdoctor/web/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 14.9 MB - -
📄 JavaScript 14.3 MB - -
🎨 CSS 115.4 KB - -
🌐 HTML 0 B - -
📁 Other Assets 512.9 KB - -

Generated by Rsdoctor GitHub Action

@SoonIter SoonIter marked this pull request as ready for review December 18, 2025 06:09
Copilot AI review requested due to automatic review settings December 18, 2025 06:09
Copy link
Contributor

Copilot AI left a 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 remarkSplitMdx to 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.

@SoonIter SoonIter changed the title chore(ssg-md): refresh remarkSplitMdx refactor(ssg-md): redesign the remarkSplitMdx split logic Dec 18, 2025
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.

[Bug]: llms plugin cannot handle unknown node containerDirective after v2.0.0-rc.1

3 participants