Pipe-based markdown tables are not converting correctly to HTML #459

Open
opened 2026-01-29 14:37:21 +00:00 by claunia · 0 comments
Owner

Originally created by @nhamawi on GitHub (May 7, 2021).

EDITED TO REPRODUCE OIRIGINAL ISSUE FOR OTHERS THAT MIGHT RUN INTO THE SAME ISSUE

[... or the documentation is missing some relevant setup information]

When trying to convert a pipe-based markdown table to HTML, the result does not include any form of HTML table even with advanced extensions enabled. Instead, the result includes the input text in paragraph blocks < p > and < /p >.

This can be reproduced with .netfiddle as follows and the latest version of Markdig (0.24.0):

using System;
using System.IO;
using Markdig;
using Markdig.Renderers;
using Markdig.Parsers;

public class Program
{
	private static string Render(string markdown)
	{
		var writer = new StringWriter();
		var renderer = new HtmlRenderer(writer);
		var pipeline = new MarkdownPipelineBuilder()
			.UseAdvancedExtensions()
			.UsePipeTables()
			.Build();
		var document = MarkdownParser.Parse(markdown, pipeline);
		// pipeline.Setup(renderer); <-- Was missing this. Uncomment to fix this issue
		renderer.Render(document);
		writer.Flush();
		return writer.ToString();
	}

	public static void Main()
	{
		var markdown = "a | b \r\n" + "-- | - \r\n" + "0 | 1 ";
		var html = Render(markdown);
		Console.WriteLine(html);
	}
}

And the output:

<p>a</p>
<p>b</p>
<p>0</p>
<p>1</p>
Originally created by @nhamawi on GitHub (May 7, 2021). **EDITED TO REPRODUCE OIRIGINAL ISSUE FOR OTHERS THAT MIGHT RUN INTO THE SAME ISSUE** [... or the documentation is missing some relevant setup information] When trying to convert a pipe-based markdown table to HTML, the result does not include any form of HTML table even with advanced extensions enabled. Instead, the result includes the input text in paragraph blocks < p > and < /p >. This can be reproduced with .netfiddle as follows and the latest version of Markdig (0.24.0): using System; using System.IO; using Markdig; using Markdig.Renderers; using Markdig.Parsers; public class Program { private static string Render(string markdown) { var writer = new StringWriter(); var renderer = new HtmlRenderer(writer); var pipeline = new MarkdownPipelineBuilder() .UseAdvancedExtensions() .UsePipeTables() .Build(); var document = MarkdownParser.Parse(markdown, pipeline); // pipeline.Setup(renderer); <-- Was missing this. Uncomment to fix this issue renderer.Render(document); writer.Flush(); return writer.ToString(); } public static void Main() { var markdown = "a | b \r\n" + "-- | - \r\n" + "0 | 1 "; var html = Render(markdown); Console.WriteLine(html); } } And the output: <p>a</p> <p>b</p> <p>0</p> <p>1</p>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#459