EnableTrackTrivia() is not generating valid HTML #512

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

Originally created by @xoofx on GitHub (Mar 10, 2022).

Followup of #561, I have added a test to check that when enabling EnableTrackTrivia() the generated HTML is still the same, but this test is failing on 80+ CommonMark tests because the representation to HTML expect a destructive output, not a conservative. Also the output is also semantically different, enough to be invalid. For example EnableTrackTrivia() might not generate proper ParagraphBlocks <p> but have multiple literals with lines in them or spaces in place that are not relevant for HTML.

94581d9655/src/Markdig.Tests/TestParser.cs (L122)

Not sure what to do. The code for parsing trivia has complicated the code enough that it might be too painful to fix it for HTML and we should then document that EnableTrackTrivia() can be only used for Markdown manipulation but not for rendering to HTML.

Originally created by @xoofx on GitHub (Mar 10, 2022). Followup of #561, I have added a test to check that when enabling `EnableTrackTrivia()` the generated HTML is still the same, but this test is failing on 80+ CommonMark tests because the representation to HTML expect a destructive output, not a conservative. Also the output is also semantically different, enough to be invalid. For example `EnableTrackTrivia()` might not generate proper ParagraphBlocks `<p>` but have multiple literals with lines in them or spaces in place that are not relevant for HTML. https://github.com/xoofx/markdig/blob/94581d96550554da046875a229150e5bd994cee3/src/Markdig.Tests/TestParser.cs#L122 Not sure what to do. The code for parsing trivia has complicated the code enough that it might be too painful to fix it for HTML and we should then document that `EnableTrackTrivia()` can be only used for Markdown manipulation but not for rendering to HTML.
claunia added the documentation label 2026-01-29 14:38:29 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#512