giallo 0.5.0

A code highlighter giving the same output as VSCode
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use giallo::{HighlightOptions, Registry, ThemeVariant};
use std::fs;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut registry = Registry::load_from_file("builtin.zst")?;
    registry.link_grammars();
    let ts_content = fs::read_to_string("src/fixtures/samples/simple.ts")?;

    let options = HighlightOptions::new("typescript", ThemeVariant::Single("vitesse-black"));

    // Loop to make highlighting dominate the profile
    for _ in 0..10000 {
        let highlighted_tokens = registry.highlight(&ts_content, &options)?;
        std::hint::black_box(highlighted_tokens);
    }

    Ok(())
}