Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nested ordered lists indented with 2 spaces are broken #399

Closed
notslang opened this issue Apr 1, 2016 · 2 comments
Closed

nested ordered lists indented with 2 spaces are broken #399

notslang opened this issue Apr 1, 2016 · 2 comments

Comments

@notslang
Copy link

notslang commented Apr 1, 2016

According the list-items rule (that sublists need to be indented to the column of the first non-whitespace character after the list marker), the following Markdown:

1. item
2. another item

  1. sub-list item
  2. sub-list another item
  3. sub-list last item

3. last item

Represents a single non-nested list:

<ol>
  <li><p>item</p></li>
  <li><p>another item</p></li>
  <li><p>sub-list item</p></li>
  <li><p>sub-list another item</p></li>
  <li><p>sub-list last item</p></li>
  <li><p>last item</p></li>
</ol>

Which seems wrong, because using a 2-space indent is enough to have the list rendered correctly with marked, redcarpet (& therefore GitHub), the original Markdown implementation, and PHP Markdown (see comparison on Babelmark).

I haven't gotten any stats yet on how popular 2 space indents are among people who write Markdown, but since there's at least one styleguide recommending it, I think it's more than an edge-case.

For people who are thinking about indentation in terms of the number of spaces before the list marker, it's quite strange that you can use 2 spaces to nest a list within an unordered list, but need at least 3 spaces to nest within an ordered one. The absurdity of this rule is illustrated further when you have ordered lists in the 2-3 digit range:

99. list item 99

    - sublist item
    - sublist item 2

100. list item 100

    - sublist item
    - sublist item 2

The tutorial at http://commonmark.org/help/tutorial/10-nestedLists.html says:

To nest one list within another, indent each item in the sublist by four spaces.

...But that doesn't work in the above example because once you get above 100 you need to switch to 5-space minimum indents (see comparison on Babelmark).

I've read the "motivation" section of the spec discussing this rule, but I'm unconvinced because cases like:

1.  foo

        indented code

...Are already handled perfectly by all parsers. And cases like:

10. foo

   bar

...Probably should be read as a list item with a subparagraph.

A few other discussions have covered the same topic:

PS: The "changing the bullet or ordered list delimiter starts a new list" rule is an awful thing to put in the standard. No other parsers do that.

@jgm
Copy link
Member

jgm commented Apr 1, 2016

The two-space rule is explicitly discussed in the spec
(along with various other rules). Please see the
discussion in http://spec.commonmark.org/0.25/#motivation
for a full explanation of why we didn't go with this
option.

marked and redcarpet are not even consistent about the
two-space rule. See
http://johnmacfarlane.net/babelmark2/?normalize=1&text=+1.+a%0A+++2.+b%0A+++++3.+c%0A+++++++4.+d%0A

Anyway, this tracker is not the place for open-ended
discussion about the spec (substantive issues).
That belongs in talk.commonmark.org.

+++ Sean Lang [Mar 31 16 21:39 ]:

According the [1]list-items rule (that sublists need to be indented to
the column of the first non-whitespace character after the list
marker), the following Markdown:

  1. item

  2. another item

    1. sub-list item
    2. sub-list another item
    3. sub-list last item
  3. last item

    Represents a single non-nested list:

  1. item

  2. another item

  3. sub-list item

  4. sub-list another item

  5. sub-list last item

  6. last item

Which seems wrong, because using a 2-space indent is enough to have the
list rendered correctly on both GitHub.com and using [2]marked.

I haven't gotten any stats yet on how popular 2 space indents are among
people who write Markdown, but since there's at least one [3]styleguide
recommending it, I think it's more than an edge-case.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or [4]view it on GitHub

References

  1. http://spec.commonmark.org/0.25/#list-items
  2. https://github.com/chjj/marked/
  3. https://github.com/carwin/markdown-styleguide
  4. nested ordered lists indented with 2 spaces are broken #399

@notslang
Copy link
Author

notslang commented Apr 2, 2016

Moved the post to http://talk.commonmark.org/t/nested-ordered-lists-indented-with-2-spaces-are-broken/2064, but had to break most of the links to get it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants