Skip to content

fix(search): strip MDX syntax from search index - #3543

Open
SoonIter wants to merge 1 commit into
mainfrom
fix/search-index-mdx-syntax
Open

fix(search): strip MDX syntax from search index#3543
SoonIter wants to merge 1 commit into
mainfrom
fix/search-index-mdx-syntax

Conversation

@SoonIter

Copy link
Copy Markdown
Member

Summary

  • Parse search content as MDX so exports, JSX attributes, and expressions are excluded from the index.
  • Preserve user-visible component children and searchable code content without leaking Markdown fences.
  • Add regression coverage for MDX syntax and fenced JSON code blocks.

Related Issue

None.

Checklist

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

Copilot AI review requested due to automatic review settings July 23, 2026 07:02

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0e9ce3114

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/node/route/extractPageData.ts Outdated
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 3 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
website_html 14.1 MB 2.0 MB +6.9 KB (0.0%) +2.0 KB (0.1%)
website_md 1.8 MB 261.7 KB +2.8 KB (0.2%) +1.4 KB (0.5%)
website_js 16.8 MB 2.9 MB +2.2 KB (0.0%) +2.3 KB (0.1%)
auto_nav_sidebar_html 304.9 KB 60.7 KB 0 0
auto_nav_sidebar_js 524.4 KB 164.3 KB 0 0
📋 Detailed Reports (Click to expand)

📁 website_html

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

📌 Baseline Commit: 0519db8293 | PR: #3550

Metric Current Baseline Change
📊 Total Size 14.1 MB 14.1 MB +6.9 KB (0.0%)
🗜️ Gzip Size 2.0 MB 2.0 MB +2.0 KB (0.1%)
📄 JavaScript 0 B 0 B 0
🎨 CSS 0 B 0 B 0
🌐 HTML 14.1 MB 14.1 MB +6.9 KB (0.0%)
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: website_html Bundle Diff

📁 website_md

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

📌 Baseline Commit: 0519db8293 | PR: #3550

Metric Current Baseline Change
📊 Total Size 1.8 MB 1.8 MB +2.8 KB (0.2%)
🗜️ Gzip Size 261.7 KB 260.2 KB +1.4 KB (0.5%)
📄 JavaScript 0 B 0 B 0
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 1.8 MB 1.8 MB +2.8 KB (0.2%)

📦 Download Diff Report: website_md Bundle Diff

📁 website_js

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

📌 Baseline Commit: 0519db8293 | PR: #3550

Metric Current Baseline Change
📊 Total Size 16.8 MB 16.8 MB +2.2 KB (0.0%)
🗜️ Gzip Size 2.9 MB 2.9 MB +2.3 KB (0.1%)
📄 JavaScript 16.5 MB 16.5 MB +1.1 KB (0.0%)
🎨 CSS 138.9 KB 138.9 KB 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 173.2 KB 172.2 KB +1.0 KB (0.6%)

📦 Download Diff Report: website_js Bundle Diff

Generated by Rsdoctor GitHub Action

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploying rspress-v2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: b3f86c9
Status: ✅  Deploy successful!
Preview URL: https://0bb019c2.rspress-v2.pages.dev
Branch Preview URL: https://fix-search-index-mdx-syntax.rspress-v2.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR updates search indexing to parse content as MDX, ensuring MDX-only syntax (exports, JSX attributes, expressions) is excluded while keeping user-visible text and searchable code block content.

Changes:

  • Add remark-mdx to the markdown processor so MDX nodes are parsed and can be handled correctly during indexing.
  • Adjust MDX node skipping/handling to keep visible JSX children while excluding MDX expressions/ESM from the index.
  • Add a regression fixture + test covering MDX expressions/exports and fenced JSON code blocks.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/core/src/node/route/fixtures/content-processing/with-mdx-syntax.mdx Adds an MDX fixture containing exports, JSX, expressions, and a JSON fenced code block for regression coverage.
packages/core/src/node/route/extractPageData.ts Parses MDX via remark-mdx and adds whitespace normalization after stripping MDX expressions.
packages/core/src/node/route/extractPageData.test.ts Adds a regression test to ensure MDX syntax is stripped while visible content + code blocks remain searchable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/node/route/extractPageData.ts Outdated
Comment thread packages/core/src/node/route/extractPageData.ts Outdated
@SoonIter SoonIter changed the title fix(core): strip MDX syntax from search index fix(search): strip MDX syntax from search index Jul 23, 2026
@SoonIter
SoonIter force-pushed the fix/search-index-mdx-syntax branch from c0e9ce3 to b3f86c9 Compare July 27, 2026 08:22

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b3f86c9594

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const createProcessor = (searchCodeBlocks: boolean) =>
unified()
.use(remarkParse)
.use(remarkMdx)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep .md pages on the Markdown parser

When a routed .md file contains raw HTML that is valid Markdown but invalid MDX/JSX—such as an HTML comment or <img> without a JSX self-closing slash—this unconditional plugin makes processor.parse(content) use MDX grammar and throw. The main compiler deliberately selects the format from the extension and enables rehypeRaw for .md in packages/core/src/node/mdx/options.ts, so these are supported pages; since createPageData awaits extraction without an error fallback, such a page can now abort a normal build. Apply remarkMdx only when processing .mdx files.

Useful? React with 👍 / 👎.

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.

2 participants