Markdown Import and Export
Switch between rich text and Markdown.
Production example
See RichTextEditor in RichMarkdown
A live writing app built with RichTextEditor: visual editing, inline code, fenced code blocks, and Markdown import and export.
Try local notes, research clips, Markdown downloads and Word export. RichMarkdown is free to use.
editor.fromMarkdown(text)converts Markdown to HTML; pass the result tosetHTMLCode().editor.toMarkdown()exports the document: headings, bold and italic, links, lists, quotes, tables and fenced code with its language.- Your users edit visually; you store Markdown. Simple formatting tags with no attributes, such as
<b>,<i>and<u>, stay as formatting. Other raw HTML, including scripts, is shown as text and never runs.
Editor
<div id="div_editor1"></div>
<script>
var editor1 = new RichTextEditor("#div_editor1");
// Load Markdown: it is converted to HTML and shown in the editor.
editor1.setHTMLCode(editor1.fromMarkdown(markdownFromYourServer));
// Export: turn the edited document back into Markdown.
var markdown = editor1.toMarkdown();
</script>Related: HTML, JSON or Markdown: how to store rich text, save and load content.