ahaoboy / ansi2

Parse ansi strings and convert them to html and svg formats
6 stars 1 forks source link

support minify #11

Closed ahaoboy closed 1 month ago

ahaoboy commented 1 month ago

close: https://github.com/ahaoboy/ansi2/issues/10

-rw-r--r-- 1 ace None  77K Oct 23 17:04 win11.svg
-rw-r--r-- 1 ace None  35K Oct 23 17:04 nu-ls.svg
-rw-r--r-- 1 ace None  89K Oct 23 17:04 vitest.svg
-rw-r--r-- 1 ace None 8.5K Oct 23 17:13 win11.svg
-rw-r--r-- 1 ace None  15K Oct 23 17:13 nu-ls.svg
-rw-r--r-- 1 ace None  24K Oct 23 17:13 vitest.svg

image

 cr --features=cli --  -f=svg --font=https://fonts.cdnfonts.com/s/98875/JetBrainsMonoRegular.woff >  a.svg

image

ahaoboy commented 1 month ago

FiraCodeNerdFontMono-Regular.ttf

image

fdncred commented 1 month ago

Wow, this makes a huge difference. One small file went from 91.6kb to 38.3kb, then with -c went to 17.4kb. Nice work!

ahaoboy commented 1 month ago

Wow, this makes a huge difference. One small file went from 91.6kb to 38.3kb, then with -c went to 17.4kb. Nice work!

However, due to SVG font rendering issues, you may need to use the mono font, otherwise it will cause alignment issues. This problem has not been found on HTML yet.

ahaoboy commented 1 month ago

Wow, this makes a huge difference. One small file went from 91.6kb to 38.3kb, then with -c went to 17.4kb. Nice work!

If you are very concerned about the size, it is recommended to use html, which is much smaller than svg and will not have text rendering problems.

fdncred commented 1 month ago

What we're really trying to do is create a preview of all nushell themes and store them in a markdown file. I know md has limited html support, but I'll have to see what that is exactly. Our current idea is to put a svg in the markdown. I'm not sure how we'll get there from here because themes by their nature change all/most of the colors.

It looks like some of the optimizations could make html even smaller. There are a lot of css colors in that file.