erusev / parsedown

Better Markdown Parser in PHP
https://parsedown.org
MIT License
14.76k stars 1.12k forks source link

Second nested list item level, possible or not? #824

Closed stgoos closed 2 years ago

stgoos commented 2 years ago

I've just started to use Parsedown and perhaps I'm (still) overlooking it but I'm missing the possibility to add a second nested list item level in lists.

Am I correct that it's not possible at the moment in the current version 1.7.4? If so, is it (already) planned for version 2.0?

This is what I'm after:

- First list item
   - First nested list item
     - Second nested list item

This is what I currently get as a result from Parsedown:

- First list item
   - First nested list item
   - Second nested list item 

So the second nested list item is at the same level as the first nested list item, which I don't want.

aidantwoods commented 2 years ago

In 1.7.4 I get the following output using the first input:

<ul>
<li>First list item
<ul>
<li>First nested list item
<ul>
<li>Second nested list item</li>
</ul></li>
</ul></li>
</ul>

Although if I remove one space from the second and first line (which should also be sufficient), then I get the result you're describing.

Parsedown 1 had some issues with indentation tracking when parsing nested blocks which should (hopefully) be resolved in 2.0.

When I give the following to the current version of 2.0.x:

- First list item
  - First nested list item
    - Second nested list item

Then I get the same result as commonmark, which is I think what you're after?

In Parsedown 1.x I think you might just need to over do it on the indentation to get it to recognise the nested list, but this will be done correctly in 2.0.

stgoos commented 2 years ago

Thanks for that, will check it as well with version 2.0.

I've been experimenting myself a bit further last night as well with the dev branch 1.8.0-beta7.

In that version it's already possible to achieve the levels I want. It comes down to the alignment of the markers.

- First list item
   - First nested list item
      - Second nested list item 

Would still go wrong BUT when aligning the markers to the text of the level above, then it works perfectly.

- First list item
  - First nested list item
    - Second nested list item 

Glad to see it's already built into the next versions.

I'll mark this topic as closed.