This basic tutorial explains how to convert Markdown to HTML in C#. It contains all the important details like the system configuration, step-by-step method calls, and finally, a running code sample to convert MD to HTML in C#. In a nutshell, you only need to make a couple of API calls to load a Markdown file and export it as an HTML file.
Steps to Convert Markdown to HTML in C#
- Install Aspose.HTML for .NET API in your system to convert Markdown files
- Open the source file as a stream
- Convert the input file with the ConvertMarkdown method
- Export the output HTML file with the Save method
These steps are helpful to understand how using C# Markdown to HTML conversion can be performed. In the first step, initialize an instance of FileStream class to load the source MD file. Then convert it to HTML format and write the output file to the disk or memory stream. Moreover, you can choose to use markdown formatted string or load the input MD file depending on your use case.
Code to Convert Markdown to HTML in C#
This code snippet is one of the basic versions to render Markdown to HTML in C#. However, there are multiple overloads of the ConvertMarkdown method where you can pass the file path as a string, as well as the path for the output file. Similarly, Save() method has different overloads to accommodate various requirements and scenarios of your application.
This tutorial explains how to generate HTML from Markdown in C#. Whereas, if you want to learn Markdown to XPS conversion, refer to the article on how to convert Markdown to XPS in C#.