Skip to main content

Module highlight

Module highlight 

Source
Expand description

Safe, dependency-free lexical syntax highlighting.

One generic scanner is parameterized by static language profiles. The output is safe HTML: source text is escaped here, and the only markup this module emits is its own fixed tok-* spans.

Functionsยง

highlight_hunk
Highlight a diff hunk with independent lexer state for its old and new sides. Context advances both streams and renders from the new side.
highlight_lines
Highlight a contiguous run of source lines. Unknown paths return None, allowing callers to preserve their plain escaped rendering.