highlight.ts#
4 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference#
modulehighlightSyntax highlighting with the native tree-sitter engine. Markup uses <pre class="ox-highlight css-variables"> and --octc…
Syntax highlighting with the native tree-sitter engine.
Markup uses <pre class="ox-highlight css-variables"> and --octc-syntax-* custom properties so theme-color packages resolve token colors.
fnhighlightCode(html: string): Promise<string>Apply native tree-sitter highlighting to HTML. Tries the document pass first. I…
Apply native tree-sitter highlighting to HTML.
Tries the document pass first. If that pass skips unreadable markup, falls back to a native-only per-block walk. Languages with no native grammar stay as the original <pre><code>.
Signature
export async function highlightCode(html: string): Promise<string>Parameters
-
htmlstring
Returns
Promise<string>
fnhighlightPageHtml(html: string, mergeHighlightedCodeBlocks: (originalHtml: string, highlightedHtml: string) => string): Promise<string>Highlight every code block in a rendered page, preserving original classes and…
Highlight every code block in a rendered page, preserving original classes and per-line metadata when the native document pass cannot read the markup.
Signature
export async function highlightPageHtml(html: string, mergeHighlightedCodeBlocks: (originalHtml: string, highlightedHtml: string) => string): Promise<string>Parameters
-
htmlstring -
mergeHighlightedCodeBlocks(originalHtml: string, highlightedHtml: string) => string
Returns
Promise<string>
fnrehypeNativeHighlight()Per-block walk used when the native document pass cannot read the markup. Unkno…
Per-block walk used when the native document pass cannot read the markup. Unknown languages stay as the original <pre><code>.
Signature
function rehypeNativeHighlight()