30

How do you put a whole codeblock into spoiler text?

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 to get a multi-line code block that is invisible?

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

2 Answers 2

30

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!'

7
9

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

You must log in to answer this question.

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