@comfit/wasm / Highlighter
Interface: Highlighter
Defined in: types.ts:180
A parser and language registry. Call dispose() when no longer needed.
Methods
createDocument()
createDocument(
options):Document
Defined in: types.ts:182
Create an independent document sharing the currently loaded language queries.
Parameters
options
Returns
dispose()
dispose():
void
Defined in: types.ts:195
Release runtime resources. Repeated calls are harmless. Later rendering calls throw.
Returns
void
highlight()
highlight(
source,language,options?): readonlyLine[]
Defined in: types.ts:188
Highlight source into owned lines and tokens using a registered ID or alias. Empty sources produce one line. A trailing newline produces a final empty line.
Parameters
source
string
language
string
options?
Returns
readonly Line[]
Throws
If the registry is disposed, options are invalid, or highlighting fails.
renderHtml()
renderHtml(
source,language,options?):string
Defined in: types.ts:193
Render an escaped HTML fragment with capture classes, inline themes, or CSS variables.
Parameters
source
string
language
string
options?
Returns
string
Throws
If the registry is disposed, options are invalid, or highlighting fails.