# Hierarchical spoilers

When giving hints to a problem, sometimes it's beneficial to use the spoiler markers >!, however if the reasoning is longer and split into more than one hint, then this leads to bad user experience. For example, consider a post with two hints:

Hint 1:

Define $x = \text{(some complex formula)}$.

Hint 2:

Observe that $f(x) = 0$.

Then, if the user wishes to read the second hint, the first disappears (along with the complex formula inside). I know that one can select the post (i.e. highlight) so that the text becomes visible, but that's only a temporary solution.

In short, it would be great if we could have spoiler markers that would support hierarchical behavior. For example, we could write:

>! hint 1
>! >! hint 2


That could be solved also by toggle-button functionality (which also makes sense for mobile devices), but some say it's not such a good idea.

I suspect that's not easy to add, but might be worth considering if some other changes were to be made as well (e.g. fixing spoilers and MathJax interaction).

What do you think?

Edit:

A feature easier to implement: a serial behavior, which could be triggered by something like
<!-- spoilers: serial --> in fashion similar to stack-overflow's syntax highlighting
<!-- language: lang-or-tag-here --> feature.

• @user147263 I disagree, each SE community is different and I think that math.se could benefit from such feature. In particular, we allow homework questions, for which hints and spoiler markers are of great use (this is also the main use case, notably 10% of questions are tagged homework). – dtldarek May 16 '14 at 16:34
• Yes, hierarchical hint capability is one of the major pedagogical advantages of ebooks vs. static paper books. We really should exploit such capabilities more frequently here. Currently most answers here do not exploit the extra capabilities vs. paper books. – Bill Dubuque May 16 '14 at 18:39
• They both show up when i am using my phone... – user1729 May 16 '14 at 19:17
• If I click on hint 1 (instead of just hovering the mouse) it seems to stay around. Click again and then it disappears. – TravisJ Jun 6 '15 at 22:47
• Note that after clicking again to hide, the spoiler will disappear only after the pointer is moved outside the spoiler bounding box. It is possible that some of this functionality was implemented after the above question was asked. – Bill Dubuque Jun 28 '15 at 15:17
• @BillDubuque You are right, and I don't remember this behavior at the time of asking. Not exactly what I wanted, but the solution is good enough and simple, which is very important. – dtldarek Jun 28 '15 at 20:13
• This must be out of date — I touch the first and it shows; I touch the second and it shows too. The first does not disappear. Isn't this something we want “fixed” on the html/css level of page rendering? – JDługosz May 28 '17 at 3:29

The toggle button functionality is more or less available through the MathJAX extension action. Though it is more suitable for displaying alternate math formulas instead of displaying a paragraph of text. Personally, I can't think of any good way to utilize this functionality.

$$\require{action} \toggle{ \begin{array}{cl} & \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{ \verb/click me for hint/} \end{array} }{ \begin{array}{cl} 1. & \text{Define }x \text{ = (complex formula)}\\ & \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{ \verb/more hint.../} \end{array} }{ \begin{array}{cl} 1. & \text{Define }x\text{ = (complex formula)}\\ 2. & \text{Observe } f(x) = 0\\ & \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{ \verb/That's it, thanks for wasting your time!/} \end{array} } \endtoggle$$

Code implementing above behavior follows

$$\require{action} \toggle{ \begin{array}{cl} & \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{ \verb/click me for hint/} \end{array} }{ \begin{array}{cl} 1. & \text{Define }x \text{ = (complex formula)}\\ & \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{ \verb/more hint.../} \end{array} }{ \begin{array}{cl} 1. & \text{Define }x\text{ = (complex formula)}\\ 2. & \text{Observe } f(x) = 0\\ & \bbox[2pt,color:red;border-radius:3px;box-shadow:4px 4px 8px firebrick]{ \verb/That's it, thanks for wasting your time!/} \end{array} } \endtoggle$$

• I can think of a "proper" use of a toggle. To toggle colorations (or other forms of emphasis) of paths through a diagram indicating in turn a first path/second path/etc. For instance, have you ever traced a commutative diagram with your finger while reading a proof. – Karl Kroningfeld May 17 '14 at 1:49
• Also, you can implement toggles that don't allow you to return to the original "click me" message after spoiling: $$\require{action}\toggle{\text{Click me}}{\toggle{1+1=2}{1+1=2}\endtoggle}\endtoggle$$ – Karl Kroningfeld May 17 '14 at 1:55
• This is great, not exactly what I would wish for, but at least partially solves the problem. – dtldarek May 21 '14 at 12:03
• $$\newcommand{\myspoiler}[2][padding: 4px;]{ \style{background-color: rgb(240,240,240);#1}{\class{spoiler}{#2}}} \text{ A test of alternate implementation of } \myspoiler[padding: 8px;]{\text{spoiler!}}$$ – achille hui Mar 7 '15 at 15:31
• Guys. Assembly code is more transparent than this!!! – steven gregory Jun 28 '15 at 14:43
• @Steven: Not if you use the AT&T convention! :-) – Asaf Karagila Jun 28 '15 at 16:43
• For ordinary posts, I can click "edit" to see the source code. Is there something similar to this for comments (I would like to see the code used in the comments above). – PhoemueX Jul 26 '15 at 7:00
• @PhoemueX right click on the piece marked up by MathJAX and then choose "Show Math As --> TeX Commands". – achille hui Jul 26 '15 at 13:21
• @PhoemueX Or for the entire comment markdown, see meta.stackexchange.com/questions/286234 if you don't want to use the API directly – Bart Michels May 28 '18 at 14:29

Clicking a hint makes it stay visible even when the mouse stops hovering it (clicking it again makes it fade again). Thus one can click the first hint, and only then click the second. Hierarchical hints (or a horrifying mathjax hack) are not necessary.

• Horrifying, but incredibly awesome. – Asaf Karagila Jun 28 '15 at 16:43
• I don't remember that feature to be available at the time, but I'm glad it is working now (esp. it's much better for mobile devices). – dtldarek Jun 28 '15 at 20:15
• You might consider accepting this answer; the MathJax hack was an interesting piece of technical wizardry but (given that this feature seems to exist now) it will be much simpler to write ordinary spoilers and let people click on them. – David K Jun 28 '15 at 21:13

This feature request is outdated!

It’s from the time that spoilers showed when you hovered over them, but only during the hover. Now spoilers show when you click them, and stay visible as long as the page is opened.

(Someone corrected an outdated link and bumped this question to the front page.)