diff --git a/ansi2/src/main.rs b/ansi2/src/main.rs index a2ab7d9..6b4e8eb 100644 --- a/ansi2/src/main.rs +++ b/ansi2/src/main.rs @@ -71,14 +71,16 @@ fn main() { let s = String::from_utf8_lossy(&buf); let mut output = match format { - Format::Svg => to_svg(s, theme, width, base64, mode, args.light_bg, args.dark_bg), + Format::Svg => { + let mut svg = to_svg(s, theme, width, base64, mode, args.light_bg, args.dark_bg); + if args.compress { + svg = osvg::osvg(&svg).expect("compress error"); + } + svg + } Format::Html => to_html(&s, theme, width, base64, mode, args.light_bg, args.dark_bg), Format::Text => to_text(&s, width), }; - if args.compress { - output = osvg::osvg(&output).expect("compress error"); - } - println!("{}", output); } diff --git a/assets/update.sh b/assets/update.sh index a75fe62..9187b64 100755 --- a/assets/update.sh +++ b/assets/update.sh @@ -2,7 +2,7 @@ for i in win11 vitest 8bit-color 24bit-color nu-ls do - cat "$i.ans" | node ../ansi2-wasm/bin/cli.js -c > "$i.svg" + cat "$i.ans" | node ../ansi2-wasm/bin/cli.js > "$i.svg" cat "$i.ans" | node ../ansi2-wasm/bin/cli.js --mode=light -c > "$i-light.svg" cat "$i.ans" | node ../ansi2-wasm/bin/cli.js --mode=dark -c > "$i-dark.svg" echo "$i done" diff --git a/readme.md b/readme.md index 75c9071..3949f07 100644 --- a/readme.md +++ b/readme.md @@ -81,6 +81,8 @@ neofetch | ansi2 --format=svg --light-bg=#FFFFFF --dark-bg=#181818 > neofetch.sv Compressing using [osvg](https://github.com/ahaoboy/osvg) and [svgo](https://github.com/svg/svgo), this will increase the running time by several seconds, but can save half of the storage space. +Note: Since svgo removes media queries and css variables, it is only recommended to use it in a specific mode. + ```bash neofetch | ansi2 --format=svg --compress > neofetch.svg neofetch | ansi2 --format=svg -c > neofetch.svg