Simple table normalization strips all table symbols #551

Closed
opened 2026-01-29 14:39:30 +00:00 by claunia · 3 comments
Owner

Originally created by @ricardoboss on GitHub (Jul 27, 2022).

Hi, great project!

I use markdig in a project to normalize incoming Markdown files and to gather metadata about the document. Now some of these documents include tables and I noticed that they are not rendered at all (I use a JS renderer for markdown, but that one works just fine). As it turns out, markdig seems to strip all table symbols in the normalization step.

I have a reproduction, which closely resembles the actual code used: https://github.com/ricardoboss/markdig-table-normalization

The gist of it is this:

Program.cs

var markdownPipeline = new MarkdownPipelineBuilder()
    .UsePipeTables()
    .Build();

var content = File.ReadAllText("test.md");
var document = Markdown.Parse(content, markdownPipeline);
var builder = new StringBuilder();
var writer = new StringWriter(builder);
var renderer = new NormalizeRenderer(writer);
renderer.Render(document);

Console.Write(builder.ToString());

test.md

| Col | Col 2 | Col 3 |
|:----|:-----:|------:|
| left | center | right |
| spaaaaaaaaacer | spaaaaaaaaacer | spaaaaaaaaacer |

And I expected the output to be same or somewhat formatted, but the actual output is this:

ColCol 2Col 3leftcenterrightspaaaaaaaaacerspaaaaaaaaacerspaaaaaaaaacer
Originally created by @ricardoboss on GitHub (Jul 27, 2022). Hi, great project! I use markdig in a project to normalize incoming Markdown files and to gather metadata about the document. Now some of these documents include tables and I noticed that they are not rendered at all (I use a JS renderer for markdown, but that one works just fine). As it turns out, markdig seems to strip all table symbols in the normalization step. I have a reproduction, which closely resembles the actual code used: https://github.com/ricardoboss/markdig-table-normalization The gist of it is this: `Program.cs` ```csharp var markdownPipeline = new MarkdownPipelineBuilder() .UsePipeTables() .Build(); var content = File.ReadAllText("test.md"); var document = Markdown.Parse(content, markdownPipeline); var builder = new StringBuilder(); var writer = new StringWriter(builder); var renderer = new NormalizeRenderer(writer); renderer.Render(document); Console.Write(builder.ToString()); ``` `test.md` ```markdown | Col | Col 2 | Col 3 | |:----|:-----:|------:| | left | center | right | | spaaaaaaaaacer | spaaaaaaaaacer | spaaaaaaaaacer | ``` And I expected the output to be same or somewhat formatted, but the actual output is this: ``` ColCol 2Col 3leftcenterrightspaaaaaaaaacerspaaaaaaaaacerspaaaaaaaaacer ```
Author
Owner

@MihaZupan commented on GitHub (Jul 27, 2022):

I think you are just missing a pipeline.Setup(renderer) call to add the renderer for tables.

Edit: On second thought, I don't think we have a normalization renderer for tables at all.
Normalization is way less polished than Html, and isn't implemented for most extensions.

@MihaZupan commented on GitHub (Jul 27, 2022): I think you are just missing a `pipeline.Setup(renderer)` call to add the renderer for tables. Edit: On second thought, I don't think we have a normalization renderer for tables at all. Normalization is way less polished than Html, and isn't implemented for most extensions.
Author
Owner

@chucker commented on GitHub (Jul 27, 2022):

https://github.com/xoofx/markdig/issues/155 doesn't list tables yet, so it might simply not be implemented at this point.

@chucker commented on GitHub (Jul 27, 2022): https://github.com/xoofx/markdig/issues/155 doesn't list tables yet, so it might simply not be implemented at this point.
Author
Owner

@MihaZupan commented on GitHub (Aug 2, 2022):

Duplicate of #155

@MihaZupan commented on GitHub (Aug 2, 2022): Duplicate of #155
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#551