项目作者: markedjs

项目描述 :
A markdown parser and compiler. Built for speed.
高级语言: JavaScript
项目地址: git://github.com/markedjs/marked.git
创建时间: 2011-07-24T13:15:51Z
项目社区:https://github.com/markedjs/marked

开源协议:Other

下载




Marked

npm
install size
downloads
github actions
snyk

  • ⚡ 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:

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. npm install -g marked

In-browser:

  1. npm install marked

Usage

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

CLI

  1. # Example with stdin input
  2. $ marked -o hello.html
  3. hello world
  4. ^D
  5. $ cat hello.html
  6. <p>hello world</p>
  1. # Print all options
  2. $ marked --help

Browser

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

or import esm module

  1. <script type="module">
  2. import { marked } from "https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js";
  3. document.getElementById('content').innerHTML =
  4. marked.parse('# Marked in the browser\n\nRendered by **marked**.');
  5. </script>

License

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