use std::{ collections::HashMap, fmt::Write, fs, io::{self, Write as _}, path, str, sync::atomic::AtomicUsize, time::Instant, }; use anstyle::{Ansi256Color, AnsiColor, Color, Effects, RgbColor}; use anyhow::Result; use lazy_static::lazy_static; use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; use serde_json::{json, Value}; use tree_sitter_highlight::{HighlightConfiguration, HighlightEvent, Highlighter, HtmlRenderer}; use tree_sitter_loader::Loader; pub const HTML_HEADER: &str = " Tree-sitter Highlighting "; pub const HTML_FOOTER: &str = " "; lazy_static! { static ref CSS_STYLES_BY_COLOR_ID: Vec = serde_json::from_str(include_str!("../vendor/xterm-colors.json")).unwrap(); } #[derive(Debug, Default)] pub struct Style { pub ansi: anstyle::Style, pub css: Option, } #[derive(Debug)] pub struct Theme { pub styles: Vec