Skip to content

highlight.ts#

View Markdown

Source

4 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

4 symbols 3 functions 1 modules 3 parameters 2 returns

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.

View source

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>

View source

Parameters

  • html string

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>

View source

Parameters

  • html string
  • 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()

View source