Convert Markdown to HTML or HTML to MD File in Java

Convert MD HTML Java

Markdown is used to create formatted text with plain text symbols. You can easily format text as bold, italic, underline, and other formatting types. You can convert Markdown MD to HTML as well as HTML to Markdown programmatically in Java. The following sections explain these conversion scenarios.

HTML and Markdown Converter – API Installation

You can convert the HTML webpage to a Markdown file using Java. You can configure Aspose.HTML for Java API by downloading the JAR file from the Downloads section or using the following Maven configurations in your project.

Repository

 <repositories>
     <repository>
         <id>snapshots</id>
         <name>repo</name>
         <url>http://repository.aspose.com/repo/</url>
     </repository>
</repositories>

Dependency

 <dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-html</artifactId>
        <version>21.6</version>
        <classifier>jdk16</classifier>
    </dependency>
</dependencies>

Convert HTML Webpage to Markdown MD Programmatically in Java

You can convert HTML Webpage to Markdown text with the following steps.

  1. Load the input HTML file.
  2. Specify MarkdownSaveOptions object.
  3. Call ConvertHTML method and save output Markdown .md file.

The code snippet below shows how to convert HTML Webpage to Markdown .md in Java:

Convert Markdown .md File to HTML Webpage Programmatically in Java

You can convert a Markdown .md file to HTML webpage with the following steps:

  1. Load the input Markdown file.
  2. Save output HTML file with ConvertMarkdown method.

The following code snippet explains how to convert a Markdown file to HTML Webpage in Java:

Conclusion

In this article, you have learned how to convert Markdown files to HTML or HTML webpage to Markdown programmatically in Java. Moreover, you can learn other features of the API by visiting the documentation. In case of any concerns, please feel free to contact us at the forum.

See Also

Convert (MD) Markdown to PDF or Image in Java