Expand description
XML-ish syntax highlighting for markup shown in an editor.
One line at a time, so a caller can highlight only the rows it paints.
Comments are the sole construct that spans lines, so the scan threads an
in_comment flag: pass xml_comment_state over everything above the
first visible row, then chain the flag returned by each
highlight_xml call into the next.
let (runs, in_comment) = highlight_xml("<col bg=\"red\">hi</col>", &Theme::default(), false);
assert!(!in_comment);
assert!(runs.len() > 1, "the line is split into styled runs");Structs§
- Syntax
Run - One styled byte range of a highlighted line.
Functions§
- highlight_
xml - Splits one line into styled runs, returning whether the line ends
inside an unterminated
<!-- ... -->comment. - xml_
comment_ state - Threads comment state across text the caller is not highlighting, such as the rows scrolled above an editor’s viewport.