Registry / utility / syntect

syntect

JSON →
library5.3.0rscratesunverified

Library for high quality syntax highlighting and code intelligence using Sublime Text's grammars.

# Cargo.toml [dependencies] syntect = "5.3.0"
INSTALL
IMPORT
SIG · SYNTECT
S
syntect
utilityrustv5.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

highlighted_html_for_string
use syntect::html::highlighted_html_for_string;

Highlights Rust source code and returns HTML.

use syntect::parsing::SyntaxSet; use syntect::html::highlighted_html_for_string; fn main() { let ss = SyntaxSet::load_defaults_newlines(); let syntax = ss.find_syntax_by_extension("rs").unwrap(); let html = highlighted_html_for_string("fn main() {}", &ss, syntax); println!("{}", html); }
Debug
Known issues
gotchaLoading default syntax sets can be slow; consider caching.
fix
Use SyntaxSet::load_defaults_newlines() once and reuse.
affects: >=5.0.0
Upgrade
Version history
5.3.0latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
syntect — cargo add syntect · libregistry