[Suggestion] Make markdig renderer-agnostic #60

Open
opened 2026-01-29 14:24:17 +00:00 by claunia · 0 comments
Owner

Originally created by @Kryptos-FR on GitHub (Oct 16, 2016).

Currently Markdig is still coupled with its HTML renderer. This makes writing new renderers very challenging.

One of the issue I encountered recently is when trying to also support extensions in my XAML renderer. For example when configuring the pipeline the following way:

var pipelinenew MarkdownPipelineBuilder()
    .UseTaskLists()
    .Build();

the TaskList extension is adding aHtmlTaskListRenderer. But in my case I would like it to add my own custom XamlTaskListRenderer instead.

Arguably I could duplicate the whole extensions mechanism to inject my own implementations but I think this defeats the purpose. Ideally all the existing code for the extensions (parsers, inlines) with the exceptions of the renderer should stay the same. So it would be nice to have another way to match/replace renderers without breaking the whole extension mechanism.

Going further, the current Markdig could be split into two assemblies: Markdig.Core which is unaware of any specific renderer (e.g. in my case I don't need to ship the HTML rendering specific code) and Markdig.HTML for the HTML rendering (which in my case is replaced by Markdig.Xaml).

Originally created by @Kryptos-FR on GitHub (Oct 16, 2016). Currently Markdig is still coupled with its HTML renderer. This makes writing new renderers very challenging. One of the issue I encountered recently is when trying to also support extensions in my XAML renderer. For example when configuring the pipeline the following way: ``` csharp var pipelinenew MarkdownPipelineBuilder() .UseTaskLists() .Build(); ``` the `TaskList` extension is adding a`HtmlTaskListRenderer`. But in my case I would like it to add my own custom `XamlTaskListRenderer` instead. Arguably I could duplicate the whole extensions mechanism to inject my own implementations but I think this defeats the purpose. Ideally all the existing code for the extensions (parsers, inlines) with the exceptions of the renderer should stay the same. So it would be nice to have another way to match/replace renderers without breaking the whole extension mechanism. Going further, the current Markdig could be split into two assemblies: Markdig.Core which is unaware of any specific renderer (e.g. in my case I don't need to ship the HTML rendering specific code) and Markdig.HTML for the HTML rendering (which in my case is replaced by Markdig.Xaml).
claunia added the enhancement label 2026-01-29 14:24:17 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#60