@tanstack/highlight
Version:
Tiny class-based syntax highlighting for documentation.
32 lines (31 loc) • 1.54 kB
TypeScript
import { type Highlighter, type HighlightDecoration, type HighlightToken, type RenderedCodeBlockData } from './core.js';
import { type CodeFenceInput } from './internal/code-fence.js';
export { getCodeFenceTitle, parseCodeDiffNotation, parseCodeFenceMeta, type CodeFenceInput, type CodeFenceMeta, } from './internal/code-fence.js';
export type HighlightedCodeFence = RenderedCodeBlockData & {
decorations: ReadonlyArray<HighlightDecoration>;
lineNumbers: boolean;
};
export type HastText = {
type: 'text';
value: string;
};
export type HastElement = {
type: 'element';
tagName: string;
properties?: Record<string, unknown>;
data?: Record<string, unknown>;
children: Array<HastElement | HastText>;
};
export type TanStackMarkdownHighlighterOptions = {
highlightLines?: ReadonlyArray<number>;
lineNumbers?: boolean;
};
export type TanStackMarkdownHighlighter = (code: string, lang?: string, options?: TanStackMarkdownHighlighterOptions) => string;
export declare function renderCodeFence(input: CodeFenceInput, highlighter: Highlighter): HighlightedCodeFence;
export declare function codeFenceToHast(input: CodeFenceInput, highlighter: Highlighter): HastElement;
export declare function createTanStackMarkdownHighlighter(highlighter: Highlighter): TanStackMarkdownHighlighter;
export declare function tokensToHast(tokens: ReadonlyArray<HighlightToken>, lang: string, options?: {
decorations?: ReadonlyArray<HighlightDecoration>;
lineNumbers?: boolean;
title?: string;
}): HastElement;