UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

55 lines 2.5 kB
import type { Plugin } from 'unified'; export type TransformHtmlCodeBlockOptions = { /** * Maximum number of context lines to keep visible above and below focused regions. * These values act as site-wide defaults for authored inline code blocks. * Per-block `@padding` directives still take precedence. * @default 25 */ paddingFrameMaxSize?: number; /** * Maximum number of visible lines to keep in a focused region before collapsing the rest. * These values act as site-wide defaults for authored inline code blocks. * Per-block `@min` directives still take precedence. * @default 60 */ focusFramesMaxSize?: number; /** * How to handle a focused region larger than `focusFramesMaxSize`: * `'truncate'` (default) keeps the first `focusFramesMaxSize` lines visible and * hides the overflow; `'hide'` produces no visible window so the block collapses * to nothing (`focusedLines === 0`, still `collapsible`) and expanding reveals * the whole source. Applies to oversized `@highlight` / `@focus` regions and the * auto-focus-from-line-1 case. * @default 'truncate' */ oversizedFocus?: 'truncate' | 'hide'; /** * Render-time default for "collapse to empty": when `true`, every authored code * block collapses to an empty window (hidden until expanded) unless the block * sets its own flag (` ```ts collapseToEmpty ` to force it, ` ```ts collapseToEmpty=false ` * to opt out). Runtime-only — the precomputed HAST is unchanged. * @default false */ collapseToEmpty?: boolean; /** * Render-time default for "initial expanded": when `true`, every authored code * block starts expanded unless the block sets its own flag * (` ```ts initialExpanded ` / ` ```ts initialExpanded=false `). Runtime-only — * the precomputed HAST is unchanged. * @default false */ initialExpanded?: boolean; }; /** * Rehype plugin that transforms semantic HTML code structures to use loadIsomorphicCodeVariant * * This plugin: * 1. Finds section and dl elements in the HTML AST * 2. Extracts code elements from the semantic structure (figure/dl/dd/pre/code) * 3. Creates variants from multiple code elements or single Default variant * 4. Uses loadIsomorphicCodeVariant to process each variant * 5. Stores the combined precompute data on the root element * 6. Clears all code element contents and replaces with error message */ export declare const transformHtmlCodeBlock: Plugin<[TransformHtmlCodeBlockOptions?]>;