markedjs/marked

README

Marked


github actions

⚡* built for speed
⬇️* low-level compiler for parsing markdown without caching or blocking for long periods of time
⚖️* light-weight while implementing all markdown features from the supported flavors & specifications
🌐* works in a browser, on a server, or from a command line interface (CLI)

Demo


Checkout the demo page to see marked in action ⛹️

Docs


Our documentation pages are also rendered using marked 💯

Also read about:

Options
Extensibility

Compatibility


Node.js:Only current and LTS Node.js versions are supported. End of life Node.js versions may become incompatible with Marked at any point in time.

Browser:Not IE11 :)

Installation


CLI:

  1. ``` shell
  2. npm install -g marked
  3. ```

In-browser:

  1. ``` shell
  2. npm install marked
  3. npm install @types/marked # For TypeScript projects
  4. ```

Usage


Warning: 🚨 Marked does not sanitize the output HTML. Please use a sanitize library, like DOMPurify (recommended), sanitize-html or insane on the output HTML! 🚨


  1. ``` sh
  2. DOMPurify.sanitize(marked.parse(`<img src="x" onerror="alert('not happening')">`));

  3. ```

CLI

  1. ``` shell
  2. # Example with stdin input
  3. $ marked -o hello.html
  4. hello world
  5. ^D
  6. $ cat hello.html
  7. <p>hello world</p>
  8. ```

  1. ``` shell
  2. # Print all options
  3. $ marked --help
  4. ```

Browser

  1. ``` html
  2. <!doctype html>
  3. <html>
  4. <head>
  5.   <meta charset="utf-8"/>
  6.   <title>Marked in the browser</title>
  7. </head>
  8. <body>
  9.   <div id="content"></div>
  10.   <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
  11.   <script>
  12.     document.getElementById('content').innerHTML =
  13.       marked.parse('# Marked in the browser\n\nRendered by **marked**.');
  14.   </script>
  15. </body>
  16. </html>
  17. ```

License


Copyright (c) 2011-2022, Christopher Jeffrey. (MIT License)