Blazor WebAssembly App - Markdig - Can not render Pipe tables or Grid tables in Markdown #464

Closed
opened 2026-01-29 14:37:26 +00:00 by claunia · 4 comments
Owner

Originally created by @Ogglas on GitHub (May 17, 2021).

I have the following code in my editor:

@page "/editor"
@using Markdig;

<div class="row">
    <div class="col-6">
        <textarea class="form-control" @bind-value="Body" @bind-value:event="oninput"></textarea>
    </div>
    <div class="col-6">
        @if (!string.IsNullOrWhiteSpace(Body))
        {
            @((MarkupString)Preview)
        }
    </div>
</div>

@code {
    public string Body { get; set; }

    public string Preview => Markdown.ToHtml(Body);
}

It works really well with everything except tables. I have tried both pipe and grid tables that should be supported but I can't get them to render. What am I doing wrong?

https://github.com/xoofx/markdig

https://github.com/xoofx/markdig/blob/master/src/Markdig.Tests/Specs/PipeTableSpecs.md

https://github.com/xoofx/markdig/blob/master/src/Markdig.Tests/Specs/GridTableSpecs.md

Markdown:

# Header

Text
- List item 1
- List item 2

+---------+---------+ 
| This is | a table | 

a | b
-- | -
0 | 1

Pipe table works here:

a b
0 1

enter image description here

Originally created by @Ogglas on GitHub (May 17, 2021). I have the following code in my editor: @page "/editor" @using Markdig; <div class="row"> <div class="col-6"> <textarea class="form-control" @bind-value="Body" @bind-value:event="oninput"></textarea> </div> <div class="col-6"> @if (!string.IsNullOrWhiteSpace(Body)) { @((MarkupString)Preview) } </div> </div> @code { public string Body { get; set; } public string Preview => Markdown.ToHtml(Body); } It works really well with everything except tables. I have tried both pipe and grid tables that should be supported but I can't get them to render. What am I doing wrong? https://github.com/xoofx/markdig https://github.com/xoofx/markdig/blob/master/src/Markdig.Tests/Specs/PipeTableSpecs.md https://github.com/xoofx/markdig/blob/master/src/Markdig.Tests/Specs/GridTableSpecs.md Markdown: # Header Text - List item 1 - List item 2 +---------+---------+ | This is | a table | a | b -- | - 0 | 1 Pipe table works here: a | b -- | - 0 | 1 [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/yv9Bj.png
claunia added the invalid label 2026-01-29 14:37:26 +00:00
Author
Owner

@mzomparelli commented on GitHub (May 24, 2021):

I have the same issue and I'm using Blazor server. It doesn't make sense to me that the framework would matter. I don't see how a utility that is parsing text into html would care that we're using Blazor.

@mzomparelli commented on GitHub (May 24, 2021): I have the same issue and I'm using Blazor server. It doesn't make sense to me that the framework would matter. I don't see how a utility that is parsing text into html would care that we're using Blazor.
Author
Owner

@MihaZupan commented on GitHub (May 24, 2021):

@Ogglas you are calling Markdown.ToHtml(Body); which uses the basic parsing and rendering pipeline.

To add table support, use

var pipeline = new MarkdownPipelineBuilder()
   .UsePipeTables() // Or UseAdvancedExtensions()
   .Build();

Markdown.ToHtml("foo", pipeline);

I don't see how a utility that is parsing text into html would care that we're using Blazor.

It doesn't

@MihaZupan commented on GitHub (May 24, 2021): @Ogglas you are calling `Markdown.ToHtml(Body);` which uses the basic parsing and rendering pipeline. To add table support, use ```c# var pipeline = new MarkdownPipelineBuilder() .UsePipeTables() // Or UseAdvancedExtensions() .Build(); Markdown.ToHtml("foo", pipeline); ``` > I don't see how a utility that is parsing text into html would care that we're using Blazor. It doesn't
Author
Owner

@mzomparelli commented on GitHub (May 24, 2021):

@MihaZupan Thanks! That worked for me.

@mzomparelli commented on GitHub (May 24, 2021): @MihaZupan Thanks! That worked for me.
Author
Owner

@Ogglas commented on GitHub (May 24, 2021):

@MihaZupan Thanks!

@Ogglas commented on GitHub (May 24, 2021): @MihaZupan Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#464