highlight-native.ts#
6 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference#
fngetTextContent(node: Element | Root): stringExtract text content from a hast node.
Extract text content from a hast node.
Signature
export function getTextContent(node: Element | Root): stringParameters
-
nodeElement | Root
Returns
string
modulehighlight-nativeThe native tree-sitter highlighting path, plus the small hast helpers the per-block walk uses when the document pass ca…
The native tree-sitter highlighting path, plus the small hast helpers the per-block walk uses when the document pass cannot read the markup.
fnhighlightDocumentNatively(html: string): Promise<NativeDocument | null>Highlights every code block in a rendered document in one native call. Returns…
Highlights every code block in a rendered document in one native call.
Returns the rewritten HTML and the languages it declined. Pending languages stay unhighlighted. Returns null when the native module is unavailable.
Signature
export async function highlightDocumentNatively(html: string): Promise<NativeDocument | null>Parameters
-
htmlstring
Returns
Promise<NativeDocument | null>
fnhighlightNatively(code: string, lang: string): string | nullHighlights with the native tree-sitter engine, or null when it has no grammar f…
Highlights with the native tree-sitter engine, or null when it has no grammar for lang.
It emits --octc-syntax-* markup so theme-color packages resolve token colors.
Signature
export function highlightNatively(code: string, lang: string): string | nullParameters
-
codestring -
langstring
Returns
string | null
interfaceNativeDocumentWhat highlightDocumentNatively produced for a page.
What highlightDocumentNatively produced for a page.
Signature
export interface NativeDocumentMembers
Properties
| Name | Type | Description |
|---|---|---|
html |
string |
|
pending |
PendingBlock[] |
Well-formed blocks whose language has no native grammar, in order. |
skipped |
string[] |
Languages of elements the native pass could not read. Non-empty means the page has to be produced by the per-block walk instead. |
interfacePendingBlockA block the native pass left unhighlighted (no grammar).
A block the native pass left unhighlighted (no grammar).
Signature
export interface PendingBlockMembers
Properties
| Name | Type | Description |
|---|---|---|
language |
string |
|
source |
string |