Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 22, 2021 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/c709fbcda21b373ca9c96a3711a6767a to your computer and use it in GitHub Desktop.
Save aspose-com-gists/c709fbcda21b373ca9c96a3711a6767a to your computer and use it in GitHub Desktop.
Convert Markdown to HTML or HTML Webpage to Markdown .md File in Java
// Prepare an HTML code and save it to the file.
String code = "<h1>Header 1</h1>" +
"<h2>Header 2</h2>" +
"<p>Hello World!!</p>";
FileWriter fw = new FileWriter("document.html");
fw.write(code);
fw.close();
// Call ConvertHTML method to convert HTML to Markdown.
Converter.convertHTML(dataDir + "document.html", new MarkdownSaveOptions(), "output.md");
// Prepare a simple Markdown example
String code = "### Hello World" +
"\r\n" +
"[visit blogs](https://blog.aspose.com/)";
// Create a Markdown file
FileWriter fw = new FileWriter("input_document.md");
fw.write(code);
fw.close();
// Convert Markdown to HTML document
Converter.convertMarkdown("input_document.md","MarkdownToHTMLoutput.html");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment