4

Formatting breaks if code follows a list:

  1. List item
  2. List item

    This is in a code block

    This does not work as expected

However, it works if between the list and the code

  1. List item
  2. List item

There is a line of normal text.

This is in a code block
# This does work as expected

Edit

To make this clear: This is not about nesting code in a list but about code following a (finished) list not working as expected (by me). To put it differently: Why is a list not considered finished despite of following empty lines? What do I have to do?

3
  • I had the same problem meta.stackexchange.com/questions/165215/…
    – asheeshr
    May 6, 2013 at 1:58
  • While I'm marking this as a duplicate, I agree with the duplicate - there should be a more intuitive way of doing this.
    – user206222
    May 6, 2013 at 2:07
  • @JasonSturges OK, at least I have learnt how to make list items with several paragraphs... :-) My intuition would consider more than one blank line (or even one non-"indented" "blank" line) to mark the end of a list. May 6, 2013 at 2:37

1 Answer 1

4

Code nested within a list must be indented 8-spaces.

  1. List item
  2. List item

    This is in a code block
    # This does work as expected
    

For a code block immediately following a list, you can put a html comment between them:

  1. List item
  2. List item
This is in a code block
# This does work as expected
2
  • But this is not to be nested. Thus I don't understand the consideration as a duplicate. The question is then: How can a list be finished (if not by empty lines) without getting anything additional (unwanted) shown? May 6, 2013 at 2:20
  • 2
    Put a html comment between the list and code block, as in: <!-- -->. May 6, 2013 at 2:25

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