Marked
v18.1.3Low level, high speed Markdown parser and compiler.
Quick start
Add this tag to your page. Place it just before the closing </body> tag, or in the <head> with the defer attribute.
HTML
<script src="https://jscdns.net/libs/marked/18.1.3/marked.umd.js"
integrity="sha384-tp/syYhgK+FeVVrz2SPmgKX5atVZ8P8hReAvOPUn58M265VNy1IbdmZAY7Jmd0gF" crossorigin="anonymous"></script>Files
| File | Size | Copy |
|---|---|---|
| marked.umd.jsScript | 49.4 KB | |
| marked.esm.jsES module | 48.5 KB |
Usage
Complete example
A minimal page that loads Marked and uses it. Copy it into a file and open it in your browser.
example.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<div id="preview"></div>
<script src="https://jscdns.net/libs/marked/18.1.3/marked.umd.js"
integrity="sha384-tp/syYhgK+FeVVrz2SPmgKX5atVZ8P8hReAvOPUn58M265VNy1IbdmZAY7Jmd0gF" crossorigin="anonymous"></script>
<script>
const markdown = '# Release notes\n\n- Faster parsing\n- **Bug** fixes';
// This Markdown is trusted. If it comes from users, sanitise the
// output with DOMPurify before inserting it into the page.
document.querySelector('#preview').innerHTML = marked.parse(markdown);
</script>
</body>
</html>Using the ES module build
If your page already uses <script type="module">, you can import the module build directly instead of relying on a global variable.
module.html
<script type="module">
import { marked } from 'https://jscdns.net/libs/marked/18.1.3/marked.esm.js';
console.log(marked.parse('**Hello** world'));
</script>Good to know. Marked does not sanitise its output. If the Markdown comes from users, pass the result through DOMPurify before adding it to the page.