giallo 0.4.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
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 jquery_content = fs::read_to_string("src/fixtures/samples/jquery.js")?;

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

    let highlighted_tokens = registry.highlight(&jquery_content, &options)?;

    // Use the result to prevent optimization from removing the work
    std::hint::black_box(highlighted_tokens);

    Ok(())
}