mfontanini / presenterm

A markdown terminal slideshow tool
https://mfontanini.github.io/presenterm/
BSD 2-Clause "Simplified" License
1.19k stars 29 forks source link

Color output breaks line length #272

Closed henryiii closed 1 month ago

henryiii commented 2 months ago

If a command produces colored output, it messes up the code box. It almost works, I think it's just counting the control sequence length incorrectly.

Screenshot 2024-06-29 at 12 52 37 AM

mfontanini commented 2 months ago

I'll need to look at this, I never tried colored output and I'm not surprised it breaks. One issue for sure is that the escape sequences are considered normal text so that causes what you see in the image where the coloring of each line at the end is missing. But yes, there's clearly more going on.

DrunkenToast commented 2 months ago

If I find the time I wouldn't mind taking a jab at this issue. I believe we can just escape ansi codes before calculating the padding, something like this crate might do the job if we don't mind introducing dependencies.

mfontanini commented 2 months ago

If you'd like to give it a shot, go for it. The execution output is handled here and the attribute you want to change should be this one. Ideally we'd compute the real length only once and then store it so this thing would need to have more than just a string.

mfontanini commented 1 month ago

This was fixed in #315.

henryiii commented 1 month ago

Thanks!

henryiii commented 1 month ago

That's a link to an issue, by the way, not a PR. I think you meant #316.