This question already has an answer here:

Following the Do we want the “spoiler” feature turned off? thread on meta.tex.sx, it's clear that the spoiler markup has a wrinkle or two that I didn't at first appreciate. For information's sake, the spoiler feature is contentious because it collides with the syntax for Latex errors.

Is there a precise description of when a blockquote will be treated as a spoiler?

Two related threads containing some information on the syntax:

  1. Implement the <spoiler> tag
  2. Add markdown support for hidden-until-you-click text (aka spoilers)

marked as duplicate by gnat, PolyGeo, Awesome Poodles, Infinite Recursion, Ward Dec 22 '15 at 7:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • This is by no means an answer but I was playing with it in the formatting sandbox and found that if you insert a blank line anywhere within the block quoted text, the spoilers are completely disabled for that block. Could be used as a temporary workaround until the feature is refined or is otherwise changed. – Jeff Mercado Dec 21 '10 at 8:58
  • @Jeff - that is intended behavior. If a blockquote contains a line that doesn't start with a ! its not a spoiler. – Kevin Montrose Dec 21 '10 at 9:06
  • Likewise, you can throw in some non-rendered content on an extra > line that will be ignored, and it'll prevent the spoiler-fication (since it's just a blockquote then). – Tim Stone Dec 21 '10 at 9:06

The way spoiler works is as follows.

If each line in a blockquote (built via >) begins with a ! it will be treated as a spoiler.


>! This is a spoiler

This is a spoiler

>! But this is  
> not a spoiler

! But this is
not a spoiler

>! A multi-line spoiler  
>! has ! multiple times

A multi-line spoiler
has ! multiple times

>! Alignment  
> ! has no effect  
 >  ! on spoilers  

has no effect
on spoilers

Due to wrinkle in how blockquotes are generated, leading white space is pretty pointless.

> ! <- still a spoiler

<- still a spoiler

The actual code expects very specific html (this a "post markdown" process). In particular, omitting the inner <p> will dodge "spoiler-ification".

The only way to guarantee a blockquote becomes a spoiler is to use the explicit >! syntax.

Prior to implementing this, I did actually check for posts that would be affected by this syntax (on SO its under one-tenth of a percent*). Even on TeX, (where ! is rather likely to come up as a first character) it is exceedingly rare (lower than SO levels). People seem very biased towards using code tags.

I'm not saying there aren't any, but any new syntax is going to catch somebody.

*Admittedly, I'm regex-ing wildly through lots of data, there is some room for error. Pretty sure I'm erroring on the side of over counting affected posts, though.

  • Do the !s have to be vertically aligned? – Charles Stewart Dec 21 '10 at 8:59
  • @Charles - no, they just need to be the first non-whitespace character after the >. – Kevin Montrose Dec 21 '10 at 9:01
  • 2
    I tried to add an image in the spoiler, but the image is always shown. Only text is hidden. I added this: ` >! Spoiler ![Image description][3] Hello`. The text "Spoiler" and "Hello" was only shown on mouseover, but the image in the middle was shown always. – awe Sep 11 '12 at 8:52
  • 1
    The multi-line spoiler isn't working for me. It's all on one line. – Tony Ennis Nov 20 '15 at 3:35
  • @awe >! [![image][1]][1] this works in image, and image description [1]: https://i.stack.imgur.com/9BTi2.jpg – J M Sep 14 '17 at 5:43
  • 2
    This actually just works as a hover but is there a collapsable spoiler in markdown? – Thielicious Nov 22 '17 at 11:28

Not the answer you're looking for? Browse other questions tagged .