Select Graphic Rendition (SGR) parameters do support "several attributes {...} in the same sequence, separated by semicolons".
e.g.: \x[32;1m for bold+green. But ansi-to-svg fails to recognize them.
workaround for multi-SGR
split them into multiple individual ANSI SGR escape sequence:
sed -r 's@(\x1b\[)([[:digit:]]+);([[:digit:]]+)(m)@\1\3\4\1\2\4@g' terminal.txt > sgr-fixed.txt
spaces
There are a few issues with the way spaces are handled:
string of spaces between text are pasted verbatim in the output SVG. The trouble is that SVG, just like HTML (And markdown) doesn display multiple space but considers them as a single separator and and displays one blank them. Thus:
even if the SVG <text> boxes start at fixed X coordinates, the left-most text still has the leading space spaces left. Somewhat luckily the above bug cancels out this bug and thus it doesn't affect the output much (until one tries the workaround. then it need fixing).
<text x="84.01" y="14.55"> 72_UK
should be:
<text x="84.01" y="14.55">72_UK
(but both render the same, until workaround is used).
harmless cosmetic: there are useless spaces at the end of SVG </text> blocks:
77_EU </text>
could also be written
77_EU</text>
(but they are both synonymous and render the same).
workaround for space
One needs to:
use non-breaking spaces (e.g.: \u00A0) in the SVG output for string of multiple space.
remove leading spaces (because now the non-breaking spaces cause the text to shift around, even if the <text>block is already shifted using coordinates).
(optionnally) remove trailing space at the end of a block.
sed command:
sed -r 's@ +(</text)@\1@g;s@> +([[:alnum:]])@>\1@g;s@ @\xC2\xA0\xC2\xA0@g;s@\xC2\xA0 @\xC2\xA0\xC2\xA0@g' terminal.svg > fixedspaces.svg
The current version struggles with this terminal output:
It should look like this:
but there are two issues preventing this output:
multiple SGR attributes
Select Graphic Rendition (SGR) parameters do support "several attributes {...} in the same sequence, separated by semicolons". e.g.:
\x[32;1m
for bold+green. But ansi-to-svg fails to recognize them.workaround for multi-SGR
split them into multiple individual ANSI SGR escape sequence:
spaces
There are a few issues with the way spaces are handled:
gets renderered as: 72_UK 78_UK 92_UK 93_UK 76_SA 77_EU
<text>
boxes start at fixed X coordinates, the left-most text still has the leading space spaces left. Somewhat luckily the above bug cancels out this bug and thus it doesn't affect the output much (until one tries the workaround. then it need fixing).should be:
(but both render the same, until workaround is used).
</text>
blocks:could also be written
(but they are both synonymous and render the same).
workaround for space
One needs to:
\u00A0
) in the SVG output for string of multiple space.<text>
block is already shifted using coordinates).sed command: