Overengineered “Shared-on-Mastodon” Notes

I’ve previously written about “hijacking” Share on Mastodon to crosspost “notes” in full, add to threads, and even attach audio or video instead of “just” images.

This time, I’ve cooked up a “simple” add-on plugin that combines these first two items, and converts HTML to Markdown, so that emphasized text shows up on Mastodon as *emphasized text*.

Before, I used Jetpack’s Markdown module to allow Markdown in notes, and the (saved) unprocessed Markdown was also what would be shared to Mastodon.

I’ve since dropped Jetpack and instead rely on IndieBlocks’ “Markdown” functionality to convert Markdown in “Micropub” posts—I often use IndiePass for Android to post quick notes to my site—to HTML. (I don’t really [need to] use Markdown inside WordPress’s admin interface, but it really comes in handy when I post from my phone.)

That way, my site displays “proper” HTML rather than raw Markdown, much like it did before.

But it also means I no longer have access to this “Markdown original,” and that whatever ends up being crossposted to Mastodon is stripped from what little additional semantics I had added.

So, why not (re)convert these few HTML tags to Markdown, just before crossposting to Mastodon?

To do so, I’m leveraging the PHP League’s HTML To Markdown package. And because of this dependency, I went the “proper plugin” route, rather than “mu-plugin” or similar.

The result can be found at https://github.com/janboddez/share-on-mastodon-notes; I don’t intend to “release” this elsewhere.