import type { CodeTokenKind } from '../types.js'; /** One run of a listing's line as a highlighter gives it: its text, the * kind of token it is (unset: plain) or a colour of its own (a CSS hex, * which wins over the kind's). */ export interface CodeToken { text: string; token?: CodeTokenKind; color?: string; } /** A highlighter: the listing's lines, each as runs whose texts join into * the line (tabs and spaces included). `lang` is the fence's language, * lower-cased. Return undefined to leave the listing to the next * highlighter (or the built-in one). */ export type CodeHighlighter = (code: string, lang: string) => CodeToken[][] | undefined; /** * Register a highlighter for listings of `lang` (lower-case, as fences * name it: `'js'`, `'python'`), or `'*'` for every language. A highlighter * for a language takes precedence over `'*'`, which takes precedence over * the built-in tokenizer; `null` removes one. Layout reads the registry * when it sets a listing, so register before building; in a web worker * (the Sandbox lays out in one) register inside the worker. */ export declare function registerCodeHighlighter(lang: string, fn: CodeHighlighter | null): void; /** Whether the built-in tokenizer reads `lang`. */ export declare function builtinCodeLanguage(lang: string | undefined): boolean; /** * The tokens of a listing's lines: a registered highlighter's (for its * language, then `'*'`), else the built-in tokenizer's when `builtin` and * it reads the language. Undefined when nothing colours it. A * highlighter's lines that do not join into the listing's own are left * out (the listing is then set plain). */ export declare function highlightCode(code: string, lang: string | undefined, builtin: boolean): CodeToken[][] | undefined; //# sourceMappingURL=highlight.d.ts.map