Expand description
Rust-native TextMate syntax highlighting with bundled grammars and themes.
Highlighter is the default batteries-included entry point, with
structured spans plus safe HTML and ANSI convenience output.
GrammarRegistry and Tokenizer provide the custom-grammar API.
use syntaxmate::Highlighter;
let highlighter = Highlighter::bundled()?;
let document = highlighter.highlight("rust", "fn main() {}", "github-dark")?;
assert!(document.status().is_complete());Structs§
- Ansi
Options ansi - Options for
render_ansi. - Asset
License - License and source provenance for one bundled language asset.
- Bundle
Error - Bundled asset failure without exposing the private bundle format.
- Catalog
- Cheaply cloned, read-only access to a grammar bundle and its metadata.
- Catalog
Summary - Summary of the embedded bundle and its provenance.
- Checkpoint
Table - Checkpoints used to replay incremental state near a requested viewport.
- Diagnostic
Error - Diagnostic regex failure with the original pattern and execution context.
- Font
Modifiers - A set of resolved font decorations.
- Grammar
Error - Grammar failure with the originating scope when available.
- Grammar
Id - Opaque identity of a grammar in one
GrammarRegistry. - Grammar
Limits - Resource limits applied while constructing a custom grammar registry.
- Grammar
Registry - A collection of TextMate JSON grammars and their external include scopes.
- Highlight
Session - A reusable incremental highlighter. Input lines exclude newline terminators.
- Highlighted
Document - Styled logical lines and their aggregate completion status.
- Highlighted
Line - One styled logical line, from a document or an incremental session.
- Highlighted
Token - One styled token with a line-relative byte range and exact ordered scopes.
- Highlighter
- A cheaply cloned, thread-safe highlighter backed by a
Catalog. - Highlighter
Options - Cache and tokenizer limits for a shared
Highlighter. - Html
Options html - Options for
render_html. - Json
Error - A JSON decoding failure with its original serde cause.
- Language
Info - Borrowed metadata for one public language in a
Catalog. - Limit
Exceeded - A configured grammar limit and the attempted resource usage.
- Missing
Include - A missing local or external grammar include.
- Prepared
Language - Caller-owned immutable preparation for one root TextMate grammar.
- Prepared
Language Stats - Bounded preparation statistics for a
PreparedLanguage. - Regex
Error - A regex parser diagnostic. Offsets count Unicode scalar values, not bytes.
- Render
Error - Render validation or writer failure.
- Rendered
Output - A rendered string together with the tokenizer completion status.
- RgbColor
- An opaque sRGB color with 8-bit channels.
- Scope
Stack Id - A compact reference to one complete, ordered TextMate scope stack.
- Scopes
- A borrowed iterator over exact, ordered TextMate scope names.
- Style
- Resolved foreground, background, and font decorations.
- Theme
- A parsed TextMate theme that can be shared across highlighting sessions.
- Theme
Error - Theme parsing or rule compilation failure.
- Theme
Rule - One caller-supplied TextMate theme rule.
- Token
- One token with a line-relative UTF-8 byte range and exact ordered scopes.
- Tokenized
Document - Tokenized logical lines and their aggregate completion status.
- Tokenized
Line - One tokenized logical line, from a document or an incremental call.
- Tokenizer
- A stateful tokenizer for one root TextMate grammar.
- Tokenizer
Options - Resource options applied to one TextMate tokenizer.
See
Self::defaultfor the default limits. - Tokenizer
State - Opaque incremental continuation state.
Enums§
- Bundle
Error Kind - Matchable cause of a bundled asset failure.
- Diagnostic
Error Kind - Matchable cause of a diagnostic regex operation failure.
- Error
- Error returned by a fallible Syntaxmate operation.
- Grammar
Error Kind - Matchable cause of a grammar failure.
- Grammar
Resource - The custom grammar resource whose configured limit was exceeded.
- Highlight
Status - Whether configured safety budgets allowed complete tokenization.
- Render
Error Kind - Matchable cause of a render failure.
- Theme
Error Kind - Matchable cause of a theme failure.
Functions§
- html_
stylesheet html - Generates a swappable theme stylesheet for
HtmlOptions::class_prefix. - render_
ansi ansi - Renders highlighted source using 24-bit ANSI SGR sequences.
- render_
ansi_ to ansi - Writes ANSI output to a caller-provided writer and returns tokenization status.
- render_
html html - Renders highlighted source as escaped HTML.
- render_
html_ to html - Writes escaped HTML to a caller-provided writer and returns tokenization status.
- style_
document - Resolves a tokenized document against a theme without retokenizing source.
Type Aliases§
- Result
- Result type for fallible Syntaxmate operations.