Skip to content

definition lists containing multi-paragraph ordered lists rendered as code #918

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

Closed
aronatkins opened this issue Mar 6, 2020 · 2 comments · Fixed by #1007
Closed

definition lists containing multi-paragraph ordered lists rendered as code #918

aronatkins opened this issue Mar 6, 2020 · 2 comments · Fixed by #1007
Labels
bug Bug report. extension Related to one or more of the included extensions.

Comments

@aronatkins
Copy link

Given Markdown with a definition list that contains an ordered list and the ordered list has multi-paragraph elements, each ordered list element is rendered as a separate ordered list and the paragraphs are rendered as code blocks.

This appears specific to definition lists (using def_list). It does not appear that other types of lists make a similar formatting decision for multi-paragraph sub-lists.

The markdown input:

term

:   this is a definition for term. it has 
    multiple lines in the first paragraph.

    1.  first thing
    
        first thing details in a second paragraph.
        
    1.  second thing

        second thing details in a second paragraph.

    1.  third thing

        third thing details in a second paragraph.

Expected:

<dl>
<dt>term</dt>
<dd>
<p>this is a definition for term. it has
multiple lines in the first paragraph.</p>

<ol>
<li>first thing
<p>first thing details in a second paragraph.</p>
</li>

<li>second thing
<p>second thing details in a second paragraph.</p>
</li>

<li>third thing
<p>third thing details in a second paragraph.</p>
</li>
</ol>

</dd>
</dl>

Actual:

<dl>
<dt>term</dt>
<dd>
<p>this is a definition for term. it has
multiple lines in the first paragraph.</p>
<ol>
<li>first thing</li>
</ol>
<pre><code>first thing details in a second paragraph.
</code></pre>
<ol>
<li>second thing</li>
</ol>
<pre><code>second thing details in a second paragraph.
</code></pre>
<ol>
<li>third thing</li>
</ol>
<pre><code>third thing details in a second paragraph.
</code></pre>
</dd>
</dl>

Tested with:

/usr/local/bin/markdown_py -x def_list definitions.md
/usr/local/bin/markdown_py --version
# => markdown_py 3.2.1
@waylan
Copy link
Member

waylan commented Mar 11, 2020

Thanks for the report.

This could be a tricky one to fix. I believe the issue is related to the DefListIndentProcessor, which subclasses the ListIndentProcessor and overrides the LIST_TYPES variable by replacing ['ul', 'ol'] with ['dl']. That attribute is relevant for parsing lose lists. When the parser finds an indented block which could be a nested list item, it checks the previously processed block. If the previous block is one of the types in LIST_TYPES, then is prosesses the current block as a child of the previous block.

The problem here is that the second level of nesting is a ol item, but it sees that the last item is a dl, so it doesn't match. I suppose instead it needs to recognize the extra level of nesting and look at the last child of the dd in the dl. The problem is that that needs to happen in ListIndentProcessor rather than the DefListIndentProcessor, which means the def_list extension also needs to override the builtin list parsing.

Alternatively, the entire block parser could be refactored to consume all nested content as a single block, rather than processing each individual sub-block separately. But that would be a major change and isn't likely to happen anytime soon.

@waylan waylan added bug Bug report. extension Related to one or more of the included extensions. labels Mar 11, 2020
@aronatkins
Copy link
Author

@waylan Thanks for digging and confirming. The ambiguity of four-space indents certainly isn't helping. Is it an indented code block? Maybe. Is it a secondary paragraph of a list item? Maybe!

I've restructured our documentation to avoid this problem - the ol beneath dd no longer contains multiple paragraphs in list-elements. Advice? Keep description details (dd) simple!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report. extension Related to one or more of the included extensions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants