8

Related (but not the same issue): Markdown formatting bug with code blocks in lists

Duplicate: Why is a code block not properly formatted when placed immediately after a list item?

The formatting guide says that you should indent code 4 spaces. However in this answer this is not working correctly. The problem seems to be when code directly follows, but is not part of a bulleted list.

I have replicated the bug below. Inserting a character between the end of the bullet and the code will cause it to appear correctly. See the second section for an example.

This seems to occur in both the preview and the posting.


  • List

    with new Importer .import "foo" .import "bar/baz" end with


  • List

Text

with new Importer
    .import "foo"
    .import "bar/baz"
end with
3

1 Answer 1

9

In a list, you need to indent the code by 8 spaces rather than 4.

After a list, if you really don't want to have text before some more code, you can use something like   to fake it:

  • List item

    Code within item
    
  • Next item

 

Code after the list

In general though, I'd suggest including some text to introduce the code after the list anyway, which works round the problem.

6
  • 1
    It is documented for (ordered) lists, in item 4 in "Advanced lists: Nesting".
    – kennytm
    Commented May 26, 2010 at 22:45
  • @KennyTM: Ah, yes. Will edit...
    – Jon Skeet
    Commented May 27, 2010 at 5:30
  • @Jon It's not supposed to be in the list, it's supposed to be after the list.
    – C. Ross
    Commented May 27, 2010 at 12:07
  • @C. Ross: Ah. The title confused me, and I see that was Jeff's edit. I suggest you edit the question to be somewhat clearer.
    – Jon Skeet
    Commented May 27, 2010 at 12:33
  • It's not "simply" eight spaces. It's 4 spaces plus 4 per indentation level :) (for when you nest lists)
    – badp
    Commented Jul 25, 2010 at 18:55
  • 2
    An HTML comment would actually be cleaner than using a dummy string like &nbsp. It counts as real enough to constitute content for separating the list from the code, but since it is a comment it is skipped so you don't end up with a huge gap between the two.
    – Grace Note StaffMod
    Commented Jul 25, 2010 at 19:41

You must log in to answer this question.

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