Skip to content

Function: highlightToHtml()

highlightToHtml(code, language): Promise<string>

Highlight code into minimal inline HTML: one colored <span> per token, lines joined by real newlines, with no line-number gutter or per-line wrapper elements. Meant to drop straight into a <pre><code> so the rendered text stays cleanly selectable and copyable. Falls back to plain escaped text when the language isn’t supported or shiki fails to parse the snippet.

string

string

Promise<string>