next.js
f74157b7 - Read FixCard snippets from the parsed expression in the bundled docs converter (#102605)

Commit
2 hours ago
Read FixCard snippets from the parsed expression in the bundled docs converter (#102605) Stacked on #102509 (base is `aurorascharff/bundled-docs-markdown`). ### What? `fixCard` reads each snippet's `text` from the expression remark-mdx has already parsed (`attribute.value.data.estree`) instead of matching `text:` with a regex over the expression source. A FixCard without a title, or a snippet whose `text` is not a string literal, now fails the conversion instead of dropping the card or its code. ### Why? The regex matches every `text:` in the expression, including the `text` of a snippet's highlighted `parts`. `errors/instant-unrendered-segment.mdx` uses that shape, so its first card ships as 9 lines of code instead of 3: ``` function Layout({ children }) { function Layout({ children }) { return <><Nav />{children}</> return <><Nav />{ children }</> } ``` The parser also resolves quotes and escapes, so the hand-written unescaping goes too. ### How? - First commit: tests only. Against the current converter, the `parts` case and the non-literal case fail (2 failed, 22 passed). - Second commit: the fix. 24 passed. - `taskr copy_docs` before and after, diffed over all 749 files in `dist/docs`: the only change is that card, which loses the 6 duplicated lines. Every other FixCard in the corpus (78 total) converts the same. --------- Co-authored-by: Aurora Scharff <aurora.sofie@gmail.com>
Author
Parents
Loading