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 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 19 +++++-------------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bf6abc8..04a1588 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,7 +43,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cgit-syntect" -version = "0.1.1" +version = "0.2.0" dependencies = [ "syntect", ] diff --git a/Cargo.toml b/Cargo.toml index 3bee23e..429c935 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cgit-syntect" -version = "0.1.1" +version = "0.2.0" edition = "2021" [dependencies] 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