[docs-infra] Add More Highlighting Extensions#1373
Conversation
…nfra-syntax-jsx-variable, and --color-docs-infra-syntax-property-string Co-authored-by: Copilot <copilot@github.com>
Deploy previewBundle sizeTotal Size Change: 🔺+3.53KB(+0.14%) - Total Gzip Change: 🔺+1.05KB(+0.15%) Show details for 63 more bundles@mui/internal-docs-infra/CodeProvider parsed: 🔺+3.53KB(+2.35%) gzip: 🔺+1.04KB(+2.34%) PerformanceTotal duration: 19.71 ms -0.40 ms(-2.0%) | Renders: 4 (+0) | Paint: 81.27 ms -1.03 ms(-1.2%) No significant changes — details Check out the code infra dashboard for more information about this PR. |
Co-authored-by: Copilot <copilot@github.com>
…-public into docs-infra/further-extend-syntax
There was a problem hiding this comment.
Pull request overview
Adds additional docs-infra syntax token classes to improve fine-grained theming of highlighted code, particularly for punctuation/operators, JSX expression variables, object-literal keys, and template-literal interpolations (including inline code snippets).
Changes:
- Extend
extendSyntaxTokenswith new additive classes (di-pu,di-jv,di-op,di-ps,di-te,di-td) and supporting parsing/state tracking. - Improve inline highlighting for “bare object literal” snippets by temporarily wrapping in parentheses and stripping the wrapper post-highlight.
- Update docs, demos, snapshots, and tests to reflect the new token classes and styling variables.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/docs-infra/src/pipeline/transformHtmlCodeInline/user.spec.ts | Adds coverage for inline TSX bare-object-literal highlighting behavior. |
| packages/docs-infra/src/pipeline/transformHtmlCodeInline/transformHtmlCodeInline.ts | Wraps bare object-literal inline snippets for correct expression tokenization; strips wrapper after highlighting. |
| packages/docs-infra/src/pipeline/transformHtmlCodeInline/removeSuffixFromHighlightedNodes.ts | Adds suffix-stripping helper for post-highlight wrapper removal. |
| packages/docs-infra/src/pipeline/parseSource/parseSource.test.ts | Updates expectations to assert new di-op extraction behavior for object keys. |
| packages/docs-infra/src/pipeline/parseSource/extendSyntaxTokens.ts | Implements new token extensions (punctuation, JSX vars, object keys, template interpolation regions/delimiters) and improves JSX-vs-generics handling. |
| packages/docs-infra/src/pipeline/parseSource/extendSyntaxTokens.test.ts | Adds/adjusts tests for new token classes and JSX generic edge cases. |
| packages/docs-infra/src/pipeline/loadServerTypes/snapshots/highlightTypes.test.ts.snap | Updates snapshot output to include new additive classes (notably di-pu / di-jv). |
| packages/docs-infra/src/pipeline/enhanceCodeEmphasis/enhanceCodeEmphasis.test.ts | Updates snapshots to reflect new additive classes in rendered emphasized output. |
| docs/app/docs-infra/pipeline/parse-source/page.mdx | Documents the new di-* token classes and their intended semantics/scope. |
| docs/app/docs-infra/hooks/use-code-window/demos/CollapsibleDemoContent.tsx | Switches demo styling import to the local syntax stylesheet. |
| docs/app/docs-infra/components/code-highlighter/demos/syntax.css | Adds CSS variables + rules for the new di-* classes (and centralizes starry-night style import). |
Add support for
--color-docs-infra-syntax-punctuation,--color-docs-infra-syntax-jsx-variable, and--color-docs-infra-syntax-property-string,--color-docs-infra-syntax-object-property,--color-docs-infra-syntax-template-expression,--color-docs-infra-syntax-template-delimiterPreview Deploy