hifi / heisenbridge

a bouncer-style Matrix IRC bridge
MIT License
244 stars 34 forks source link

Improving formatting support and outputting well-formed HTML. #225

Closed tjaderxyz closed 2 years ago

tjaderxyz commented 2 years ago

Added support for color, hex color, reverse color, strikethrough and monospace.

Used https://modern.ircdocs.horse/formatting.html as reference.

I made it always output well-formed HTML by closing all tags whenever there's a control character and reopening them again. This leads to some unnecessarily verbose output, for example (I'm using [B] for \x02, [I] for \x1d, etc):

[B][I]bold italic would lead to <b></b><b><i>bold italic</i></b> [C]02[I]color italic would lead to <font mx-data-color='#00007f'></font><font mx-data-color='#00007f'><i>bold italic</i></font>

In my opinion these unnecessary empty tags are better than the current situation with malformed HTML. I could get rid of them by keeping track of what has been opened in a stack and only closing tags whenever necessary instead of always, but that would make the code a bit more complex. If you think it would be better I can implement it.

hifi commented 2 years ago

Tested and it works good, thanks!