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

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?

share|improve this question

marked as duplicate by jjnguy, Nathan Taylor, Grace Note, Jon Seigel, Jeff Atwood Feb 22 '11 at 19:03

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.

1  
See also: meta.stackexchange.com/questions/34292/… –  sth Feb 22 '11 at 18:22

1 Answer 1

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

  1. one
  2. two
Code !!!!
share|improve this answer
    
Excellent. Thanks! –  Nathan Taylor Feb 22 '11 at 18:24
    
@Nathan, you are welcome. Glad to help. –  jjnguy Feb 22 '11 at 18:24
    
Aaargh! Where's the source gone??! –  drkvogel Oct 1 at 15:24
    
@drkvogel The link got messed up when the site moved. It's fixed now. –  jjnguy Oct 3 at 18:32

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