jirutka / asciidoctor-html5s

Semantic HTML5 converter (backend) for Asciidoctor
MIT License
89 stars 10 forks source link

Ordered List right after Unordered List combines them #19

Closed nidomiro closed 4 years ago

nidomiro commented 4 years ago

I'm using this package to render my asciidoc files with hugo.

I found that having a ordered list right after a unordered list causes a wrong html-nesting. The ordered list will be inside the last list item of the unordered list.

The following asciidoc source was used for the test:

sdfhkjdfg

* a
* b
* c

1. a
2. b
.. abc
3. c

sdfhkjdfg

* a
* b
* c

sdfhkjdfg

1. a
2. b
.. abc
3. c

sdfhkjdfg

will result in

<p>sdfhkjdfg</p>
<div class="ulist">
    <ul>
        <li>a</li>
        <li>b</li>
        <li>c
            <ol class="arabic">
                <li>a</li>
                <li>b
                    <ol class="loweralpha" type="a">
                        <li>abc</li>
                    </ol>
                </li>
                <li>c</li>
            </ol>
        </li>
    </ul>
</div>
<p>sdfhkjdfg</p>
<div class="ulist">
    <ul>
        <li>a</li>
        <li>b</li>
        <li>c</li>
    </ul>
</div>
<p>sdfhkjdfg</p>
<div class="olist arabic">
    <ol class="arabic">
        <li>a</li>
        <li>b
            <ol class="loweralpha" type="a">
                <li>abc</li>
            </ol>
        </li>
        <li>c</li>
    </ol>
</div>
<p>sdfhkjdfg</p>

I would expect the following output:

<p>sdfhkjdfg</p>
<div class="ulist">
    <ul>
        <li>a</li>
        <li>b</li>
        <li>c</li>
    </ul>
</div>
<div class="olist arabic">
    <ol class="arabic">
        <li>a</li>
        <li>b
            <ol class="loweralpha" type="a">
                <li>abc</li>
            </ol>
        </li>
        <li>c</li>
    </ol>
</div>
<p>sdfhkjdfg</p>
<div class="ulist">
    <ul>
        <li>a</li>
        <li>b</li>
        <li>c</li>
    </ul>
</div>
<p>sdfhkjdfg</p>
<div class="olist arabic">
    <ol class="arabic">
        <li>a</li>
        <li>b
            <ol class="loweralpha" type="a">
                <li>abc</li>
            </ol>
        </li>
        <li>c</li>
    </ol>
</div>
<p>sdfhkjdfg</p>
jirutka commented 4 years ago

This is not asciidoctor-html5s’ fault, that’s how Asciidoctor parses the lists. It’s even mentioned in Asciidoctor’s manual: Separating lists.