News for hackers. Stuff that matters.
Re:Show HN: Termtosvg – Record terminal sessions as SVG anim... by nbe on Tuesday July 03, 2018 @12:39PM (#17451622)
OP here. Sadly, SVG file size is not as small as I'd want it to be. The main problem is that a few attributes (x, y and lengthAdjust) have to be repeated on each text tag to position each character at the right place. I can't use CSS for this since those attributes are not styling attributes.

Using SVG definitions efficiently to avoid duplication is also not as easy as I thought it would be.

I have a few ideas on how to reduce file size, this is the next improvement I'm planning to work on.

For the examples shown at [1], file size ranges from 56kB to 252kB, the worst case scenario being lots of single characters with different colors.

[1] https://github.com/nbedos/termtosvg/blob/master/examples/exa...

Re:Show HN: Termtosvg – Record terminal sessions as SVG anim... by bonyt on Tuesday July 03, 2018 @01:36PM (#17452139)
How about with gzip? I feel like SVG files should compress well. I’d imagine most HTTP servers already just use gzip for these files.
Re:Show HN: Termtosvg – Record terminal sessions as SVG anim... by wes-k on Tuesday July 03, 2018 @01:43PM (#17452203)
Was curious myself. 252K -> 17K. Yes it compresses well :)
Re:Show HN: Termtosvg – Record terminal sessions as SVG anim... by fla on Tuesday July 03, 2018 @01:48PM (#17452247)
What about embedding a mini ECMAScript player and apply values to the DOM on the fly ?
Re:Show HN: Termtosvg – Record terminal sessions as SVG anim... by nbe on Tuesday July 03, 2018 @02:32PM (#17452614)
I'd rather stick to plain SVG for the animation part, in case ECMAScript is stripped from the SVG for security reasons. ECMAScript might be worth adding for additional features though (play/pause, progress bar, frame seeking...)
Re:Show HN: Termtosvg – Record terminal sessions as SVG anim... by ramses0 on Tuesday July 03, 2018 @07:04PM (#17454255)
Why not `zip blah.zip blah.html` and do it all as a single html doc?

http://pieroxy.net/blog/pages/lz-string/index.html

https://github.com/pieroxy/lz-string/blob/master/libs/lz-str...

~5kb gets you an lz-decoder, and you should be able to pull a bunch of trickery with blobs and compressed strings to get somewhere?

Re:Show HN: Termtosvg – Record terminal sessions as SVG anim... by kirjavascript on Wednesday July 04, 2018 @06:24AM (#17456329)
it's actually possible to reduce duplication in this case with the <g> element, see this example;

https://jsfiddle.net/2kc6tqy1/2/