Skip to main content

Crate syntaxmate

Crate syntaxmate 

Source
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§

AnsiOptionsansi
Options for render_ansi.
AssetLicense
License and source provenance for one bundled language asset.
BundleError
Bundled asset failure without exposing the private bundle format.
Catalog
Cheaply cloned, read-only access to a grammar bundle and its metadata.
CatalogSummary
Summary of the embedded bundle and its provenance.
CheckpointTable
Checkpoints used to replay incremental state near a requested viewport.
DiagnosticError
Diagnostic regex failure with the original pattern and execution context.
FontModifiers
A set of resolved font decorations.
GrammarError
Grammar failure with the originating scope when available.
GrammarId
Opaque identity of a grammar in one GrammarRegistry.
GrammarLimits
Resource limits applied while constructing a custom grammar registry.
GrammarRegistry
A collection of TextMate JSON grammars and their external include scopes.
HighlightSession
A reusable incremental highlighter. Input lines exclude newline terminators.
HighlightedDocument
Styled logical lines and their aggregate completion status.
HighlightedLine
One styled logical line, from a document or an incremental session.
HighlightedToken
One styled token with a line-relative byte range and exact ordered scopes.
Highlighter
A cheaply cloned, thread-safe highlighter backed by a Catalog.
HighlighterOptions
Cache and tokenizer limits for a shared Highlighter.
HtmlOptionshtml
Options for render_html.
JsonError
A JSON decoding failure with its original serde cause.
LanguageInfo
Borrowed metadata for one public language in a Catalog.
LimitExceeded
A configured grammar limit and the attempted resource usage.
MissingInclude
A missing local or external grammar include.
PreparedLanguage
Caller-owned immutable preparation for one root TextMate grammar.
PreparedLanguageStats
Bounded preparation statistics for a PreparedLanguage.
RegexError
A regex parser diagnostic. Offsets count Unicode scalar values, not bytes.
RenderError
Render validation or writer failure.
RenderedOutput
A rendered string together with the tokenizer completion status.
RgbColor
An opaque sRGB color with 8-bit channels.
ScopeStackId
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.
ThemeError
Theme parsing or rule compilation failure.
ThemeRule
One caller-supplied TextMate theme rule.
Token
One token with a line-relative UTF-8 byte range and exact ordered scopes.
TokenizedDocument
Tokenized logical lines and their aggregate completion status.
TokenizedLine
One tokenized logical line, from a document or an incremental call.
Tokenizer
A stateful tokenizer for one root TextMate grammar.
TokenizerOptions
Resource options applied to one TextMate tokenizer. See Self::default for the default limits.
TokenizerState
Opaque incremental continuation state.

Enums§

BundleErrorKind
Matchable cause of a bundled asset failure.
DiagnosticErrorKind
Matchable cause of a diagnostic regex operation failure.
Error
Error returned by a fallible Syntaxmate operation.
GrammarErrorKind
Matchable cause of a grammar failure.
GrammarResource
The custom grammar resource whose configured limit was exceeded.
HighlightStatus
Whether configured safety budgets allowed complete tokenization.
RenderErrorKind
Matchable cause of a render failure.
ThemeErrorKind
Matchable cause of a theme failure.

Functions§

html_stylesheethtml
Generates a swappable theme stylesheet for HtmlOptions::class_prefix.
render_ansiansi
Renders highlighted source using 24-bit ANSI SGR sequences.
render_ansi_toansi
Writes ANSI output to a caller-provided writer and returns tokenization status.
render_htmlhtml
Renders highlighted source as escaped HTML.
render_html_tohtml
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.