RoundtripRenderer looses list content #745

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

Originally created by @stylefish on GitHub (Jun 13, 2025).

hi,

i've an issue when using the RoundtripRenderer. When this document gets parsed and rendered back to md (doing this for cleanup), the first list element is missing:

here is some sample code:

var md = @"1. 1. 

2. 2. 

3. 3. 

- 1. 

- 2. 
";
var parsed = Markdown.Parse(md, true);
var w = new StringWriter();
var r = new RoundtripRenderer(w);
r.Render(parsed);
w.Flush();
var md2 = w.ToString();

Console.WriteLine(md2);

md and md2 should be equal, but md2 is missing the 1. after the first dash -.

so this:

1. 1. 

2. 2. 

3. 3. 

- 1. 

- 2. 

is after the rpundtrip this:

1. 1. 

2. 2. 

3. 3. 

- 

- 2. 

according to commonmark reference implementation this should work: https://spec.commonmark.org/dingus/

is this a bug or is there a way to workaround this? i'm a little stuck here.

any help would be much appreciated! thank you!
greetings

Originally created by @stylefish on GitHub (Jun 13, 2025). hi, i've an issue when using the `RoundtripRenderer`. When this document gets parsed and rendered back to md (doing this for cleanup), the first list element is missing: here is some sample code: ``` var md = @"1. 1. 2. 2. 3. 3. - 1. - 2. "; var parsed = Markdown.Parse(md, true); var w = new StringWriter(); var r = new RoundtripRenderer(w); r.Render(parsed); w.Flush(); var md2 = w.ToString(); Console.WriteLine(md2); ``` md and md2 should be equal, but md2 is missing the `1.` after the first dash `-`. so this: ``` 1. 1. 2. 2. 3. 3. - 1. - 2. ``` is after the rpundtrip this: ``` 1. 1. 2. 2. 3. 3. - - 2. ``` according to commonmark reference implementation this should work: https://spec.commonmark.org/dingus/ is this a bug or is there a way to workaround this? i'm a little stuck here. any help would be much appreciated! thank you! greetings
claunia added the bugPR Welcome! labels 2026-01-29 14:44:35 +00:00
Author
Owner

@MihaZupan commented on GitHub (Jun 13, 2025):

Probably a bug in the roundtrip renderer for ordered lists.
Compare the ordered part
682c727288/src/Markdig/Renderers/Roundtrip/ListRenderer.cs (L30-L32)
vs unordered
682c727288/src/Markdig/Renderers/Roundtrip/ListRenderer.cs (L47-L58)

The former is probably missing the handling for 0 blocks & the pop indent.

@MihaZupan commented on GitHub (Jun 13, 2025): Probably a bug in the roundtrip renderer for ordered lists. Compare the ordered part https://github.com/xoofx/markdig/blob/682c727288defba5dfab05ccb4ef847c760d412c/src/Markdig/Renderers/Roundtrip/ListRenderer.cs#L30-L32 vs unordered https://github.com/xoofx/markdig/blob/682c727288defba5dfab05ccb4ef847c760d412c/src/Markdig/Renderers/Roundtrip/ListRenderer.cs#L47-L58 The former is probably missing the handling for 0 blocks & the pop indent.
Author
Owner

@stylefish commented on GitHub (Jun 13, 2025):

great - thanks for pointing that out - i'll have a look next week and try to create a PR

@stylefish commented on GitHub (Jun 13, 2025): great - thanks for pointing that out - i'll have a look next week and try to create a PR
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#745