How to generate real HTML? #210

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

Originally created by @topfunet on GitHub (May 31, 2018).

this is my code:
var pipeline = new MarkdownPipelineBuilder().ConfigureNewLine(Environment.NewLine).UseAdvancedExtensions().Build();
var result = Markdown.ToHtml("This is a text \r\n\r\n with some emphasis", pipeline);
this is the OUTPUT:
"

This is a text

\r\n

with some emphasis

\r\n"
BUT what i want is:

This is a text

with some emphasis

Because \r\n is for WPF not for real HTML, i want to put result to a html page, so how can i do it?
Originally created by @topfunet on GitHub (May 31, 2018). this is my code: var pipeline = new MarkdownPipelineBuilder().ConfigureNewLine(Environment.NewLine).UseAdvancedExtensions().Build(); var result = Markdown.ToHtml("This is a text \r\n\r\n with some *emphasis*", pipeline); this is the OUTPUT: "<p>This is a text</p>\r\n<p>with some <em>emphasis</em></p>\r\n" BUT what i want is: <p>This is a text</p><p>with some <em>emphasis</em></p> Because \r\n is for WPF not for real HTML, i want to put result to a html page, so how can i do it?
claunia added the questioninvalid labels 2026-01-29 14:30:28 +00:00
Author
Owner

@Kryptos-FR commented on GitHub (May 31, 2018):

Are you sure you are using the library correctly? I just tried and I get the expected:

<p>This is a text</p>
<p>with some <em>emphasis</em></p>
@Kryptos-FR commented on GitHub (May 31, 2018): Are you sure you are using the library correctly? I just tried and I get the expected: ``` <p>This is a text</p> <p>with some <em>emphasis</em></p> ```
Author
Owner

@xoofx commented on GitHub (May 31, 2018):

@topfunet first, you should learn how to format your github issue using markdown (use escape code, code blocks...etc.). It is almost unreadable as-is as I had to go back to edit your issue to see exactly the expected markdown. That's also a bit ironic to use a markdown library but not use markdown properly here 😐

Because \r\n is for WPF not for real HTML

Secondly, this is confusing and wrong. You are using Markdown.ToHtml so there is absolutely zero WPF involved here. Also, what do you mean by real HTML? \r\n are known as #text white spaces in HTML and they are perfectly valid output inside tags and between tags. You should not even care about them, as for most of the case, they are not displayed by browsers.

i want to put result to a html page, so how can i do it?

Markdig provides a method to output a HTML fragment (so no <html>, <head>, <body> tags), something that you can put into a HTML page/body...etc. It is up to your application to integrate markdig and insert the result of the conversion at the proper place.

Closing as there are no issues here related to the library correctness.

@xoofx commented on GitHub (May 31, 2018): @topfunet first, you should learn how to format your github issue using markdown (use escape code, code blocks...etc.). It is almost unreadable as-is as I had to go back to edit your issue to see exactly the expected markdown. That's also a bit ironic to use a markdown library but not use markdown properly here :neutral_face: > Because \r\n is for WPF not for real HTML Secondly, this is confusing and wrong. You are using `Markdown.ToHtml` so there is absolutely zero WPF involved here. Also, what do you mean by real HTML? `\r\n` are known as [`#text` white spaces in HTML](https://www.w3.org/TR/html401/struct/text.html) and they are perfectly valid output inside tags and between tags. You should not even care about them, as for most of the case, they are not displayed by browsers. > i want to put result to a html page, so how can i do it? Markdig provides a method to output a HTML fragment (so no `<html>, <head>, <body>` tags), something that you can put into a HTML page/body...etc. It is up to your application to integrate markdig and insert the result of the conversion at the proper place. Closing as there are no issues here related to the library correctness.
Author
Owner

@vexx32 commented on GitHub (Feb 26, 2021):

@xoofx

Markdig provides a method to output a HTML fragment (so no <html>, <head>, tags), something that you can put into a HTML page/body...etc.

I've been looking for this but several google searches and searches in this repo have come up completely empty. How can this be done?

EDIT: Apparently I just hadn't realized that was the default behaviour for Markdown.ToHtml(). Never mind then, thanks! 😁

@vexx32 commented on GitHub (Feb 26, 2021): @xoofx > Markdig provides a method to output a HTML fragment (so no <html>, <head>, <body> tags), something that you can put into a HTML page/body...etc. I've been looking for this but several google searches and searches in this repo have come up completely empty. How can this be done? EDIT: Apparently I just hadn't realized that was the default behaviour for Markdown.ToHtml(). Never mind then, thanks! 😁
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#210