HTML to Markdown Conversion

Summary

Markdown is a generally well-accepted markup language that often used as a format for documentation and readme files. It is popular with technical writers for its simplicity of use and lightweight learning and broad support. You can access and edit Markdown files or create new content from any devices in any text editor. Working in Markdown is safe and secure because a text editor never crash. Using Aspose.HTML Cloud library you can convert HTML to Markdown format in your C# and other .NET programming languages.

Aspose.HTML Cloud v4.0 provides the simplest API to convert HTML documents to Markdown format with high quality, easy and fast. This article demonstrates how to convert HTML file to Markdown by direct REST API calls or using SDKs.

cURL Example

A cURL is a command-line tool that you can use to access Aspose.HTML Cloud web services.

This example demonstrates how to convert an HTML file located in the default cloud storage to Markdown with default parameters using the cURL utility (in the console, or using the system shell script - .bat file or PowerShell script in Windows, bash script in Linux etc.).

Step 1: Get JWT token for the user authentication

Step 2: Initialize an asynchronous conversion process using the POST method

The curl -X POST command specifies a request method (POST) to use when communicating with the HTTP server. The POST method is usually used in requests for adding data; in this case, an empty parameter list is passed -d "{}".

Step 3: Check the previously started conversion process status using the GET method

The GET method allows checking the previously started operation state by its ID and returns the state object.

SDK Examples

These examples demonstrate how to convert HTML to Markdown using available SDKs.

Case 1. Convert an HTML document from the storage by its name to Markdown and save to the storage

In the example, we used methods of the ConverterBuilder class: FromStorageFile(inputPath), To(ConversionOptions) and SaveToStorage(outputDirectory) that specify input data, the output format and the target directory for a conversion result.

Case 2. Convert a Web page by its URL to Markdown and save to the local file system

Aspose.HTML Cloud SDK allows you to get HTML page from the web by its URL, convert it to another format and save into the local file system. The example below demonstrates how to convert HTML to Markdown.

In the example, we use methods of the ConverterBuilder class: FromUrl(urlAddress), To(ConversionOptions) and SaveToStorage(outputDirectory) that specify input data, the output format and the target directory for a conversion result.

You can get information about all the API resources from Aspose.HTML for Cloud API Reference.