ahaoboy / ansi2

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

Invalid svg created #1

Open ChrisJefferson opened 6 months ago

ChrisJefferson commented 6 months ago

Hi, this seems like a cool project :)

I decided to grab a random ansi file ( https://16colo.rs/pack/laz17/ll-darlaakacrystal.ans in my case) and try running ansi2svg on it. The resulting svg is invalid, I think because the original file has funcky characters?

Looking at the output, the first couple of lines are:

<text x="0px" y="32px" font-weight="normal" width="20px" height="32px" ><tspan>�</tspan></text>
<text x="20px" y="32px" font-weight="normal" width="20px" height="32px" ><tspan>/tspan></text>

So firstly we have a invalid character, but then much worse it looks like there is no character, and the < got eaten from the /tspan close?

ChrisJefferson commented 6 months ago

I had a quick check and that's not what is actually been outputted, there are terminal movement characters mixed in, which is confusing my viewing of the output using cat :) Still doesn't look good in an SVG! Maybe you didn't want to do the terminal movement things too?

ahaoboy commented 6 months ago

Thank you for your feedback. It seems that there is a lack of a parsing pattern that matches [0;1;30;47m. Adding a pattern should solve this problem.

ahaoboy commented 6 months ago

I think I found the problem. Take https://16colo.rs/pack/laz17/ll-darlaakacrystal.ans as an example. You must use a terminal with a width of 80 so that characters can wrap. However, I did not find the IBM VGA font it uses. When I use Windows terminal to output on my computer, I can see a fuzzy outline, but it is not clear because of the font. Can you output the correct image on your computer? And can you share the IBM VGA font file? image