What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 Stack Exchange communities.

I sometimes find I want to put a whole codeblock into spoiler text. This is useful in answering homework tagged questions, where I intend to say something along the lines of Now try and implement this part yourself, and mouseover the section below for some ideas if you get stuck. Forgive me if this has been covored before, I searched but didn't find the same question and I couldn't see it in the markup advanced help section either.

This is normal text

This is spoiler text

This is one line of visible code

This is one line of invisible code

def visible_function():
  print 'hello world'

But can I get a multi-line code block that is invisible? I couldn't figure out the markup syntax for it.

def invisible_function():
  print 'Eeek! I feel so naked!'
share|improve this question
    
This still does not seem to be possible, on SO at least, and meta.stackexchange.com/questions/112305/… does not seem to have been resolved. I'd love to be able to give answers on SO using this technique from Math. –  Jason C Mar 22 at 17:00
add comment

2 Answers

up vote 12 down vote accepted

You can do it using HTML

>! <pre><code>def invisible_function():
>!   print 'Eeek! I feel so naked!'</code></pre>

This results in some extra padding, though.

def invisible_function():
   print 'Eeek! I feel so naked!'

share|improve this answer
3  
I tried your approach on SO but it didn't work:-( –  Christoph Mar 15 '12 at 16:59
    
Doesn't work on math.SX, either. –  JeffE Apr 30 '12 at 12:42
    
@Christoph: It looks like the CSS for spoilers conflicts with the syntax highlighting (which is disabled here). –  hammar Apr 30 '12 at 12:59
2  
@Christoph, there's a bug report for that: Code samples inside of spoilers are still visible on some sites. –  Arjan Feb 2 '13 at 19:03
add comment

This may not be the right way to do this. I was just trying different combinations with the syntax and came up with one possible way to include multiline code within the spoiler section using the HTML <pre> tag.

By default, the text is not shown as per spoiler behavior.

text hidden

Multiline code displayed onmouseover.

multiline code

Example

SELECT  *
FROM  dbo.Spoiler
WHERE NumberOfLines > 1

share|improve this answer
add comment

You must log in to answer this question.

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