Syntaxmate
A fast, Rust-native syntax highlighter powered by TextMate grammars.
Bundled languages and GitHub themes, incremental highlighting, safe HTML and ANSI output, and no native Oniguruma dependency.
Documentation · Examples · Benchmarks · Languages · Compatibility · Contributing
Usage
[]
= "0.2"
use Highlighter;
let highlighter = bundled?;
let output = highlighter.highlight_html?;
assert!;
println!;
# Ok::
For custom grammars, themes, and incremental use, start with the compiled examples. See rendering for output options and source/document pairing requirements.
For structured output, document and incremental APIs share the same token types:
use ;
let highlighter = bundled?;
let document = highlighter.highlight?;
let token: &HighlightedToken = &document.lines.tokens;
assert!;
assert_eq!;
# Ok::
See Migrating from 0.1 for the upcoming 0.2 API changes.
Binary size
Embed only the languages you need with the
subset-bundle command and loading workflow.
default-features = false omits embedded grammars and themes; custom catalogs
and shared Highlighter instances remain available.
Measured on Linux x86-64, 2026-09-27, Rust 1.98.1: a consumer using
include_bytes!, Catalog::from_static, and Highlighter::tokenize, with
lto="fat", codegen-units=1, panic="abort", and strip=true:
| Languages | Bundle bytes | Stripped executable bytes |
|---|---|---|
| Full catalog | 2,556,579 | 3,966,824 |
| Rust, TOML, JSON | 13,027 | 1,423,272 |
| HTML, CSS, JavaScript, TypeScript, TSX, JSON, Markdown | 832,468 | 2,242,728 |
These are complete executables, including the engine. Dependencies and licenses are included in each bundle; embedded languages explain much of the web set's size. Results depend on the target and consumer code.