mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-07 21:42:25 +00:00
Unabled to convert empty lines into the correct HTML element #591
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tiagolima97 on GitHub (Feb 16, 2023).
Here's an image showing what the markdown text I'm trying to convert looks like:

Here's the value I have relative to the previous image:
TEST 1\n\nTEST 2\n\nTEST 3\n\n- TEST 4\n- TEST 5Here's the output I'm getting from the
Markdown.ToHtmlmethod:<p>TEST 1</p>\n<p>TEST 2</p>\n<p>TEST 3</p>\n<ul>\n<li>TEST 4</li>\n<li>TEST 5</li>\n</ul>\nThe output is returned with a bunch of
\nthat aren't converted successfully to HTML tags.Here's the output I was expecting to get:
<p>TEST 1</p><br><p>TEST 2</p><br><p>TEST 3</p><br><ul><li>TEST 4</li><li>TEST 5</li></ul>@xoofx commented on GitHub (Feb 16, 2023):
It depends on the options you are using. The default is that it should be CommonMark compliant, and it means that you don't get
<br>for multiple lines. There is an extension in Markdig to create hard break lines, but it's not outside of a paragraph as you expect (afair,<br>has to be inside a<p>as per the HTML specs)@tiagolima97 commented on GitHub (Feb 17, 2023):
Thanks for the quick response @xoofx!
In regard to the
<br>being inside the<p>, you're correct, that's how it should be returned. My mistake.However, I've tried adding the extension needed to create hard break lines but I still get the same output.
It seems that Markdig is struggling to understand what these
\nmean and leaves them unparsed.Here's the implementation I'm testing:

Here's the output I'm getting:

@xoofx commented on GitHub (Feb 17, 2023):
Yep, but the extension is for lines within a paragraph, not trailing blank lines. The problem is that blank lines are used to break paragraph already. It's part of CommonMark parsing rules and this is not something that can be changed.
@CraigComeOnThisNameCantBeTaken commented on GitHub (May 18, 2023):
I am also finding this a problem
@angezid commented on GitHub (May 26, 2023):
Why Github
not following this stupid
rule?
How to keep structure of documents then?
@xoofx commented on GitHub (May 26, 2023):
A blank line is not considered as a structure. Don't use Markdown in that case.