-
Notifications
You must be signed in to change notification settings - Fork 437
Feature Request: Pretty-print SVG file and group elements with nested inherited properties to reduce file size #33
Comments
Prettier might be helpful for this: |
I created a pull request which should fix this issue, it should nicely format the resulting SVGs. @trevordmiller |
@trevordmiller You actually won't need prettier for this, as you could just use My concern and this issue was mostly about a pretty printing functionality, so that in step 2 somebody can trace down the properties that are unnecessary and can be grouped. Currently it's just a big mess. If you want an example: I could reduce the file size of the installation svg of lycheejs from around 8 MB (megabyte!) to around 362kB with this, and a lot of manual editing macros in VIM. |
Ah good points :) |
@cookiengineer Would you mind recording a terminal session with curl in a cast file ( |
@nbedos I don't have the original asciinema cast file left (recorded with termtosvg), but I have the fixed one. I'm trying to make a new one once I have a better internet connection (as it will literally take more than 60mins to install). I tried to make a reduced test case, as described below. The original cast file had two types of issues that appeared with a slow internet connection (slow meaning 3-5MB/s and large repos/downloads beyond 1200MB+):
Example to reproduce:
#!/bin/bash
RUNTIME_FILE="lycheejs-runtime.zip";
# XXX: Automated download of lycheejs-runtime.zip
if [ ! -f /tmp/lycheejs-runtime.zip ]; then
echo " (L) > Installing lychee.js Runtimes ...";
echo " (L) (This might take a while)";
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/Artificial-Engineering/lycheejs-runtime/releases/latest | grep "browser_download_url" | grep "$RUNTIME_FILE" | head -n 1 | cut -d'"' -f4);
DOWNLOAD_SUCCESS=0;
if [ "$DOWNLOAD_URL" != "" ]; then
DOWNLOAD_SUCCESS=1;
cd /tmp;
echo " (L) curl --location --retry 8 --retry-connrefused --progress-bar $DOWNLOAD_URL > /tmp/lycheejs-runtime.zip";
curl --location --retry 8 --retry-connrefused --progress-bar $DOWNLOAD_URL > /tmp/lycheejs-runtime.zip;
if [ $? != 0 ]; then
DOWNLOAD_SUCCESS=0;
fi;
if [ "$DOWNLOAD_SUCCESS" == "1" ]; then
mkdir /tmp/lycheejs-runtime-extracted;
echo " (L) cd /tmp/lycheejs-runtime-extracted";
echo " (L) unzip -qq ../lycheejs-runtime.zip";
cd /tmp/lycheejs-runtime-extracted;
unzip -qq ../lycheejs-runtime.zip;
if [ $? != 0 ]; then
DOWNLOAD_SUCCESS=0;
fi;
fi;
if [ "$DOWNLOAD_SUCCESS" == "1" ]; then
# XXX: Do nothing, just a test.
echo "Well, fuck. Didn't work.";
else
rm /tmp/lycheejs-runtime.zip 2> /dev/null;
fi;
if [ "$DOWNLOAD_SUCCESS" == "1" ]; then
echo -e "\e[42m\e[97m (I) > SUCCESS \e[0m";
else
echo -e "\e[41m\e[97m (E) > FAILURE \e[0m";
exit 1;
fi;
fi;
fi; |
@nbedos Lucky me, I found the ascii recording files and all steps in between the modifications on my old laptop. I added them to the gist: https://gist.github.com/cookiengineer/41d667b616abb0de0b8dda557ff4414f File Descriptions (from the README in there):
With the current HEAD of termtosvg, I could reproduce the following:
I also dumped all SVGs in their steps and pretty printed variants for comparison in this separate gist here: https://gist.github.com/cookiengineer/97082877faec8bd95b1378a7b7620237 After step 3 there was an additional step 4 where I was modifying the SVG file manually, and removing all unnecessary properties of all Pretty printing (for the sake of using |
@cookiengineer Thanks for the detailed report. I've made a few improvements to termtosvg regarding file size. Nothing drastic but the size of the examples at https://github.com/nbedos/termtosvg/tree/develop/examples are reduced by 10% to 25%. I've also added a command line option to enforce a minimum frame duration. Basically it merges consecutive frames together and helps control the size of recordings involving calls like I've not made a release yet, but all these changes are on the "develop" branch. |
Those changes are included in version 0.6.0 which was published a month ago, so I'm closing this issue. |
It would be amazing to have a pretty-printed variant of the SVG file when it is initially rendered. By pretty-printed I mean all
<text>
sections at least line-separated.Why? That way it would be possible to track the SVG animations via git! Imagine the possibilities ... when new releases come out, you could even see the differences in the SVG animation files.
The text was updated successfully, but these errors were encountered: