[PR #49] Fixes issue where multiple definition lists are created when they are nested in a list item. #791

Open
opened 2026-01-29 14:45:33 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/xoofx/markdig/pull/49

State: closed
Merged: Yes


I've experienced an issue where a nested definition list outputs multiple definition lists, instead of one list with multiple terms.
The following markdown:

1.  Item One

2.  Item Two

    Term One
    :   Description One

    Term Two
    :   Description Two

    Term Three
    :   Description Three

3.  Item Three

is rendered as:

<ol>
<li><p>Item One</p></li>
<li><p>Item Two</p>
<dl>
<dt>Term One</dt>
<dd>Description One</dd>
</dl>
<dl>
<dt>Term Two</dt>
<dd>Description Two</dd>
</dl>
<dl>
<dt>Term Three</dt>
<dd>Description Three</dd>
</dl>
</li>
<li><p>Item Three</p></li>
</ol>

instead of:

<ol>
<li><p>Item One</p></li>
<li><p>Item Two</p>
<dl>
<dt>Term One</dt>
<dd>Description One</dd>
<dt>Term Two</dt>
<dd>Description Two</dd>
<dt>Term Three</dt>
<dd>Description Three</dd>
</dl>
</li>
<li><p>Item Three</p></li>
</ol>

I've tracked this down to the way the DefinitionListParser will look for the item before the last ParagraphBlock for an existing DefinitionList but, when the DefinitionList is nested in a ListItem, there will be an additional BlankItemBlock between them.

**Original Pull Request:** https://github.com/xoofx/markdig/pull/49 **State:** closed **Merged:** Yes --- I've experienced an issue where a nested definition list outputs multiple definition lists, instead of one list with multiple terms. The following markdown: ``` md 1. Item One 2. Item Two Term One : Description One Term Two : Description Two Term Three : Description Three 3. Item Three ``` is rendered as: ``` html <ol> <li><p>Item One</p></li> <li><p>Item Two</p> <dl> <dt>Term One</dt> <dd>Description One</dd> </dl> <dl> <dt>Term Two</dt> <dd>Description Two</dd> </dl> <dl> <dt>Term Three</dt> <dd>Description Three</dd> </dl> </li> <li><p>Item Three</p></li> </ol> ``` instead of: ``` html <ol> <li><p>Item One</p></li> <li><p>Item Two</p> <dl> <dt>Term One</dt> <dd>Description One</dd> <dt>Term Two</dt> <dd>Description Two</dd> <dt>Term Three</dt> <dd>Description Three</dd> </dl> </li> <li><p>Item Three</p></li> </ol> ``` I've tracked this down to the way the `DefinitionListParser` will look for the item _before_ the last `ParagraphBlock` for an existing `DefinitionList` but, when the `DefinitionList` is nested in a `ListItem`, there will be an additional `BlankItemBlock` between them.
claunia added the pull-request label 2026-01-29 14:45:33 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#791