Legend-of-iPhoenix / cemetech-userstyle

iPhoenix's Spiffy Cemetech Userstyle
MIT License
10 stars 4 forks source link

Support Discord markdown #36

Open LogicalJoe opened 3 years ago

LogicalJoe commented 3 years ago

Someone suggested I do this so here it is. Shouldn't be hard to add but idk what to put here. ~~ ___ __ _ *** ** * || also `

Legend-of-iPhoenix commented 3 years ago

Where exactly do you want discord markdown supported- in posts with some kind of translator (probably building off of https://legend-of-iphoenix.github.io/markdown-bbcode-html/) or in SAX?

LogicalJoe commented 3 years ago

I was thinking in SAX since that sees it get used more often. It already seems to handle *text*-only messages in a somewhat broken way (intentionally for /me which uses _text_?)… but that's fine.

h
Legend-of-iPhoenix commented 3 years ago

I was thinking in SAX since that sees it get used more often. It already seems to handle *text*-only messages in a somewhat broken way (intentionally for /me which uses _text_?)… but that's fine.

h

This is a reasonable but incorrect understanding of what is happening. Unlike the Discord <=> IRC bridge, which does not understand /me and uses _text_, the Discord <=> XMPP bridge does emit /me commands. This is pretty weird but we'll roll with it.

You can see this by turning the userstyle off, you'll get something like

**[] [D] [iPhoenix] sent a message with /me on discord

Now, the sax rewrite special-cases the /me command to make it italic (sax-action class) and a separate tweak removes the [*] from messages because it's usually at least, like, triply redundant.

The net result here is that the message content (for your example, [D] [LogicalJoe] h) is italicized but the thing saying that it's an action (***[*]) is hidden.

Ideally sax.js would treat messages differently if they come through the bridge so this wouldn't happen (I agree with you that it is somewhat broken-looking) but if the bridge changes at all in the future I don't want it to make SAX look bugged-out.