Possible Duplicate:
Code block is not properly formatted when placed immediately after a list item

In my answer here, I wrote up a solution with step-by-step instructions. However, my numbered items are being reset to 1. This only happens in Item B and Item C. The first section of my answer doesn't suffer from this problem.

Is this a bug in markdown, or am I doing something wrong?

marked as duplicate by Cody Gray, Manishearth, Toon Krijthe, Tim Stone, Pops Apr 25 '12 at 17:35

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.


It's tricky to mix code blocks and numbered lists. You need to indent the code blocks 8 spaces (4 to put them "inside" the numbered list and 4 to make them code blocks):

This markup:

1. foo bar:


2. baz quux

produces this result:

  1. foo bar:

  2. baz quux

  • "You need to indent the code blocks 8 spaces (4 to put them "inside" the numbered list and 4 to make them code blocks)" Thanks, I never new that, it's something I struggled with on a few answers. +1 – vascowhite Apr 19 '12 at 7:27

I have edited your post you can see what I've done.

In addition to what Joachim said, you also had some fancy space character in some of your lines, for example:


As you can see although it's indented it's not recognized as code block because those are not ordinary space character (ASCII value 32) but something else. I verified it in this online tool which says those characters are NULL.

Replacing it with ordinary spaces:


Solved the issue of course. What IDE are you using? Maybe something there went funky.

  • Thanks! I'm using Eclipse and instructed it to convert tabs into spaces, but this may not be happening correctly... – Tony the Pony Apr 19 '12 at 7:32
  • @Tony any chance you're under Korean, Chinese, or Japanese language settings on your machine? I believe it cause such a "double space" character. – ShaWiz Apr 19 '12 at 7:36
  • No, just a basic US English install. What's a good tool to sanitize whitespace and tabs prior to posting? – Tony the Pony Apr 19 '12 at 7:42
  • @Tony that's really weird then. Not aware of any such tool, but if you see your code won't get formatted even with spaces it probably means fake spaces. – ShaWiz Apr 19 '12 at 8:03

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