UseSoftlineBreakAsHardlineBreak() doesn't work? #311

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

Originally created by @denys-olleik on GitHub (Jul 3, 2019).

I see absolutely no difference with the following...

var pipeline1 = new MarkdownPipelineBuilder().UseSoftlineBreakAsHardlineBreak().Build();
var pipeline2 = new MarkdownPipelineBuilder().Build();

var result1 = Markdown.ToHtml("test\r\n\r\n\r\ntest", pipeline1);
var result2 = Markdown.ToHtml("test\r\n\r\n\r\ntest", pipeline2);

Output...

<p>test</p>
<p>test</p>

Expected output...

<p>test</p>
</br>
</br>
<p>test</p>

I thought at some point it worked and added </br>, no?

Originally created by @denys-olleik on GitHub (Jul 3, 2019). I see absolutely no difference with the following... var pipeline1 = new MarkdownPipelineBuilder().UseSoftlineBreakAsHardlineBreak().Build(); var pipeline2 = new MarkdownPipelineBuilder().Build(); var result1 = Markdown.ToHtml("test\r\n\r\n\r\ntest", pipeline1); var result2 = Markdown.ToHtml("test\r\n\r\n\r\ntest", pipeline2); Output... <p>test</p> <p>test</p> Expected output... <p>test</p> </br> </br> <p>test</p> I thought at some point it worked and added `</br>`, no?
Author
Owner

@MihaZupan commented on GitHub (Jul 3, 2019):

If you test "test\r\ntest", you will see the difference as that is a line break inside of a paragraph.

What is happening in your example is that you have multiple newlines which means you're splitting the paragraph into two.

@MihaZupan commented on GitHub (Jul 3, 2019): If you test `"test\r\ntest"`, you will see the difference as that is a line break inside of a paragraph. What is happening in your example is that you have multiple newlines which means you're splitting the paragraph into two.
Author
Owner

@denys-olleik commented on GitHub (Jul 3, 2019):

Ok, maybe I misunderstood what that UseSoftlineBreakAsHardlineBreak does. But I'm looking for a way to preserve spaces between my paragraphs that I get back from my textarea.

@denys-olleik commented on GitHub (Jul 3, 2019): Ok, maybe I misunderstood what that UseSoftlineBreakAsHardlineBreak does. But I'm looking for a way to preserve spaces between my paragraphs that I get back from my textarea.
Author
Owner

@MihaZupan commented on GitHub (Jul 3, 2019):

The extension does what you think it does (insert <br> to force a new-line being rendered in the browser), but having a blank line between text in markdown means that that ends the paragraph and all blank lines are discarded.

From the top of my head I can only think of inserting <br> tags into the document manually where you want more empty lines.

@MihaZupan commented on GitHub (Jul 3, 2019): The extension does what you think it does (insert `<br>` to force a new-line being rendered in the browser), but having a blank line between text in markdown means that that ends the paragraph and all blank lines are discarded. From the top of my head I can only think of inserting `<br>` tags into the document manually where you want more empty lines.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#311