rburns / ansi-to-html

Convert ansi escaped text streams to html.
MIT License
351 stars 48 forks source link

Using `<a>` to support nested text-decoration #75

Open brettz9 opened 4 years ago

brettz9 commented 4 years ago

Builds on #57 .

I have switched here to using <a> instead of <span>.

The reason is that span will not allow overriding text-decoration styles (I had some underlining which wasn't getting disabled for this reason). (The same problem occurs in ansi-to-html's current state.)

I would have thought divs would work, but when using <div style="display: inline;">, though the Inspector (in Firefox or Chrome) shows the nested values as applying (e.g., a text-decoration: none), it still shows the content with an underline. This issue appears specific to text-decoration; the following can offer some more detail: https://stackoverflow.com/questions/1823341/how-do-i-get-this-css-text-decoration-override-to-work

But things work fine in both Firefox and Chrome when I change the elements to an <a> instead (without href). One problem is that the browser source shows this as invalid, I guess for having both flow and phrasing content, but I still think this may be the best solution.

You expressed concerns about this in #57 , but I think this is the only way to truly work with text-decoration overrides (as needed when overriding underline, strike-through, and overline). If you want this behind a flag, let me know.

(While I may be able to go back to using spans for the colors, I'm not sure if there are any cases where resetting a color should also reset the text-decoration. And I haven't added any tests for resetting command 0 to see its effect with text-decoration.)