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 block is not properly formatted when placed immediately after a list item

I was just submitting a new answer to an old question on Stackoverflow and noticed my code block was not being formatted as code.

It was originally positioned between a bulleted list and some plain text.

I discovered that when I cut and paste it to after the plain text it would be formatted correctly, but pasting it back in its old positions would always be without format. Adding blank lines around it made no difference.

Here's a screenshot of the same code block in both positions showing the first unformatted and the second correctly formatted:
formatting bug screenshot

Let's see what happens here:

var foo = 'bar'; // works
  • random
  • bullet
  • list

    var bar = 'foo'; // doesn't work

share|improve this question

marked as duplicate by Michael Mrozek, animuson, hippietrail, Bart, Bo Persson Nov 18 '12 at 4:18

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.

2 Answers 2

To have a code block immediately after a list, you can put a HTML comment between them:

 * item 1
 * item 2

<!-- -->

    code block

Result:

  • item 1
  • item 2
code block
share|improve this answer

Inside list markdown, you need to indent 8-spaces for code sample.

Example markdown:

- List Item

        /** code block */

Markdown output:

  • List Item

    /** code block */
    
share|improve this answer
    
This is handy to know, but it actually makes the code block itself part of a list item, which is not what I was trying to achieve. hammar's workaround hits the nail on the head though. –  hippietrail Nov 18 '12 at 3:31

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