Hello everyone!
This is a request for comments as well as a heads-up about an upcoming addition to the Markdown syntax in Flarum. If you have any comments, leave them here and I'll read everything. If you have nothing to add but you like the idea, you can also like this post and move on with your day. 🙂
First a bit of context: I'm the author of the text-formatting library used by Flarum. It handles all of the markup, including BBCodes and Markdown-style formatting, and enables Flarum extensions to add their own markup and features such as mentions or custom BBCodes. Changes to the core plugins automatically trickle down into Flarum. The plugin in charge of the Markdown syntax is named Litedown, and the name is used interchangeably to describe the plugin and the syntax of this Markdown flavour. The syntax itself is based off the original Markdown syntax and tries to support the most commonly requested/used extensions to the syntax. Which brings me to spoilers.
One of the most requested markup in forum software is spoilers. When they are not supported out of the box, they are usually added one way or another via an extension or via a user hack. Most of the time, spoilers can be created with a custom BBCode. Unfortunately, there is no consensus over a Markdown-like syntax for spoilers:
- StackExchange has supported block spoilers for a few years. They start with
>!
- Reddit added inline spoilers earlier this year. They use
>!
and !<
- Discord added inline spoilers earlier this year. They use
||
and ||
This is what they look like:
>! This is a block spoiler using StackOverflow's syntax.
> You're still inside the spoiler because only the first marker matters, unlike StackOverflow's syntax.
- Here's an >!inline spoiler!< using Reddit's syntax.
- Here's an ||inline spoiler|| using Discord's syntax.
Other than those three, GitHub and GitLab have chosen not to add a syntax for Markdown spoilers and instead enabled the <details>
and <summary>
HTML elements. Other websites and other Markdown flavours have discussed adding spoilers without coming to a decision.
I intend to add support for spoilers in the Litedown plugin in version 2.1 of the library. Currently, my intention is to support the three forms shown above. I think the block spoiler syntax makes a lot of sense. It looks and behaves like the normal quote syntax and it just works. Reddit's inline spoilers are a variation on that syntax and I think it fits nicely with the rest. I don't like Discord's syntax because the same marker is used to open and close the spoiler, and because programmers associate the double pipes with the boolean "OR". However, Discord is a popular app and users familiar with Discord may expect those spoilers to work in other Markdown-enabled text editors.
The implementation is ready, the new feature has virtually no effect on performance or software complexity, and I expect it to be fully compatible with existing spoiler extensions. I have looked at @Kvothe's extension and @sijad's extension and they should be fully compatible. The [spoiler]
BBCode's behaviour won't change and Markdown-style spoilers will match their BBCode counterpart.
You can try out the online demo here. The default style is very simple and may change slightly in the final version but if you want cool-looking spoilers you'll have to install an extension.
Similar implementations:
Other implementations:
Other discussions: