pub fn highlight_code(
code: &str,
lang: &str,
theme: &Theme,
) -> Option<Vec<Vec<(String, Style)>>>Expand description
Highlight source code using tree-sitter.
Returns Some(lines) where each line is a Vec<(text, style)> of
styled segments, or None if:
- The language is not recognised
- The corresponding
syntax-*feature is not enabled - Parsing fails
Callers should fall back to the built-in keyword highlighter when
None is returned.
§Example
ⓘ
let lines = slt::syntax::highlight_code("let x = 1;", "rust", &theme);