mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
776 stars 146 forks source link

trouble with zero-based nested lists #31

Closed ec1oud closed 6 years ago

ec1oud commented 6 years ago

Try to parse something like this: it seems to me that it combines some list items. As long as the indices start from 1, it doesn't happen.

0. Introduction
1. Chapter One
    0) One thing
    1) Another thing
        0. Subpoint
        1. Counterpoint
    2) Yet another thing
mity commented 6 years ago

From some intuitive point of view, I find it troublesome as well. But this behavior is explicitly required by the CommonMark specification:

In order to solve of unwanted lists in paragraphs with hard-wrapped numerals, we allow only lists starting with 1 to interrupt paragraphs.

(See http://spec.commonmark.org/0.28/#example-267)

So zero cannot interrupt the paragraph of the parent item. To get what you expect, you have to use some blank lines to interrupt the leading paragraphs manually:

0. Introduction
1. Chapter One

    0) One thing
    1) Another thing

        0. Subpoint
        1. Counterpoint
    2) Yet another thing

Cmark (CommonMark reference implementation) behaves exactly the same way in this regard.

There is some discussion whether the specs should be modified and how so, who knows, perhaps the specification may change in some future version.

ec1oud commented 6 years ago

OK, I missed that part. That's fine then.