cadence’s website.

Some changes will be applied after reloading.
Some changes will be applied after reloading.

Matrix spoilers

Today I did several things, including making a couple of additions to yesterday's post, but one of the more concrete things I did was add support for spoilers to my fork of the matrix-to-discord bridge.

Matrix lets you send custom HTML. Span elements with the data-mx-spoiler attribute will have their contents turned into a spoiler, where the text is blurred and you must click it to reveal it. However, there's no actual UI or Markdown for creating spoilers at the moment. You have to write that HTML by hand. Luckily for us, client support for viewing spoilers is pretty good. It works in Riot Desktop, RiotX, and FluffyChat. Probably Riot for iOS too, but I don't know. It doesn't work on Riot.im for Android or nheko.

Discord has spoilers too. In the "official" matrix-to-discord bridge, spoilers are transmitted both ways as non-spoilers, which as you can imagine is pretty bad. Today I modifed the bridge so that spoilers on Discord become the spoiler tags on Matrix.

But what about the Matrix clients that can't see native spoilers?

Interestingly, there's another thing you can do with custom HTML: <span style="color: #ff0000">. The standard way of sending custom colours is to use the font element, or the data-mx-color attribute. Using style is interestingly only supported in nheko and Riot.im on Android, and not Riot Desktop, RiotX, or FluffyChat.

This means that by using style combined with data-mx-spoiler, I can show clickable spoilers where they're supported, and highlight-to-reveal spoilers where they aren't supported. Remember back in the day on forums when you used BBCode to make the text colour the same as the background colour, and then people could highlight text if they wanted to read it? I've got the same thing going on here.

I think this is a great solution. My changes aren't public at the moment, because they're living on my server without git credentials, but one day I will sort out the different changes I've made and put them into commits somewhere.

I don't think the "official" matrix-to-discord bridge wants all of my changes, which is why I haven't already rushed to make a pull request.

There are still two significant problems:

  1. People on matrix-side can't create spoilers. Nothing's changed there.
  2. Spoiler images from discord-side are not protected in any way.

Regardless, I've made a great start.

— Cadence

A seal on a cushion spinning a globe on its nose.
Another seal. They are friends!