@mui/internal-docs-infra
Version:
MUI Infra - internal documentation creation tools.
30 lines • 1.33 kB
text/typescript
import type { Root as HastRoot } from 'hast';
/**
* A rehype plugin that enhances inline code elements in three ways:
*
* 1. **Tag bracket wrapping**: Wraps HTML/JSX tag patterns (opening bracket,
* tag-name span, closing bracket) in a wrapper span. HTML tags (`pl-ent`)
* get `<span class="di-ht">`, JSX component tags (`pl-c1`) get
* `<span class="di-jt">`. The original `pl-*` spans are preserved
* inside — no semantic information is destroyed.
*
* 2. **Token reclassification**: Corrects misidentified token classes,
* e.g., `function` marked as `pl-en` is changed to `pl-k` (keyword).
*
* 3. **Built-in type enhancement** (TypeScript only): Reclassifies standalone
* type keywords (`string`, `number`, `void`, etc.) from `pl-smi`/`pl-k`
* to `pl-c1 di-bt`, matching `extendSyntaxTokens` output in type context.
*
* Transforms patterns like:
* `<code><<span class="pl-ent">div</span>></code>`
*
* Into:
* `<code><span class="di-ht"><<span class="pl-ent">div</span>></span></code>`
*
* **Important**: This plugin should run after syntax highlighting plugins
* (like transformHtmlCodeInline) as it modifies the structure
* of highlighted elements.
*
* @returns A unified transformer function
*/
export default function enhanceCodeInline(): (tree: HastRoot) => void;