Markdown Parser

The MarkdownDocument class allows you to parse a Markdown String into a Markdown Document, and then Render it with a Markdown Renderer.


string md = "This is **Markdown**";
MarkdownDocument Document = new MarkdownDocument();

// Takes note of all of the Top Level Headers.
foreach (var element in document.Blocks)
    if (element is HeaderBlock header)
        Console.WriteLine($"Header: {header.ToString()}");


Class Purpose
Microsoft.Toolkit.Parsers.Markdown.MarkdownDocument Represents a Markdown Document.
Microsoft.Toolkit.Parsers.Markdown.Render.MarkdownRendererBase A base renderer for Rendering Markdown into Controls.



Property Type Description
Blocks IList<MarkdownBlock> Gets or sets the list of block elements.


Methods Return Type Description
Parse(string) void Parses markdown document text.
LookUpReference(string) LinkReferenceBlock Looks up a reference using the ID.

Create a Markdown Renderer

In order to create a Markdown Renderer, you can either implement your own, or inherit from MarkdownRenderBase, this class already has all the required methods, and some assistive code to make implementing a Renderer easy, all you have to do is implement the Block and Inline Rendering, and the output.

This requires an inherited IRenderContext, which allows you to keep track of the Context of the rendering.

The best way to figure out how to create a Renderer, is to look at the implementation for the UWP MarkdownTextBlock control.

Sample Code

Markdown Parser Sample Page Source.

You can see this in action in UWP Community Toolkit Sample App.


Implementation .NET Standard 1.4.
Namespace Microsoft.Toolkit.Parsers
NuGet package Microsoft.Toolkit.Parsers

API Source Code