Markdown Import and Export

  • editor.fromMarkdown(text) converts Markdown to HTML; pass the result to setHTMLCode().
  • 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. Raw HTML inside the Markdown is shown as text, not run.
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.