Issue while trying to convert markdown to Html ( with pipelines) #280

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

Originally created by @Matteo7497 on GitHub (Mar 7, 2019).

Hello,
I'm trying to convert some markdown to html using this code:

var pipeline = new MarkdownPipelineBuilder();
MarkdownPipeline markdownPipeline = pipeline.UseAdvancedExtensions().UsePipeTables().Build();
StringWriter tw = new StringWriter();
MarkdownObject doc = Markdown.ToHtml(markdown, tw, markdownPipeline);

After that i have to update links in the Markup from relative to absolute paths.
So, after that i'm trying to convert the MarkdownObject to string using this code:

var builder = new StringBuilder();
var textwriter = new StringWriter(builder);
var renderer = new HtmlRenderer(textwriter);
var t = renderer.Render(doc);
return builder.ToString();

so what?
Pipe Tables are parsed as paragraphs.

Some example:

| abc | def | ghi |
|---|---|---|
| 1 | 2 | 3 |

this markdown table is parsed as:

<p>abc</p>
<p>def</p>
<p>ghi</p>
<p>1</p>
<p>2</p>
<p>3</p>

However if i use this code everthing works (but i can't update links in an easy way)

string html = Markdown.ToHtml(markdown, markdownPipeline);

How can i convert this markdown?
Thank you so much.

Originally created by @Matteo7497 on GitHub (Mar 7, 2019). Hello, I'm trying to convert some markdown to html using this code: ``` var pipeline = new MarkdownPipelineBuilder(); MarkdownPipeline markdownPipeline = pipeline.UseAdvancedExtensions().UsePipeTables().Build(); StringWriter tw = new StringWriter(); MarkdownObject doc = Markdown.ToHtml(markdown, tw, markdownPipeline); ``` After that i have to update links in the Markup from relative to absolute paths. So, after that i'm trying to convert the MarkdownObject to string using this code: ``` var builder = new StringBuilder(); var textwriter = new StringWriter(builder); var renderer = new HtmlRenderer(textwriter); var t = renderer.Render(doc); return builder.ToString(); ``` so what? Pipe Tables are parsed as paragraphs. Some example: ``` | abc | def | ghi | |---|---|---| | 1 | 2 | 3 | ``` this markdown table is parsed as: ``` <p>abc</p> <p>def</p> <p>ghi</p> <p>1</p> <p>2</p> <p>3</p> ``` However if i use this code everthing works (but i can't update links in an easy way) `string html = Markdown.ToHtml(markdown, markdownPipeline); ` How can i convert this markdown? Thank you so much.
claunia added the questioninvalid labels 2026-01-29 14:32:38 +00:00
Author
Owner

@xoofx commented on GitHub (Mar 7, 2019):

Just look at ToHtml, likely you forgot to setup the renderer with the pipeline:

ea99cd6115/src/Markdig/Markdown.cs (L98-L105)

@xoofx commented on GitHub (Mar 7, 2019): Just look at `ToHtml`, likely you forgot to setup the renderer with the pipeline: https://github.com/lunet-io/markdig/blob/ea99cd6115a0d1e48759214c27c4a5cfde37d02e/src/Markdig/Markdown.cs#L98-L105
Author
Owner

@Matteo7497 commented on GitHub (Mar 8, 2019):

Thank you so much!!
I forgot to setup the renderer with the pipeline, now it works correctly!

@Matteo7497 commented on GitHub (Mar 8, 2019): Thank you so much!! I forgot to setup the renderer with the pipeline, now it works correctly!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#280