highlight

fun highlight(code: String, language: Language, theme: SyntaxTheme): AnnotatedString

Returns an AnnotatedString of code with theme styles applied to tree-sitter capture spans defined by language. Each capture name is resolved through SyntaxTheme.resolve, which falls back along dotted prefixes (e.g. string.escape ->string) before yielding null.

Constructs a fresh tree-sitter Parser on every call. Compose callers should prefer rememberHighlightedString or SyntaxHighlightedText, both of which memoize the result.