Repository navigation
fix: stop content loss and code-sample damage in cleaning and partials - #85
Merged
Merged
Conversation
- Import removal (partial inlining and excludeImports) matched any line
starting with "import ", deleting wrapped prose, and left multi-line
imports half-removed. A shared IMPORT_STATEMENT regex removes only ES
import statements with a quoted specifier, multi-line braces included.
- resolvePartialImports masks code at every recursion level, so imports
and partial usage inside a nested partial's code fence stay as written
(also on the missing-partial path). Inlined bodies are parked behind
tokens until the end, so a later splice cannot reach into an earlier
partial's code sample.
- maskCodeSegments tokens are namespaced per call, so masking already
masked content restores correctly.
- TAG_ATTRS: a bare attribute value cannot start with a quote or brace,
removing the exponential backtracking on long tags that fail to match.
- HTML stripping keeps boundaries: block tags become a newline (a space in
a markdown table row), adjacent td/th cells get " | ", and <img src alt>
becomes  so image-URL rewriting applies.
- Fence masking follows CommonMark closing rules (same char, at least as
long as the opener) and masks fences inside blockquotes.
- Description extraction: the H1 fallback reads the masked body, and MDX
{/* */} paragraphs are skipped. MDX and HTML comments outside code are
stripped from cleaned content.
- Partial imports accept `{ default as X }` and `X, { y }`, and a partial
used with element children is inlined.
Adds tests/test-content-loss.js (32 cases; 25 failed before the fix).
- A partial used with children (`<Wrap>…</Wrap>`) now renders them where
its body has `{props.children}`, matching MDX; otherwise they're dropped
as before.
- Blank-line collapsing ran after code was restored, so a code sample's
runs of blank lines were squeezed to one. Collapse before restoring, and
also clear the whitespace-only lines that indented HTML leaves behind.
rachfop
added a commit
that referenced
this pull request
Oct 2, 2026
#85) * fix: stop content loss and code-sample damage in cleaning and partials - Import removal (partial inlining and excludeImports) matched any line starting with "import ", deleting wrapped prose, and left multi-line imports half-removed. A shared IMPORT_STATEMENT regex removes only ES import statements with a quoted specifier, multi-line braces included. - resolvePartialImports masks code at every recursion level, so imports and partial usage inside a nested partial's code fence stay as written (also on the missing-partial path). Inlined bodies are parked behind tokens until the end, so a later splice cannot reach into an earlier partial's code sample. - maskCodeSegments tokens are namespaced per call, so masking already masked content restores correctly. - TAG_ATTRS: a bare attribute value cannot start with a quote or brace, removing the exponential backtracking on long tags that fail to match. - HTML stripping keeps boundaries: block tags become a newline (a space in a markdown table row), adjacent td/th cells get " | ", and <img src alt> becomes  so image-URL rewriting applies. - Fence masking follows CommonMark closing rules (same char, at least as long as the opener) and masks fences inside blockquotes. - Description extraction: the H1 fallback reads the masked body, and MDX {/* */} paragraphs are skipped. MDX and HTML comments outside code are stripped from cleaned content. - Partial imports accept `{ default as X }` and `X, { y }`, and a partial used with element children is inlined. Adds tests/test-content-loss.js (32 cases; 25 failed before the fix). * fix: keep partial children and code-sample blank lines - A partial used with children (`<Wrap>…</Wrap>`) now renders them where its body has `{props.children}`, matching MDX; otherwise they're dropped as before. - Blank-line collapsing ran after code was restored, so a code sample's runs of blank lines were squeezed to one. Collapse before restoring, and also clear the whitespace-only lines that indented HTML leaves behind.
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.
Content cleaning and partial inlining deleted prose, damaged code samples, and could hang the build:
excludeImports), including wrapped prose. Only ES import statements are removed now, multi-line ones whole.a<br/>bbecameab, table cells ran together,<img>vanished). Block tags leave a line break, cells get|, and<img>becomes a Markdown image.{/* */}and<!-- -->comments are now stripped outside code.{props.children}.tests/test-content-loss.jscovers each case. The docs site build output is unchanged. On a 3,461-page MDX docs site, no prose is lost: the only removed words are comments and a half-removed multi-line import.