[BBCode] Spoiler Text

Started by snow, Apr 17, 2025, 10:20 PM

Previous topic - Next topic

If we had a [spoiler] tag, what would it be?

Hide inline text (Discord-like)
0 (0%)
Hide blocks of text (old school)
0 (0%)
Both???
2 (100%)

Total Members Voted: 2

snow

Adjacent to [secret], I'd love to have a [spoiler] tag for, well, spoilery text. My first idea is something like the traditional block format using summary/details, but I feel that's not the "norm." Nowadays spoilers are done by "redacting" the text and making it visible on click.

It's not like we can't support both, but the BBCode renderer isn't particularly context-aware, and I don't want to make the types of tags too confusing for others. But if anyone has an idea for how to make it less confusing (or feels one or the other is unneeded), I'd like to hear it!

Skirmisher

If we already wanna have inline monospace text and code blocks, then I mean, y'know, why not both here too,

(it would be cute if the block style used a button as the toggle widget, but that's just my nostalgia bias)

snow

Quote from: Skirmisher on Apr 18, 2025, 05:04 AMIf we already wanna have inline monospace text and code blocks, then I mean, y'know, why not both here too,

The main problem is, what tag should we use for that? I'm worried about a <pre/> vs <code/> situation where it can get confusing on which is inline or block :-\

Quote from: Skirmisher on Apr 18, 2025, 05:04 AM(it would be cute if the block style used a button as the toggle widget, but that's just my nostalgia bias)

Hmm, I'll have to see how much I can do there. I want to avoid JS if I can help it, so I was just going to do a summary/details thingo.

snow

It's been a bit, but this has been the main thing I've been working on! Here's a bit of a preview:

You cannot view this attachment.

The basic idea is as follows:

  • Use [spoiler][/spoiler] to hide a spoiler, setting [spoiler=Some Text][/spoiler] to define the title text to "Some Text"
  • Use [noguest][/noguest] to restrict text to logged-in users. This is automatically opened, but still collapsible if you're taking a screenshot and want to hide it. (credit to @iliana for the idea)

The trickiest part so far was getting nesting to work properly, but now it's good! I just have to work on dark mode support, and then it should be good enough for prod.

Skirmisher

Yaaaaaay good job and thank you  :eggbug_smile_hearts:

snow

Done! ;D

Here's an example:
"Spoiler Alert" by They Might Be Giants