mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
RoundTrip renderer not working?, breaking changes in output. #642
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @NetTecture on GitHub (Nov 26, 2023).
Tests done with 0.33.0
I have complex markdown that Itry to process and I find the simpple issue that at least links are not properly processed at all.
The following is a simple code snippet that I use to debug this:
}
Doing really nothing, it takes a text as input, generates the parsed document, turns it out through the RoundtripRenderer. This is as simple as it gets, essentially.
Here are some (not so nice) findings I find:
This:
turns into:
In some parts, it is breaking:
To:
2x the new line was skipped, putting the image link right into text and destroying the header information, as it must be on a new line. On top, this snippet shows another round trip bug:
As you can see in the last comparison up - the https link was removed and the output has no URL. It does keep the text associated:
To
but the links get removed.
it COULD bea configuration error on my side, but the code as shown is trivial enough I do not think so and follows the roundtrip documentation.
Not round trippy.
@MihaZupan commented on GitHub (Nov 26, 2023):
You have to pass the
trackTriviaflag toMarkdown.Parse@NetTecture commented on GitHub (Nov 28, 2023):
This smells like a bug still to me. Let me be clear here - I can understand that for things that re non breaking (like removing SURPLUS empty lines).... but if this parsing removes functional elements.... something is broken. trackTrivial should not leave to links becoming totlly useless or new lines that are essential to be removed.
@xoofx commented on GitHub (Nov 29, 2023):
Markdig was initially developed for generating HTML. Not for doing roundtrip to Markdown which came later, came partially and was not ideal to bring because it is on its own, already quite complex to manage, but even more complicated to bring as an afterthought.
trackTriviawas introduced after, by someone outside of myself and @MihaZupan. Tracktrivia is not free, it makes the parsing slower, generates more GC and as I said, the primary usage of Markdig is for generating HTML. That's why it's not on by default.So, it's not a bug, but a complexity/legacy that we need to deal with.