diff options
author | mia <mia@mia.jetzt> | 2024-06-03 21:35:16 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-06-03 21:35:16 -0700 |
commit | 044df10ee3a53deead2f17144c5b3def8f2b03ab (patch) | |
tree | cf65e6bd30e4256e8377b633106fd683089dd156 | |
parent | 40509ba913e52196b2dd7f3a733bec816d38bda0 (diff) | |
download | cgit-syntect-0.2.0.tar.gz cgit-syntect-0.2.0.zip |
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | 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); |