Auto Highlight Result
Result of a successful HighlightEngine.highlightAuto call.
This mirrors HighlightResult, but stores the language detected by Highlight.js instead of a caller-supplied language. Automatic detection is convenient for unknown snippets, but it is usually slower and less accurate than passing an explicit language.
Usage
engine.highlightAuto(code, theme).onSuccess { result ->
SyntaxHighlightedCode(
code = code,
language = result.detectedLanguage,
theme = theme,
)
log("Detected language: ${result.detectedLanguage}")
log("Highlight took ${result.durationMs} ms")
}detectedLanguage may be an empty string if Highlight.js could not determine a language.
Constructors
Properties
The syntax-highlighted AnnotatedString ready for rendering.
Highlight.js detected language identifier, or an empty string when auto-detection could not determine one.
Pure highlight time in milliseconds. Equals timings.total.inWholeMilliseconds.
Number of AnnotatedString.spanStyles entries. A value of 0 indicates that no tokens were found.
Per-layer timing breakdown for this highlight call. Always populated.