Skip to main content
added 17 characters in body
Source Link
badp
  • 33.6k
  • 5
  • 90
  • 176

Unfortunately, this is an ambiguity in the Markdown specification. This markdown source:

42. list item

    more text

can mean two things. One of them is the one you're expecting: more text is following a blank line and indented by four spaces, making it a top-level (i.e. not part of the list) code block.

The second possible meaning is this:

List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab:

1.  This is a list item with two paragraphs. Lorem ipsum dolor
    sit amet, consectetuer adipiscing elit. Aliquam hendrerit
    mi posuere lectus.
    Vestibulum enim wisi, viverra nec, fringilla in, laoreet
    vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
    sit amet velit.

– in other words, more text is a regular second paragraph within the list item.

It's indistinguishable which of the two meanings is the intended one; both are correct. And what the Markdown converter (actually, all of themall of them) chooses is the second meaning.

The only way to fix this would be adding an additional syntax to Markdown, enabling you to distinguish the two. I can, however, not think of any intutitive and unobtrusive thing to do, so using one of the workarounds here is as good as anything. My preferred workaround, by the way, would be an HTML comment like this:

* list item

<!-- -->

    code

turns into this:

  • list item
code

– but it doesn't really matter which one you use. Bottom line is: As sad as it is, this is unfixable.

Unfortunately, this is an ambiguity in the Markdown specification. This markdown source:

42. list item

    more text

can mean two things. One of them is the one you're expecting: more text is following a blank line and indented by four spaces, making it a top-level (i.e. not part of the list) code block.

The second possible meaning is this:

List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab:

1.  This is a list item with two paragraphs. Lorem ipsum dolor
    sit amet, consectetuer adipiscing elit. Aliquam hendrerit
    mi posuere lectus.
    Vestibulum enim wisi, viverra nec, fringilla in, laoreet
    vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
    sit amet velit.

– in other words, more text is a regular second paragraph within the list item.

It's indistinguishable which of the two meanings is the intended one; both are correct. And what the Markdown converter (actually, all of them) chooses is the second meaning.

The only way to fix this would be adding an additional syntax to Markdown, enabling you to distinguish the two. I can, however, not think of any intutitive and unobtrusive thing to do, so using one of the workarounds here is as good as anything. My preferred workaround, by the way, would be an HTML comment like this:

* list item

<!-- -->

    code

turns into this:

  • list item
code

– but it doesn't really matter which one you use. Bottom line is: As sad as it is, this is unfixable.

Unfortunately, this is an ambiguity in the Markdown specification. This markdown source:

42. list item

    more text

can mean two things. One of them is the one you're expecting: more text is following a blank line and indented by four spaces, making it a top-level (i.e. not part of the list) code block.

The second possible meaning is this:

List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab:

1.  This is a list item with two paragraphs. Lorem ipsum dolor
    sit amet, consectetuer adipiscing elit. Aliquam hendrerit
    mi posuere lectus.
    Vestibulum enim wisi, viverra nec, fringilla in, laoreet
    vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
    sit amet velit.

– in other words, more text is a regular second paragraph within the list item.

It's indistinguishable which of the two meanings is the intended one; both are correct. And what the Markdown converter (actually, all of them) chooses is the second meaning.

The only way to fix this would be adding an additional syntax to Markdown, enabling you to distinguish the two. I can, however, not think of any intutitive and unobtrusive thing to do, so using one of the workarounds here is as good as anything. My preferred workaround, by the way, would be an HTML comment like this:

* list item

<!-- -->

    code

turns into this:

  • list item
code

– but it doesn't really matter which one you use. Bottom line is: As sad as it is, this is unfixable.

Source Link
balpha StaffMod
  • 158.9k
  • 45
  • 506
  • 679

Unfortunately, this is an ambiguity in the Markdown specification. This markdown source:

42. list item

    more text

can mean two things. One of them is the one you're expecting: more text is following a blank line and indented by four spaces, making it a top-level (i.e. not part of the list) code block.

The second possible meaning is this:

List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab:

1.  This is a list item with two paragraphs. Lorem ipsum dolor
    sit amet, consectetuer adipiscing elit. Aliquam hendrerit
    mi posuere lectus.
    Vestibulum enim wisi, viverra nec, fringilla in, laoreet
    vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
    sit amet velit.

– in other words, more text is a regular second paragraph within the list item.

It's indistinguishable which of the two meanings is the intended one; both are correct. And what the Markdown converter (actually, all of them) chooses is the second meaning.

The only way to fix this would be adding an additional syntax to Markdown, enabling you to distinguish the two. I can, however, not think of any intutitive and unobtrusive thing to do, so using one of the workarounds here is as good as anything. My preferred workaround, by the way, would be an HTML comment like this:

* list item

<!-- -->

    code

turns into this:

  • list item
code

– but it doesn't really matter which one you use. Bottom line is: As sad as it is, this is unfixable.