Skip to content

A browser script to render Markdown text directly into DOM.

Notifications You must be signed in to change notification settings

vx68k/mdtodom.js

Repository files navigation

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.