public static FlowDocument ToFlowDocument([NotNull] string markdown, MarkdownPipeline pipeline = null) { if (markdown == null) { throw new ArgumentNullException(nameof(markdown)); } pipeline = pipeline ?? new MarkdownPipelineBuilder().Build(); // We override the renderer with our own writer var result = new FlowDocument(); var renderer = new WpfRenderer(result); pipeline.Setup(renderer); var document = Markdig.Markdown.Parse(markdown, pipeline); renderer.Render(document); return(result); }