From 044df10ee3a53deead2f17144c5b3def8f2b03ab Mon Sep 17 00:00:00 2001 From: mia Date: Mon, 3 Jun 2024 21:35:16 -0700 Subject: remove global background, shorten mode var --- src/main.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 734dfd1..0cb7261 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use syntect::{ }; fn main() { - match std::env::var("CGIT_SYNTECT_MODE").as_deref().ok() { + match std::env::var("MODE").as_deref().ok() { Some("compile") => compile(), Some("theme") => theme(), None | Some("") | Some("highlight") => highlight(), @@ -50,22 +50,13 @@ fn theme() { let mut css_gen = Vec::new(); let mut scopes_gen = Vec::new(); - let mut global_css = String::new(); let credit = match (theme.name, theme.author) { (None, None) => "".to_string(), - (None, Some(author)) => format!("/* theme by {author} */\n"), - (Some(name), None) => format!("/* {name} theme */\n"), - (Some(name), Some(author)) => format!("/* {name} theme by {author} */\n"), + (None, Some(author)) => format!("/* by {author} */\n"), + (Some(name), None) => format!("/* {name} */\n"), + (Some(name), Some(author)) => format!("/* {name} by {author} */\n"), }; - global_css.push_str(&credit); - global_css.push_str(".highlight {\n"); - if let Some(bg) = theme.settings.background { - global_css.push_str(" background-color: #"); - global_css.push_str(&hex_color(bg)); - global_css.push_str(";\n"); - } - global_css.push_str("}\n"); - css_gen.push(global_css); + css_gen.push(credit); for (idx, item) in theme.scopes.into_iter().enumerate() { let selectors_str = selectors_to_string(item.scope); -- cgit 1.4.1