# Block-style spoiler tags

**URL:** <https://meta.discourse.org/t/block-style-spoiler-tags/31266>\
**Category:** Plugin\
**Tags:** deprecated\
**Created:** [July 21, 2015, 5:08pm UTC](https://meta.discourse.org/t/block-style-spoiler-tags/31266 "2015-07-21T17:08:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukegb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lukegb/32/114920_2.png) [@lukegb](https://meta.discourse.org/u/lukegb)\
**Post date:** [July 21, 2015, 5:08pm UTC](https://meta.discourse.org/t/block-style-spoiler-tags/31266/1 "2015-07-21T17:08:34Z")

</div>

Need support for `[spoiler]` tags which are actually misnamed and are actually collapsed-block tags? Look no further!

(yes, this is basically the same as the built-in `[details]` block, you should try to convince your users to use those instead!)

[https://github.com/lukegb/discourse-bbcode-spoiler](https://github.com/lukegb/discourse-bbcode-spoiler)

## Screenshots

 ![](https://global.discourse-cdn.com/meta/original/3X/f/4/f407fdc043ed890d1c568c3f4a059f0d84d730aa.png)

( **FLARD** is an injoke on my forum)

## Syntax

`[spoiler]contents go here[/spoiler]` if you want the default title.

`[spoiler=Button title]contents go here[/spoiler]` if you don’t.

## Features

- Fully supports nested `[spoiler]` tags and markdown (so HRs, headers, etc, work fine)
- Removes the spoiler contents from emails which are sent. (This needs rethinking, but for my usecase it’s OK since we don’t have reply-via-email turned on yet)
- Always shows in expanded mode in post previews to allow for easier editing
- Configurable default spoiler text (i.e. what happens if no button override text is specified)

## Known issues

- Currently recursively invokes the full Markdown-\>JsonML transpiler instead of letting Discourse pass me the inner JsonML. It (Discourse) seems to have weird issues with block-level Markdown tags at the moment, but that could just be me messing up.
- Horrific UUID generation stuff in order to easily refer to the checkbox.
- Currently overrides `[spoiler]` and not `[hide]` and this is not configurable (at the moment). PRs welcome, but I’m planning to come back to this in a bit.
- Probably(?) doesn’t scroll properly in preview mode.

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [July 22, 2015, 2:49am UTC](https://meta.discourse.org/t/block-style-spoiler-tags/31266/2 "2015-07-22T02:49:41Z")

</div>

On line 58, I think you can use `this.toTree(inner)` instead - [discourse-bbcode-spoiler/assets/javascripts/bbcode\_spoiler\_dialect.js at 9716d81686d0ef728409be53fce545a37cd9224e · lukegb/discourse-bbcode-spoiler · GitHub](https://github.com/lukegb/discourse-bbcode-spoiler/blob/9716d81686d0ef728409be53fce545a37cd9224e/assets/javascripts/bbcode_spoiler_dialect.js#L58)

---

<div class="post-metadata">

**Author:** ![jakedwhitaker](https://avatars.discourse-cdn.com/v4/letter/j/8e7dd6/32.png) [@jakedwhitaker](https://meta.discourse.org/u/jakedwhitaker)\
**Post date:** [August 29, 2015, 3:57pm UTC](https://meta.discourse.org/t/block-style-spoiler-tags/31266/3 "2015-08-29T15:57:39Z")

</div>

One issue I’ve encountered: block spoilers cannot read links that are outside of the block spoiler, which makes it difficult to use them for organization as a collapsible text feature. You can manually move the links, yes, but adding new ones moves them all back to the bottom of the post.

---

<div class="post-metadata">

**Author:** ![lukegb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lukegb/32/114920_2.png) [@lukegb](https://meta.discourse.org/u/lukegb)\
**Post date:** [August 29, 2015, 4:20pm UTC](https://meta.discourse.org/t/block-style-spoiler-tags/31266/4 "2015-08-29T16:20:16Z")

</div>

> [@jakedwhitaker](#):
>
> One issue I’ve encountered: block spoilers cannot read links that are outside of the block spoiler, which makes it difficult to use them for organization as a collapsible text feature. You can manually move the links, yes, but adding new ones moves them all back to the bottom of the post.

Yeah, I know about [this one](https://github.com/lukegb/discourse-bbcode-spoiler/issues/1). The workaround is to use non-ref style links, but it’s a bit of a pain since the Markdown editor uses them by default.

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [May 4, 2020, 6:32pm UTC](https://meta.discourse.org/t/block-style-spoiler-tags/31266/5 "2020-05-04T18:32:45Z")

</div>

Marked as #plugin:broken-plugin. All functionality except the CSS theme to draw a box around collapsed-details is built-in now.

If you think you need this for a import/migration, try doing this instead:

```bash
rake posts:remap'[\[spoiler\],\[details=Spoiler\]]'
rake posts:remap'[\[spoiler=,\[details=]'
rake posts:remap'[\[/spoiler\],\[/details\]]'

```

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [June 18, 2024, 3:40pm UTC](https://meta.discourse.org/t/block-style-spoiler-tags/31266/6 "2024-06-18T15:40:26Z")

</div>


