highlight To Html
Highlights code and returns raw HTML with <span class="hljs-*"> tokens, together with the time taken for the JavaScript round-trip.
Lower-level alternative to highlight: use this when you need the raw HTML string rather than a theme-applied AnnotatedString. Automatically initializes the WebView on the first call. Thread-safe: may be called from any dispatcher.
engine.highlightToHtml("val x = 42", "kotlin").onSuccess { result ->
// result.html contains e.g. <span class="hljs-keyword">val</span> x = ...
renderRawHtml(result.html)
log("JS round-trip: ${result.durationMs} ms")
}Return
Result wrapping an HtmlHighlightResult (html + timing), or Result.failure with a HighlightException on error. Returns HighlightException.Timeout if the JavaScript call does not complete within the timeout window.
Parameters
The source code to highlight.
Highlight.js language identifier (e.g. "kotlin", "python"). If blank or unrecognized by Highlight.js, returns escaped plain text without running automatic language detection. Use highlightAuto if automatic language detection is desired.