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?

marked as duplicate by Aza, Lucifer, animuson, Matt, hims056 May 6 '13 at 3:37

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.

migrated from meta.serverfault.com May 6 '13 at 1:54

This question came from our discussion, support, and feature requests site for system and network administrators.

  • I had the same problem meta.stackexchange.com/questions/165215/… – asheeshr May 6 '13 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. – Aza May 6 '13 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. – Hauke Laging May 6 '13 at 2:37
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
  • 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? – Hauke Laging May 6 '13 at 2:20
  • 2
    Put a html comment between the list and code block, as in: <!-- -->. – Jason Sturges May 6 '13 at 2:25

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