fix(mdx): stop double-escaping angle brackets inside code - #1243
Closed
nlimpid wants to merge 1 commit into
Closed
Conversation
The preflight rewrites in astro.config.ts run over the raw mdx source with code blocks included. Rule 5 turned `<iostream>` and `<token>` into `<…>`, the downstream pipeline escaped that a second time, and 419 pages ended up rendering the entity text: every C++ include and every curl auth header was broken for anyone copying it off the page. Stash the code regions — fenced blocks, inline spans, and the CliCommand payload built in rule 1.5 — before rules 2-10 run, and restore them once the rewrites are done. The placeholder uses U+E000 rather than NUL so oxlint's no-control-regex stays quiet. Verified against the dev server: the three affected shapes now render as `#include <iostream>`, `Bearer <token>` and `<client_id>`; all 78 absolute-slug English pages still return 200; CliCommand cards, REST brace placeholders and directive callouts are unchanged.
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.
Problem
The preflight rewrites in
astro.config.tsrun over the raw mdx source with code blocks included. Rule 5 turns<iostream>and<token>into<…>, the downstream pipeline escapes that a second time, and the page renders the entity text:419 pages are affected. Anyone copying a snippet off the page gets broken code.
It is not only rule 5 — rules 6, 7, 9 and 10 rewrite code-region content too, so fixing a single rule is not enough.
Fix
Stash the code regions before rules 2-10 run, restore them afterwards. Three kinds, and the order matters:
CliCommandpayload built in rule 1.5 (a JSON string that may itself contain backticks, so it goes first)The placeholder uses
U+E000rather thanNULso oxlint'sno-control-regexstays quiet.Verification
Against the dev server:
#include <iostream>✅Bearer <token>✅<client_id>✅/v1/content/{symbol}/newsunchangedThe regression checks matter most here: had the stash regex over-captured into prose, those placeholders would reach MDX as undefined components and the pages would 500. All 78 returning 200 confirms the prose-side escaping still works.