list item with blank line between items causes paragraph / misalignment #724

Closed
opened 2026-01-29 14:43:54 +00:00 by claunia · 2 comments
Owner

Originally created by @jonstelly on GitHub (Feb 24, 2025).

lists with blank line between items causes a paragraph which causes the item indicator and text to show up on separate lines. Removing the blank line above 2 fixes the issue. Same thing happens on unordered lists.

This is for an AI thing so I think I can instruct the AI to not include the blank line in lists, but it would be nicer if I didn't have to. Is there any setting or some other reasonable way I could fix the formatting even if the blank line is there?

### Step-by-Step Guide

1. Install Visual Studio (if not already installed):
   - Download and install Visual Studio from [here](https://visualstudio.microsoft.com/vs/). You can choose the Community version for free.

2. Create a New Project:

ends up as

<h3>Step-by-Step Guide</h3>
<ol>
<li><p>Install Visual Studio (if not already installed):</p>
<ul>
<li>Download and install Visual Studio from <a href="https://visualstudio.microsoft.com/vs/">here</a>. You can choose the Community version for free.</li>
</ul>
</li>
<li><p>Create a New Project:</p>
</li>
</ol>

renders as
Image

Originally created by @jonstelly on GitHub (Feb 24, 2025). lists with blank line between items causes a paragraph which causes the item indicator and text to show up on separate lines. Removing the blank line above 2 fixes the issue. Same thing happens on unordered lists. This is for an AI thing so I think I can instruct the AI to not include the blank line in lists, but it would be nicer if I didn't have to. Is there any setting or some other reasonable way I could fix the formatting even if the blank line is there? ``` ### Step-by-Step Guide 1. Install Visual Studio (if not already installed): - Download and install Visual Studio from [here](https://visualstudio.microsoft.com/vs/). You can choose the Community version for free. 2. Create a New Project: ``` ends up as ``` <h3>Step-by-Step Guide</h3> <ol> <li><p>Install Visual Studio (if not already installed):</p> <ul> <li>Download and install Visual Studio from <a href="https://visualstudio.microsoft.com/vs/">here</a>. You can choose the Community version for free.</li> </ul> </li> <li><p>Create a New Project:</p> </li> </ol> ``` renders as ![Image](https://github.com/user-attachments/assets/82e8a46a-5434-4f65-92e8-2920a3754e57)
claunia added the invalid label 2026-01-29 14:43:54 +00:00
Author
Owner

@jonstelly commented on GitHub (Feb 24, 2025):

I was playing around looking into the AST. Nothing jumps out, the structure of the tree is the same in both cases. So I guess that means this is more on the renderer side? I'm just getting started with this library so just talking out loud as I dig into the issue a bit.

        var good = Markdig.Markdown.Parse("1. First\r\n2. Second", _pipeline);
        var bad = Markdig.Markdown.Parse("1. First\r\n\r\n2. Second", _pipeline);
        
        var goodJson = JsonConvert.SerializeObject(good, Formatting.Indented, new JsonSerializerSettings()
        { 
            TypeNameHandling = TypeNameHandling.All,
            ReferenceLoopHandling = ReferenceLoopHandling.Ignore
        });
        var badJson = JsonConvert.SerializeObject(bad, Formatting.Indented, new JsonSerializerSettings()
        { 
            TypeNameHandling = TypeNameHandling.All,
            ReferenceLoopHandling = ReferenceLoopHandling.Ignore
        });
        Console.WriteLine("GOOD:\r\n{0}\r\n\r\nBAD:\r\n{1}", goodJson, badJson);
@jonstelly commented on GitHub (Feb 24, 2025): I was playing around looking into the AST. Nothing jumps out, the structure of the tree is the same in both cases. So I guess that means this is more on the renderer side? I'm just getting started with this library so just talking out loud as I dig into the issue a bit. ``` var good = Markdig.Markdown.Parse("1. First\r\n2. Second", _pipeline); var bad = Markdig.Markdown.Parse("1. First\r\n\r\n2. Second", _pipeline); var goodJson = JsonConvert.SerializeObject(good, Formatting.Indented, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All, ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); var badJson = JsonConvert.SerializeObject(bad, Formatting.Indented, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All, ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); Console.WriteLine("GOOD:\r\n{0}\r\n\r\nBAD:\r\n{1}", goodJson, badJson); ```
Author
Owner

@xoofx commented on GitHub (Feb 24, 2025):

Yes, it looks like a problem of CSS on your side.

Closing as the result is correct across all CommonMark engine here

@xoofx commented on GitHub (Feb 24, 2025): Yes, it looks like a problem of CSS on your side. Closing as the result is correct across all CommonMark engine [here](https://babelmark.github.io/?text=%23%23%23+Step-by-Step+Guide%0A1.+Install+Visual+Studio+(if+not+already+installed)%3A%0A+++-+Download+and+install+Visual+Studio+from+%5Bhere%5D(https%3A%2F%2Fvisualstudio.microsoft.com%2Fvs%2F).+You+can+choose+the+Community+version+for+free.%0A%0A2.+Create+a+New+Project%3A)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#724