File
Blob: src/shared/editor/highlight/code-highlight-runtime.d.ts
| 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. |
| 4 | export interface HighlightNode { |
| 5 | value?: string; |
| 6 | properties?: { className?: string[] | string }; |
| 7 | children?: HighlightNode[]; |
| 8 | } |
| 9 | |
| 10 | export interface HighlightResultNode { |
| 11 | value?: HighlightNode[]; |
| 12 | children?: HighlightNode[]; |
| 13 | } |
| 14 | |
| 15 | export interface CodeHighlightSegment { |
| 16 | text: string; |
| 17 | classes: string[]; |
| 18 | } |
| 19 | |
| 20 | export interface CodeBlockHighlighter { |
| 21 | highlight(language: string, value: string): HighlightResultNode; |
| 22 | highlightAuto(value: string): HighlightResultNode; |
| 23 | listLanguages(): string[]; |
| 24 | registered?(aliasOrLanguage: string): boolean; |
| 25 | } |
| 26 | |
| 27 | export const codeBlockLowlight: CodeBlockHighlighter; |
| 28 | export function isPlainTextCodeLanguage(language: string | null | undefined): boolean; |
| 29 | export function highlightCodeToSegments(language: unknown, code: string): CodeHighlightSegment[]; |