xoofx / xoofx/markdig

EnableTrackTrivia() is not generating valid HTML

Open
#604 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
C#
Stars
5.3k
Forks
510
Avg merge
8d 5h
Merged PRs (30d)
5

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the EnableTrackTrivia() test in src/Markdig.Tests/TestParser.cs around line 122 and reproduce the failures across the CommonMark tests. Compare the generated HTML for paragraph and literal handling, focusing on the semantically invalid output described here. Done means either restoring valid, equivalent HTML rendering or documenting that EnableTrackTrivia() is limited to Markdown manipulation.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.