Having to pass a pipeline into ToHtml is weird #43

Closed
opened 2026-01-29 14:22:39 +00:00 by claunia · 1 comment
Owner

Originally created by @dotnetchris on GitHub (Jul 15, 2016).

Simple fix is to provide an extension ontop of the pipeline

var html = _mycustomPipeline.ToHtml(markdown);

    public static class MarkdigExtensions
    {
        public static string ToHtml(this MarkdownPipeline pipeline, string markdown)
        {
            var html = Markdown.ToHtml(markdown, pipeline);
            return html;
        }
    }

Alternative solution, maybe Build() returns a type different than MarkdownPipeline and it gives you an instance that does the correct things to have ToHtml().

Originally created by @dotnetchris on GitHub (Jul 15, 2016). Simple fix is to provide an extension ontop of the pipeline `var html = _mycustomPipeline.ToHtml(markdown);` ``` c# public static class MarkdigExtensions { public static string ToHtml(this MarkdownPipeline pipeline, string markdown) { var html = Markdown.ToHtml(markdown, pipeline); return html; } } ``` Alternative solution, maybe `Build()` returns a type different than MarkdownPipeline and it gives you an instance that does the correct things to have `ToHtml()`.
claunia added the questioninvalid labels 2026-01-29 14:22:40 +00:00
Author
Owner

@xoofx commented on GitHub (Jul 16, 2016):

Sorry I will decline this. I would prefer not to introduce a different high-level API entry point in case you have a pipeline or not, so the current design is preferable as it is the same method. You can still use your extension method in your own project.

@xoofx commented on GitHub (Jul 16, 2016): Sorry I will decline this. I would prefer not to introduce a different high-level API entry point in case you have a pipeline or not, so the current design is preferable as it is the same method. You can still use your extension method in your own project.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#43