Skip to content

fix(docs): escape braces in generated MDX so the site builds#28

Merged
wavyx merged 1 commit into
mainfrom
fix-docs-build
Jul 9, 2026
Merged

fix(docs): escape braces in generated MDX so the site builds#28
wavyx merged 1 commit into
mainfrom
fix-docs-build

Conversation

@wavyx

@wavyx wavyx commented Jul 9, 2026

Copy link
Copy Markdown
Owner

The v0.22 Docs deploy failed: filter command descriptions inject literal { into reference/commands.mdx, which MDX parses as a JSX expression. mdxSafe() now escapes {/} like it already does </>. Verified npm --prefix website run build is green. Unblocks the docs site (currently stuck at v0.21).

https://claude.ai/code/session_018dRMUUj9vpKp3tqKQFsvE9

Greptile Summary

This PR fixes an MDX build failure introduced in v0.22 by escaping { and } characters in generated command descriptions. The mdxSafe() helper already handled |, <, and > — this adds &#123;/&#125; escaping for braces so Starlight's MDX compiler no longer mistakes JSON snippet notation and object destructuring syntax in description text for JSX expressions.

  • scripts/gen-commands.mjs: Two .replaceAll calls added to mdxSafe(), covering both command-level and flag-level description fields fed through it.
  • website/src/content/docs/reference/commands.mdx: Auto-regenerated output with the two previously offending lines now escaped correctly.

Confidence Score: 5/5

Safe to merge — the change is a minimal, targeted escaping fix in the generator helper and its regenerated output.

The two new .replaceAll calls in mdxSafe() correctly map bare { and } to the standard HTML entities &#123;/&#125;, which browsers render faithfully and MDX compilers do not misparse. All code paths that output prose into MDX (command descriptions at line 112, flag descriptions at line 123) already route through mdxSafe(), so the fix is complete. The generated file change is a straightforward mechanical consequence of re-running the script.

No files require special attention.

Important Files Changed

Filename Overview
scripts/gen-commands.mjs Adds &#123;/&#125; escaping for {/} in mdxSafe(); fix is correct and covers all call-sites that render prose into MDX.
website/src/content/docs/reference/commands.mdx Auto-generated file; two rows updated to replace bare {/} with &#123;/&#125;, consistent with the generator fix.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[oclif manifest JSON] --> B[gen-commands.mjs]
    B --> C[groupByTopic]
    C --> D[renderWebsiteMdx]
    D --> E{For each command}
    E --> F["mdxSafe(c.description)\nescape | < > { }"]
    E --> G{For each flag}
    G --> H["mdxSafe(f.description)\nescape | < > { }"]
    F --> I[Prose section in MDX]
    H --> J[Table cell in MDX]
    I --> K[commands.mdx]
    J --> K
    K --> L[Starlight MDX compiler]
    L --> M[Docs site build ✓]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[oclif manifest JSON] --> B[gen-commands.mjs]
    B --> C[groupByTopic]
    C --> D[renderWebsiteMdx]
    D --> E{For each command}
    E --> F["mdxSafe(c.description)\nescape | < > { }"]
    E --> G{For each flag}
    G --> H["mdxSafe(f.description)\nescape | < > { }"]
    F --> I[Prose section in MDX]
    H --> J[Table cell in MDX]
    I --> K[commands.mdx]
    J --> K
    K --> L[Starlight MDX compiler]
    L --> M[Docs site build ✓]
Loading

Reviews (1): Last reviewed commit: "fix(docs): escape braces in generated MD..." | Re-trigger Greptile

The v0.22 filter commands put literal { } into descriptions/examples
(e.g. filter export's {name, type, conditions} and conditions JSON),
and MDX reads a bare { as a JSX expression, so the Astro build failed at
reference/commands.mdx and the v0.22 Docs deploy never shipped. mdxSafe()
now escapes { } like it already does < >; commands.mdx regenerated.

Claude-Session: https://claude.ai/code/session_018dRMUUj9vpKp3tqKQFsvE9
@wavyx wavyx merged commit 7d53de7 into main Jul 9, 2026
11 checks passed
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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