fix(docs): escape braces in generated MDX so the site builds#28
Merged
Conversation
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
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
The v0.22 Docs deploy failed: filter command descriptions inject literal
{intoreference/commands.mdx, which MDX parses as a JSX expression.mdxSafe()now escapes{/}like it already does</>. Verifiednpm --prefix website run buildis 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. ThemdxSafe()helper already handled|,<, and>— this adds{/}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.replaceAllcalls added tomdxSafe(), 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
.replaceAllcalls inmdxSafe()correctly map bare{and}to the standard HTML entities{/}, 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 throughmdxSafe(), 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
{/}escaping for{/}inmdxSafe(); fix is correct and covers all call-sites that render prose into MDX.{/}with{/}, 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 ✓]%%{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 ✓]Reviews (1): Last reviewed commit: "fix(docs): escape braces in generated MD..." | Re-trigger Greptile