3

There's one annoying bug:

Try to do write a list and then add some code. If you don't place another line of text in between, the code section breaks and the first and last lines jump out of the formatting:

Testcases:

  1. This is
  2. Some list
  3. with items

    // And some code if ( list( $code, $items ) ) break;

And another unordered list followed by some short code lines

  • A list
  • that will
  • break stuff
  • again - even when showing
  • the code line intended

    switch ( 'formatting' ) { case 'bug' : return array( 'list', 'code' ); break; case 'default' : return print 'Mooo'; break; } echo "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";

I'm not sure if I've to add to get this fixed.

1
  • 2
    I agree. The SE markdown really doesn't handle lists all that well, particularly with code or quotes within lists. Commented Feb 23, 2012 at 14:37

2 Answers 2

6

It's actually just allowing you to choose between putting your code in the list and putting it outside of the list. To put it in the list, you must double indent (2 tabs or 8 spaces to start the block). For example:

  • This is
  • a sample list
  • and here's a codeblock in that list

    // << 8 spaces
    // leet code goes here
    

Just for comparison, here is the method you must use to do code outside of a list:

  • here is
  • another list
  • that doesn't have code

some blah to reset from list

// << 4 spaces
// even leeter code goes here

The real bug, as I see it, is that doing 2 line breaks after a list and then starting a code block should do a list reset, you shouldn't need that line of text.

2
  • 1
    Nice! So really, the issue is merely that the markdown documentation for lists needs to be improved? Commented Feb 24, 2012 at 15:10
  • 1
    Yea, I'd say so...the only real change that needs to be made in code is allowing a non-list codeblock to come immediately after a list...I'd make that dependent on the number of line breaks, requiring at least 2, maybe 3.
    – mor7ifer
    Commented Feb 24, 2012 at 16:28
3

This is due to an ambiguity in the Markdown spec - all implementations, including Daring Fireball's, render this way.

See balpha's excellent answer for a complete description.

1
  • 1
    Thanks +1. The ` ` hack is a little big hackish, but the &nbsp; hack seems to be a nice workaround.
    – kaiser
    Commented Feb 28, 2012 at 20:20

You must log in to answer this question.

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