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.

2

1 Answer 1

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.

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

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