Skip to content
File

Blob: src/shared/editor/highlight/code-highlight-runtime.d.ts

typescript30 lines
1// Narrow local declarations for code-highlight-runtime.js. Do not import
2// highlight.js or lowlight types here; their declarations reference lib.dom and
3// would leak DOM types into the Worker typecheck.
4export interface HighlightNode {
5 value?: string;
6 properties?: { className?: string[] | string };
7 children?: HighlightNode[];
8}
9 
10export interface HighlightResultNode {
11 value?: HighlightNode[];
12 children?: HighlightNode[];
13}
14 
15export interface CodeHighlightSegment {
16 text: string;
17 classes: string[];
18}
19 
20export interface CodeBlockHighlighter {
21 highlight(language: string, value: string): HighlightResultNode;
22 highlightAuto(value: string): HighlightResultNode;
23 listLanguages(): string[];
24 registered?(aliasOrLanguage: string): boolean;
25}
26 
27export const codeBlockLowlight: CodeBlockHighlighter;
28export function isPlainTextCodeLanguage(language: string | null | undefined): boolean;
29export function highlightCodeToSegments(language: unknown, code: string): CodeHighlightSegment[];