mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-08 13:54:54 +00:00
[Question] Custom renderer outside MarkDig possible? #736
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 @Seikilos on GitHub (May 10, 2025).
Hi,
due to a lack of documentation I am trying to create a simple PDF exporter and was playing around with deriving from RendererBase because I won't return a text writer, so I cannot use TextRenderBase like the HtmlRenderer does. (This is my assumption)
However, the signature of render base poses some questions for me:
public override object Render(MarkdownObject markdownObject)I get a
MarkdownObjectand need to descend down to containers, etc but I am stuck.Beside the fact that I haven't found a way for a hierarchical traversal yet, I stumbled upon
MarkdownObject.IsContainerInlineandMarkdownObject.IsContainerBlock, which are internal.I assume that I misunderstand how to approach the traversal, but does the internal modifier on the method above makes it quite tricky to discern what to do?
I looked at the plain text and html renderers, I also looked at some forked Wpf Renderer but still am unsure on how to handle traversal that way without a text render output (otherwise I could somehow hijack the html renderer I assume.
Or would be actually using the Html renderer to get html be the best way? I could parse the resulting html into a tree and then continue my pdf export from html instead of markdown I assume.
@xoofx commented on GitHub (May 10, 2025):
RendererBasehas several methods WriteChildren andWrite(MarkdownObject)that are used to traverse the objects.Your derived
MarkdownObjectRendererwill call back to these methods as it is done for the HtmlRenderers For example for the list renderer here or the quote block renderer here ...etc.