10

When editing this answer, I noticed that placing breaks (blank lines) in lists (especially nested lists) is inconsistent (and possibly dependent on the current state of the JavaScript variables of the editor).

Different layouts can give the same results, multiple changes, changes to the wrong part, or no changes at all.

For example, with the following list, there are no line-breaks before or after anything as expected:

  1. foo
    * bar
    * baz
  2. test
    * me
    * you

Gives this:

  1. foo
    • bar
    • baz
  2. test
    • me
    • you

If you try to add a space between the two top-level lists (before the line with 2. test), you would naturally use this:

  1. foo
    * bar
    * baz

  2. test
    * me
    * you

Except that you get this unexpected and unwanted result instead:

  1. foo

    • bar
    • baz
  2. test

    • me
    • you

In this state, adding or removing a blank line between the first- and second-level lists (after foo or test) changes nothing:

  1. foo

    * bar
    * baz

  2. test
    * me
    * you

Is the same as before:

  1. foo

    • bar
    • baz
  2. test

    • me
    • you

Look at the marked rows in the following screenshot; different layouts give the same results (which often don’t match what was expected):

enter image description here

A video is worth a million words (ImageShack, PhotoBucket). The closest related question I could find was this one.


(“By design?” So making it work inconsistently and give unexpected and unwanted results is on purpose‽ ಠ_ఠ)

2
  • I had the same question. So, as it stands, there's still no way to have more spacing between * baz and 2. test that follows, right?
    – janos
    Commented Jan 11, 2014 at 9:47
  • Correct. And there probably won’t be because they tagged it “by designed” instead of acknowledging it’s a bug and fixing it. ¬_¬
    – Synetech
    Commented Jan 11, 2014 at 14:39

2 Answers 2

3

The next time you change your question to say the opposite from what it said before, a comment on existing answers that you're invalidating with your edit would be nice.

You now say

> As you can see, different layouts give the same results:

(as opposed to "same layouts give different results", which you claimed before and still do in a few places; see the first revision of this post for my answer to that).

This can hardly be considered a bug. After all, these four also give the same results:

Hello <em>World!</em>

Hello *World!*

Hello
*World!*

&#72;ello <em>Worl&#100;!</em>

As for your specific example, the Markdown spec says

If list items are separated by blank lines, Markdown will wrap the items in <p> tags in the HTML output.

Quoting myself from this answer:

Besides the fact that this is actually ambigous (Which item is wrapped in <p> tags? The one before the blank line? The one after it? Both? All of them, once there's a blank line anywhere?) and that different implementations actually handle this differently, here's how the original implementation [ed: and ours] does it:

The first element is wrapped in <p> if it's followed by a blank line, the last element when it's preceded by a blank line, and all other ones when there's a blank line at least on one side. All items are wrapped if they contain blank lines.

In the five images you marked with a star (counting left-to-right, top-to-bottom), the following hold for the numbered (outer) list:

  1. Item 1 contains a blank line and is followed by a blank line; item 2 is preceded by a blank line.
  2. Item 1 is followed by a blank line; item 2 is preceded by a blank line.
  3. Item 1 is followed by a blank line; item 2 contains a blank line and is preceded by a blank line.
  4. Item 1 contains a blank line and is followed by a blank line; item 2 contains a blank line and is preceded by a blank line.
  5. Item 1 contains a blank line; item 2 contains a blank line.

So in all five examples, each item of the numbered list fulfills at least one condition to have its content wrapped in a paragraph. Thus it's absolutely correct that they give the same result.

0

Now that I've finally finished closing all of the ads that popped up after viewing your video...

I don't think this is a bug, but rather .

If you want a space between the second set of blocks, you probably want a space between the first set of blocks, too. And if you don't, well, we're going to force you to do so for consistency.

It's not the only aspect of markdown that works this way. For example, if I have the following raw text, the output by the markdown parser will look very similar to the original. In particular, there will be no blank lines between the numbered list items.

Here are some points:

1. One    
2. Two
3. Three

But if I put a line between the first and second items,

Here are some points:

1. One

2. Two
3. Three

...a blank line will be automatically inserted between all of the list items by the markdown parser:

Here are some points:

  1. One

  2. Two

  3. Three

That way, I don't have to manually format the entire list with blank lines between each list item.

2
  • (I block ads, so I didn’t know ImageShack was so bad. I can try PhotoBucket, but Imgur doesn’t do video.) It is definitely not by design because blanks pop up in bizarre and incorrect (sometimes even unrelated) places. I also demonstrated that the same layout gives different results depending on the sequence of steps taken.
    – Synetech
    Commented Feb 29, 2012 at 4:56
  • > ...a blank line will be automatically inserted between all of the list items by the markdown parser That seems to fit. Unfortunately it seems to make incorrect guesses sometimes and limits the user’s ability to accurately control the layout. I guess it’s a case of trying to be helpful backfiring.
    – Synetech
    Commented Feb 29, 2012 at 18:39

You must log in to answer this question.

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