syntect_assets/lib.rs
1//! `syntect-assets` contains [syntect](https://github.com/trishume/syntect) syntax and theme assets from [bat](https://github.com/sharkdp/bat).
2//!
3//! The main struct of this crate is `HighlightingAssets` which can be used in `syntect`.
4//!
5//! "Hello world" example:
6//! ```rust
7//! use syntect::easy::HighlightLines;
8//! use syntect::highlighting::Style;
9//! use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings};
10//! use syntect_assets::assets::HighlightingAssets;
11//!
12//! // Load these once at the start of your program
13//! let assets = HighlightingAssets::from_binary();
14//! let ss = assets.get_syntax_set().unwrap();
15//! let syntax = ss.find_syntax_by_extension("rs").unwrap();
16//! let theme = assets.get_theme("OneHalfDark");
17//!
18//! let mut h = HighlightLines::new(syntax, theme);
19//! let s = "pub struct Wow { hi: u64 }\nfn blah() -> u64 {}\n";
20//! for line in LinesWithEndings::from(s) { // LinesWithEndings enables use of newlines mode
21//! let ranges: Vec<(Style, &str)> = h.highlight_line(line, ss).unwrap();
22//! let escaped = as_24_bit_terminal_escaped(&ranges[..], true);
23//! print!("{}", escaped);
24//! }
25//! ```
26
27#![deny(unsafe_code)]
28
29
30pub mod assets;
31pub mod assets_metadata {
32 pub use super::assets::assets_metadata::*;
33}
34
35pub(crate) mod syntax_mapping;
36mod error;
37