Module text_style::syntect[][src]

Expand description

Conversion methods for syntect’s text style types.

Requires the syntect feature.

This module implements these conversions:

Example

Converting highlighted ranges to styled strings and rendering them:

use syntect::{easy, parsing, highlighting, util};

let ps = parsing::SyntaxSet::load_defaults_newlines();
let ts = highlighting::ThemeSet::load_defaults();

let syntax = ps.find_syntax_by_extension("rs").unwrap();
let mut h = easy::HighlightLines::new(syntax, &ts.themes["base16-ocean.dark"]);
let s = "pub struct Wow { hi: u64 }\nfn blah() -> u64 {}";
for line in util::LinesWithEndings::from(s) {
    let ranges: Vec<(highlighting::Style, &str)> = h.highlight(line, &ps);
    text_style::ansi_term::render_iter(std::io::stdout(), ranges.iter())
        .expect("Could not render line");
}