Crate syntect

source ·
Expand description

Welcome to the syntect docs.

Much more info about syntect is available on the Github Page.

May I suggest that you start by reading the Readme.md file in the main repo. Once you’re done with that you can look at the docs for parsing::SyntaxSet and for the easy module.

Almost everything in syntect is divided up into either the parsing module for turning text into text annotated with scopes, and the highlighting module for turning annotated text into styled/colored text.

Some docs have example code but a good place to look is the syncat example as well as the source code for the easy module in easy.rs as that shows how to plug the various parts together for common use cases.

Modules

Methods for dumping serializable structs to a compressed binary format These are used to load and store the dumps used for fast startup times.
API wrappers for common use cases like highlighting strings and files without caring about intermediate semantic representation and caching.
Everything having to do with turning parsed text into styled text. You might want to check out Theme for its handy text-editor related settings like selection color, ThemeSet for loading themes, as well as things starting with Highlight for how to highlight text.
Rendering highlighted code as HTML+CSS
Everything about parsing text into text annotated with scopes. The most important struct here is SyntaxSet, check out the docs for that.
Convenient helper functions for common use cases: printing to terminal, iterating lines with \ns, modifying ranges of highlighted output

Enums

Common error type used by syntax and theme loading