Trying to get the pipe table to work #445

Closed
opened 2026-01-29 14:36:57 +00:00 by claunia · 2 comments
Owner

Originally created by @Dennizzzzz on GitHub (Mar 15, 2021).

Maybe a N00b question, but I'm trying to get a pipe table to work.
And I cannot find any C# example code.

Tried this:

var h = "a|b|b";
h += "--|--|--";
h += "1|2|3";
var r = MarkDig.Markdown.ToHtml();

but r results in:
<p>a|b|c--|--|--1|2|3</p>

documentation : here is not really helping...

Update:
Tried this, but also not working:

   var p = new Markdig.MarkdownPipelineBuilder().UsePipeTables().Build();
   var h = "a|b|c";
   h += "--|--|--";
   h += "1|2|3";
   var r = Markdig.Markdown.ToHtml(h,p);

What am I missing?

Originally created by @Dennizzzzz on GitHub (Mar 15, 2021). Maybe a N00b question, but I'm trying to get a pipe table to work. And I cannot find any C# example code. Tried this: ``` var h = "a|b|b"; h += "--|--|--"; h += "1|2|3"; var r = MarkDig.Markdown.ToHtml(); ``` but r results in: `<p>a|b|c--|--|--1|2|3</p>` documentation : [here](https://github.com/xoofx/markdig/blob/master/src/Markdig.Tests/Specs/PipeTableSpecs.md) is not really helping... Update: Tried this, but also not working: ``` var p = new Markdig.MarkdownPipelineBuilder().UsePipeTables().Build(); var h = "a|b|c"; h += "--|--|--"; h += "1|2|3"; var r = Markdig.Markdown.ToHtml(h,p); ``` What am I missing?
Author
Owner

@MihaZupan commented on GitHub (Mar 15, 2021):

You'll need to add some new lines there - you're currently trying to render a|b|b--|--|--1|2|3

@MihaZupan commented on GitHub (Mar 15, 2021): You'll need to add some new lines there - you're currently trying to render `a|b|b--|--|--1|2|3`
Author
Owner

@Dennizzzzz commented on GitHub (Mar 15, 2021):

Thanks to @MihaZupan

   var p = new Markdig.MarkdownPipelineBuilder().UsePipeTables().Build();
   var h = "a|b|c" + Environment.NewLine;
   h += "--|--|--" + Environment.NewLine;
   h += "1|2|3" + Environment.NewLine;
   var r = Markdig.Markdown.ToHtml(h,p);

returns:

<table>
<thead>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>
@Dennizzzzz commented on GitHub (Mar 15, 2021): Thanks to @MihaZupan ``` var p = new Markdig.MarkdownPipelineBuilder().UsePipeTables().Build(); var h = "a|b|c" + Environment.NewLine; h += "--|--|--" + Environment.NewLine; h += "1|2|3" + Environment.NewLine; var r = Markdig.Markdown.ToHtml(h,p); ``` returns: ``` <table> <thead> <tr> <th>a</th> <th>b</th> <th>c</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> </tbody> </table> ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#445