4

Possible Duplicate:
How to nest code within a list using markdown

  • If there is a list immediately followed by a code block the code block is not recognized as code
  • (Even though there is a newline between the two).

    int answer = 42;

    Note: This happens both in the WMD preview and in the final (server rendered) post.

marked as duplicate by Shog9, Kyle Cronin Jul 20 '09 at 19:51

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.

6

Inside a bullet list

To place a code block inside a list item, use eight spaces to format the code.

- item 1

        code

- item 2

Result:

  • item 1

    code
    
  • item 2

After a bullet list

To place a code block after a bullet list, add an empty comment between them.

- item 1
- item 2

<!-- -->

    code

Result:

  • item 1
  • item 2
code

Since Markdown doesn't have a way to explicitly end a list, there has to be something to make it start a new section of formatting.

  • Oh, I think maybe I was answering a different question. Oops. – mmyers Jul 20 '09 at 19:33
  • I will often just put in a <p/>, on it's own line. – Brad Gilbert Jul 20 '09 at 20:12
  • IMO, A better solution is to just indent by 8 spaces instead of 4 – user133440 Jun 12 '11 at 19:38

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