Question: Is it possible to get Updated Markdown text from MarkdownDocument? #203

Closed
opened 2026-01-29 14:30:17 +00:00 by claunia · 3 comments
Owner

Originally created by @RickStrahl on GitHub (Apr 21, 2018).

I see that I can render a syntax tree to HTML, but diggning throgh the code I'm not seeing if there's a way to get Markdown back out after making changes to the sytnax tree.

Scenario:

I'm basically looking through a Markdown document and need to fix up a few links and images - so I iterate through the document and make changes to the inlines to fix up the links/images on MarkdownDocument. Parsing and updating works beautifully.

But I can't seem to find a way to now get back Markdown text from this. Should this be possible or am I just missing it?

Originally created by @RickStrahl on GitHub (Apr 21, 2018). I see that I can render a syntax tree to HTML, but diggning throgh the code I'm not seeing if there's a way to get Markdown back out after making changes to the sytnax tree. Scenario: I'm basically looking through a Markdown document and need to fix up a few links and images - so I iterate through the document and make changes to the inlines to fix up the links/images on MarkdownDocument. Parsing and updating works beautifully. But I can't seem to find a way to now get back Markdown text from this. Should this be possible or am I just missing it?
claunia added the question label 2026-01-29 14:30:17 +00:00
Author
Owner

@xoofx commented on GitHub (Apr 22, 2018):

There is an ongoing work called "normalize" which is usable here from Markdown class directly (or via the NormalizeRenderer)

But it is a work in progress, it doesn't strictly support round trip, it is missing a few stuffs, it doesn't cover extensions for now...etc.

@xoofx commented on GitHub (Apr 22, 2018): There is an ongoing work called "normalize" which is usable here from [Markdown class directly](https://github.com/lunet-io/markdig/blob/812c4fabe6846575466f1c59c47a19b1a98cb288/src/Markdig/Markdown.cs#L26-L62) (or via the NormalizeRenderer) But it is a work in progress, it doesn't strictly support round trip, it is missing a few stuffs, it doesn't cover extensions for now...etc.
Author
Owner

@xoofx commented on GitHub (Apr 22, 2018):

The issue #155 is following a bit this work (but I have personally no more time to work on this)

@xoofx commented on GitHub (Apr 22, 2018): The issue #155 is following a bit this work (but I have personally no more time to work on this)
Author
Owner

@pauldotknopf commented on GitHub (May 6, 2018):

@RickStrahl, it looks like I am doing something similar in #225.

I'm trying to create a custom renderer that simply passes the raw markdown to a new markdown content, with the option to override certain block items.

To me, it seems like it would be easier to instead of modifying the syntax tree directly, implement a custom renderer that transforms the input markdown into new markdown, that you could re-parse.

In your case, you would provide your own MarkdownObjectRenderer for a LinkInline to transform the markdown into anything else.

@pauldotknopf commented on GitHub (May 6, 2018): @RickStrahl, it looks like I am doing something similar in #225. I'm trying to create a custom renderer that simply passes the raw markdown to a new markdown content, with the option to override certain block items. To me, it seems like it would be easier to instead of modifying the syntax tree directly, implement a custom renderer that transforms the input markdown into new markdown, that you could re-parse. In your case, you would provide your own ```MarkdownObjectRenderer``` for a ```LinkInline``` to transform the markdown into anything else.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#203