Expand description
Pure tree-sitter syntax tokenizer.
Maps source code to a flat list of semantic HighlightedToken spans
(byte range + TokenKind). This crate has no rendering dependencies —
it knows nothing about colors, themes, fonts, or HTML. Consumers map
TokenKind to their own presentation:
- A native presenter resolves
TokenKindto a theme color. - A web presenter (such as the HTML the
x0k-tangleweave emits) resolves it to a CSS class viacss_class.
Tree-sitter grammars for JSON, Rust, Python, TypeScript and TSX are
compiled in behind the syntax-highlight feature (default on). With the
feature off, highlight always returns None and the grammar crates
are not built.
The grammars are pinned to tree-sitter 0.24 (language ABI 14). A
consumer that links its own tree-sitter grammars must bump in lockstep
with this crate: mixing ABI versions fails at set_language.
Structs§
- Highlighted
Token - A highlighted token with its byte range in the source.
Enums§
Functions§
- css_
class - The stable CSS class name for a token kind, e.g.
TokenKind::Keyword => "tok-keyword". This is the shared class-name contract every HTML/web presenter agrees on; the matching CSS lives in the consuming surface’s stylesheet. Native presenters ignore this and mapTokenKindstraight to a color. - highlight
- Highlight code, returning token ranges.