# What is wrong with code snippets/blocks on Stack Overflow?

I wasn't following Meta Stack Overflow too closely so maybe something was changed that I'm not aware of. But each time I paste a snippet from a Python console I'm getting wrong formatting. What I'm doing wrong? It seems that '>>>' is confusing for Stack Overflow. I've tried to escape it with backslashes, and it was working fine in preview but doesn't work after the question is rendered.

I was able to observe that problem on: recent Chrome (Windows, Mac), Safari 4 (Mac).

Here is my recent answer I wasn't able to make right.

Funny, I think the snippets are rendered just fine on Meta Stack Overflow. Here is one:

>>> def throw(): raise Exception()
...
>>> a=1
>>> a=throw()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in throw
Exception
>>> a
1

-
Does this happen in stable/released/supported browsers? The team doesn't even look at bugs that only happen in beta/dev browsers. – Pops Nov 23 '10 at 19:53
@Popular it doesn't work on safari 4, mac os x. – Piotr Czapla Nov 23 '10 at 19:58
@Popular Good point. I've forgot to mention that :) – Piotr Czapla Nov 23 '10 at 19:58

That is a subtle case where the code-block was considered part of the bullet-list, so needed double indenting - otherwise it assumed the > was the markdown for a quoted section. I just added a new line between the "Check this out:" to break out of the bullet-list.

So with markdown:

- bullet 1
- bullet 2

this looks like a code block, but isn't; it is just more text in bullet 2

- bullet 3
- bullet 4

this *is* a code block in the bulletted list (in bullet 4)

finish bullet 4

this text is no longer part of the bullet-list

and hence this is a code-block

and to prove it:

• bullet 1
• bullet 2

this looks like a code block, but isn't; it is just more text in bullet 2

• bullet 3

• bullet 4

this *is* a code block in the bulletted list (in bullet 4)


finish bullet 4

this text is no longer part of the bullet-list

and hence this is a code-block

-
or you can add <-- separator --> if you need to disambiguate at the bottom of a list – Jeff Atwood Nov 24 '10 at 1:12