commonmark-to-dom

Module script to render Markdown directly into DOM on web browsers

Usage no npm install needed!

<script type="module">
  import commonmarkToDom from 'https://cdn.skypack.dev/commonmark-to-dom';
</script>

README

Introduction

The mdtodom.js script renders a commonmark.js AST directly into DOM on modern web browsers to make a webpage from a Markdown content.

(License)

Usage

The basic usage of the script is shown below:

import {DOMRenderer} from "./mdtodom.js";

// Assuming commonmark.js has been loaded.
let parser = new window.commonmark.Parser();
let renderer = new DOMRenderer(document);
let child = rendereer.render(parser.parse("*something* in Markdown"));

let container = document.getElementById("container");
container.appendChild(child);

See also

The project home.

Informational references

The Fetch standard by WHATWG.

The Fetch API documentation on MDN.