Markdown Converter – Convert MD in C# or Online
Markdown is a lightweight markup language designed to indicate formatting in plain text. MD files use Markdown language that was proposed and developed by John Gruber. They include inline text characters that determine how text is formatted, such as indentation, table formatting, fonts, and headings. In addition, MD files can be converted to HTML, PDF or images to take advantage of other formats for specific tasks.
The main highlight of Aspose.HTML is a conversion feature. The Aspose.Html.Converters namespace implements easy access to conversion methods. It provides a wide range of conversions to popular formats, such as Markdown to HTML, Markdown to DOCX, or Markdown to PDF.
You can download the complete examples and data files from GitHub.
This section provides information on the list of supported Markdown conversions and how to perform them using ConvertMarkdown() methods. All of these methods allow for the basic Markdown to HTML conversion. Conversions from Markdown to other formats go through the Markdown to HTML conversion stage.
Please take a look at the following C# example, which shows Markdown to JPG conversion with ImageSaveOptions specifying:
1using System.IO;
2using Aspose.Html.Converters;
3using Aspose.Html.Rendering.Image;
4using Aspose.Html.Saving;
5using System.Drawing;
6...
7
8 // Prepare a path to a source Markdown file
9 string sourcePath = Path.Combine(DataDir, "nature.md");
10
11 // Prepare a path for converted file saving
12 string outputPath = Path.Combine(OutputDir, "nature-options.jpg");
13
14 // Convert Markdown to HTML
15 using var document = Converter.ConvertMarkdown(sourcePath);
16
17 // Initialize an instance of ImageSaveOptions
18 var options = new ImageSaveOptions(ImageFormat.Jpeg)
19 {
20 BackgroundColor = System.Drawing.Color.AliceBlue
21 };
22
23 // Convert HTML document to JPG image file format
24 Converter.ConvertHTML(document, options, outputPath);
In the example, the
ConvertMarkdown(sourcePath
) method takes the source path of an Markdown file and results an
HTMLDocument. The ImageSaveOptions() constructor creates a new
ImageSaveOptions object with JPG ImageFormat and BackgroundColor properties. Then, the
ConvertHTML() method takes HTMLDocument, ImageSaveOptions, and output path and completes the Markdown to JPG conversion.
Aspose.HTML offers a free online Markdown Converter for converting Markdown files to a variety of popular formats. You can easily convert Markdown to HTML, Markdown to PDF, Markdown to JPG, or MHTML to DOCX. Just select the file, choose the format to convert, and you’re done. It’s fast and completely free!