How can I convert markdown into html in .NET?
var markdown = "Some **bold** text";
var output = ConvertMarkdownToHtml(markdown)
// Output: <p>Some <strong>bold</strong> text</p>
I have Markdown text stored in a database that needs to be converted to html when it is displayed.
I know about StackOverflow's WMD Editor (now PageDown), but that only converts client-side.
To convert Markdown to HTML using Typora, click File —> Export —> HTML. Then save the file in your preferred location. The image below shows that the HTML output looks exactly as how the Markdown is displayed inside Typora.
Originally created to make writing XHTML/HTML easier by converting plain-text files into structurally valid HTML or XHTML, Markdown can be used for almost any type of writing: manuscripts, tutorials, notes, web content and more.
Markdown is easier to write than HTML, and it's easier for most humans to read Markdown source than HTML source. However, HTML is more expressive (particularly regarding semantic tagging) and can achieve some specific effects that might be difficult or impossible in Markdown.
Despite their visual differences, all of the applications do the same thing. Like Dillinger, they all convert Markdown-formatted text to HTML so it can be displayed in web browsers.
TL;DR: now it's 2021 use markdig
I just came across this questions and the answers are all quite old. It appears that implementations based on commonmark are the suggested way to go now. Implementations for lots of languages (including C#) can be found here
Another implementation that seems to be gaining ground is MarkdownDeep
This is a full implementation for both C# and JavaScript. The MarkdownHelper on Nuget is using MarkdownDeep now instead of MarkdownSharp.
I've used both and MarkdownDeep seems to be more fully functional and having the JavaScript version is great for quick client side setups.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With