Markdig Not Displaying Markdown Tables Properly

Created on

A solution for your markdown tables showing up with incorrect syntax instead of the expected HTML table.

Markdig Table Issue

I was creating a table for a my blog post on string interpolation and my markdown tables were being displayed as markdown syntax instead of the expected HTML table when using Markdig.

My tables looked like this in my blog post:

|Language|String Interpolation Examples| |:-------------:|:-------------------------------:| | C# |C# - String Interpolation Examples|

Searching for the Solution

I ended up finding the solution with a google search that returned this github gist, but I still had to dig (Ba Dum Tss!) further.

The final solution to get your markdown tables displaying properly is to use Markdig's MarkdownPipelineBuilder.

The Solution to the Markdig Table Issue

Here is my old code that was not displaying the tables correctly:


Here is the new code that displays my markdown tables properly:

   var pipeline = new Markdig.MarkdownPipelineBuilder().UseAdvancedExtensions().Build();

@Html.Raw(Markdown.ToHtml(Model.MarkdownContent, pipeline))