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

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

📋 Pull Request Information

Original PR: https://github.com/xoofx/markdig/pull/49
Author: @christophano
Created: 8/22/2016
Status: Merged
Merged: 9/14/2016
Merged by: @xoofx

Base: masterHead: bugfix/nested-definition-lists


📝 Commits (2)

  • d003837 Fixes issue where multiple definition lists are created when they are nested in a list item.
  • 86fb962 Removes BlankLineBlock if it is found after an active definition list.

📊 Changes

3 files changed (+76 additions, -2 deletions)

View changed files

📝 src/Markdig.Tests/Specs/DefinitionListSpecs.md (+25 -0)
📝 src/Markdig.Tests/Specs/Specs.cs (+37 -0)
📝 src/Markdig/Extensions/DefinitionLists/DefinitionListParser.cs (+14 -2)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/xoofx/markdig/pull/49 **Author:** [@christophano](https://github.com/christophano) **Created:** 8/22/2016 **Status:** ✅ Merged **Merged:** 9/14/2016 **Merged by:** [@xoofx](https://github.com/xoofx) **Base:** `master` ← **Head:** `bugfix/nested-definition-lists` --- ### 📝 Commits (2) - [`d003837`](https://github.com/xoofx/markdig/commit/d003837b273abb932021582d43f6d2e00bf67b67) Fixes issue where multiple definition lists are created when they are nested in a list item. - [`86fb962`](https://github.com/xoofx/markdig/commit/86fb962fdbe44c8bb13906cfec8a06513669a6af) Removes BlankLineBlock if it is found after an active definition list. ### 📊 Changes **3 files changed** (+76 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/Markdig.Tests/Specs/DefinitionListSpecs.md` (+25 -0) 📝 `src/Markdig.Tests/Specs/Specs.cs` (+37 -0) 📝 `src/Markdig/Extensions/DefinitionLists/DefinitionListParser.cs` (+14 -2) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 14:45:31 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#786