Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 157 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Possible Duplicate:
Code block is not properly formatted when placed immediately after a list item

As part of this answer on SO I entered a code block. The code however was not being displayed in the markup, it was just plain text with no line breaks. I tried multiple times copying and pasting it in, entering tabs/spaces for the indents and highlighting it and clicking the 'Code Sample' button.

Here is an example of the failure case...

  1. Here is a list item. The code direclty after is not formatted correctly.

    import java.text.SimpleDateFormat import java.text.DateFormat

    Date timeDate1 = new Date().parse("dd-MM-yyyy HH:mm:ss Z","18-05-2012 09:29:41 +0800") Date timeDate2 = new Date().parse("dd-MM-yyyy HH:mm:ss Z","18-05-2012 09:29:21 +0900")

After further testing it seems that if you enter source code directly after a list then the code will not be formatted correctly.

How do correctly display code blocks after a bullet list?

share|improve this question

marked as duplicate by jadarnel27, a cat, balpha May 24 '12 at 12:34

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.

Enter a dash - character on it's own line after the bullet list.

  1. The code below works (with the dash character the code block displays correctly formatted). E.g.:

-

import java.text.SimpleDateFormat
import java.text.DateFormat

Date timeDate1 = new Date().parse("dd-MM-yyyy HH:mm:ss Z","18-05-2012 09:29:41 +0800")
Date timeDate2 = new Date().parse("dd-MM-yyyy HH:mm:ss Z","18-05-2012 09:29:21 +0900")

This however seems like a work around. I would think it should be possible to display code after a list without needing to add an extra unnecessary character.

share|improve this answer
2  
It is, just indent 8 spaces, rather than 4. – Cody Gray May 24 '12 at 12:59
2  
@TheEstablishment But that makes the code block part of the last list item. A <!-- comment --> between list and code block works without displaying a stray extra character (but is more work than typing a single dash). – Daniel Fischer May 24 '12 at 13:50

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