[Question]: Does this library programmatically expose the AST? #601

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

Originally created by @fourpastmidnight on GitHub (Apr 27, 2023).

First, I checked out this library and it is simply fantastic, supporting all major Markdown concepts. Hats off to you and all contributors for making such a great library for rendering Markdown via C#!

I was looking through the source code, but I didn't seem to see anything where I could use the generated AST when parsing a markdown document. Does this library expose the AST in any way, similar to how Roslyn programmatically exposes the C# AST, so that one could manipulate the AST to influence the final outcome?

My use case is that I would want to dynamically build up one or more markdown fragments. For example, a tool that would prompt users for text in order to say, generate a changelog entry. The same tool could parse an existing markdown document and perhaps, using the AST, transform the AST to update the resulting document. Working with an AST instead of raw text would be much more efficient and less error-prone.

Originally created by @fourpastmidnight on GitHub (Apr 27, 2023). First, I checked out this library and it is simply fantastic, supporting all major Markdown concepts. Hats off to you and all contributors for making such a great library for rendering Markdown via C#! I was looking through the source code, but I didn't seem to see anything where I could use the generated AST when parsing a markdown document. Does this library expose the AST in any way, similar to how Roslyn programmatically exposes the C# AST, so that one could manipulate the AST to influence the final outcome? My use case is that I would want to dynamically build up one or more markdown fragments. For example, a tool that would prompt users for text in order to say, generate a changelog entry. The same tool could parse an existing markdown document and perhaps, using the AST, transform the AST to update the resulting document. Working with an AST instead of raw text would be much more efficient and less error-prone.
Author
Owner

@fourpastmidnight commented on GitHub (Apr 27, 2023):

Ah, I found the documentation. I simply missed it. Great!!

@fourpastmidnight commented on GitHub (Apr 27, 2023): Ah, I found the documentation. I simply missed it. Great!!
Author
Owner

@karmeye commented on GitHub (Aug 17, 2024):

@fourpastmidnight Could you provide the link? I'm trying to parse a Markdown document, modify the contents, then save it back to Markdown.

@karmeye commented on GitHub (Aug 17, 2024): @fourpastmidnight Could you provide the link? I'm trying to parse a Markdown document, modify the contents, then save it back to Markdown.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#601