Possible Duplicate:
Code blocks after a list, but not within a list in markdown. Is it possible?

I noticed an interesting little issue/challenge with the formatting applied to an ordered list which is followed by a block of code. It is impossible to create a correctly formatted block of code immediately following an ordered list, without forcing markdown to breakout of the ordered list formatting by adding unformatted text or a horizontal rule (I'm sure there are at least a couple other ways to terminate it which I have not tested).

Consider the following:

  1. Foo bar
  2. Some code

    function DoSomething() { }

In the above example, the code block is formatted with 4 spaces, but the code highlighter does not activate on it. Interestingly, there is a line-break after the first curly brace in the above code, but it does not get rendered in the output.

Now, modifying the example slightly:

  1. Foo bar
  2. Some code

function DoSomething() {   

As we can see, both the ordered list as well as the code block are formatted, but I had to add a horizontal rule to do so.

No amount of line breaks after the ordered list seems to terminate this effect. Is there any other way to break out of the ordered list formatting which does not require adding a visible element?


1 Answer 1


This has been discussed before (lots). See my source for the solution.

  1. one
  2. two
Code !!!!
  • Aaargh! Where's the source gone??!
    – drkvogel
    Oct 1, 2014 at 15:24
  • @drkvogel The link got messed up when the site moved. It's fixed now.
    – jjnguy
    Oct 3, 2014 at 18:32

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