ThatXliner / unmarkd

An extremely configurable markdown reverser for Python3.

Home Page:https://pypi.org/project/unmarkd/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested lists of same type don't work

sirnacnud opened this issue · comments

Both unordered and ordered list don't work when nested of the same type:

Two nested ordered lists

HTML:

<ol>
    <li>Top level 1</li>
    <li>Top level 2
        <ol>
            <li>A</li>
            <li>B</li>
            <li>C</li>
        </ol>
    </li>
    <li>Top level 3</li>
</ol>

Output:

1. Top level 1
 2. Top level 2
        
 1. A
 2. B
 3. C
 3. Top level 3

Two nested unordered lists

HTML:

<ul>
    <li>Top level 1</li>
    <li>Top level 2
        <ul>
            <li>A</li>
            <li>B</li>
            <li>C</li>
        </ul>
    </li>
    <li>Top level 3</li>
</ul>

Output:

- Top level 1
- Top level 2
        
- A
- B
- C
- Top level 3

Seems like a logic issue in our current way of rendering lists. I have a feeling we need some special way of handling li tags...

Alright, I made a PR but before I merge it, I want to make sure I have these assumptions right:

  • For your first case, the expected output is
1. Top level 1
2. Top level 2
    1. A
    2. B
    3. C
3. Top level 3
  • For your second case, the expected output is
- Top level 1
- Top level 2
    - A
    - B
    - C
- Top level 3

I want you to confirm because I tried making tests but it's not working. I'm pretty sure it's either Marko's parsing markdown incorrectly or that we need an extra newline between the parent and child lists.

Yes that output looks correct to me.