UNPKG

2.88 kBMarkdownView Raw
1<a href="https://marked.js.org">
2 <img width="60px" height="60px" src="https://marked.js.org/img/logo-black.svg" align="right" />
3</a>
4
5# Marked
6
7[![npm](https://badgen.net/npm/v/marked)](https://www.npmjs.com/package/marked)
8[![gzip size](https://badgen.net/badgesize/gzip/https://cdn.jsdelivr.net/npm/marked/marked.min.js)](https://cdn.jsdelivr.net/npm/marked/marked.min.js)
9[![install size](https://badgen.net/packagephobia/install/marked)](https://packagephobia.now.sh/result?p=marked)
10[![downloads](https://badgen.net/npm/dt/marked)](https://www.npmjs.com/package/marked)
11[![github actions](https://github.com/markedjs/marked/workflows/Tests/badge.svg)](https://github.com/markedjs/marked/actions)
12[![snyk](https://snyk.io/test/npm/marked/badge.svg)](https://snyk.io/test/npm/marked)
13
14- ⚡ built for speed
15- ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time
16- ⚖️ light-weight while implementing all markdown features from the supported flavors & specifications
17- 🌐 works in a browser, on a server, or from a command line interface (CLI)
18
19## Demo
20
21Checkout the [demo page](https://marked.js.org/demo/) to see marked in action ⛹️
22
23## Docs
24
25Our [documentation pages](https://marked.js.org) are also rendered using marked 💯
26
27Also read about:
28
29* [Options](https://marked.js.org/#/USING_ADVANCED.md)
30* [Extensibility](https://marked.js.org/#/USING_PRO.md)
31
32## Compatibility
33
34**Node.js:** Only [current and LTS](https://nodejs.org/en/about/releases/) Node.js versions are supported. End of life Node.js versions may become incompatible with Marked at any point in time.
35
36**Browser:** Not IE11 :)
37
38## Installation
39
40**CLI:**
41
42```sh
43npm install -g marked
44```
45
46**In-browser:**
47
48```sh
49npm install marked
50```
51
52## Usage
53
54### Warning: 🚨 Marked does not [sanitize](https://marked.js.org/#/USING_ADVANCED.md#options) the output HTML. Please use a sanitize library, like [DOMPurify](https://github.com/cure53/DOMPurify) (recommended), [sanitize-html](https://github.com/apostrophecms/sanitize-html) or [insane](https://github.com/bevacqua/insane) on the *output* HTML! 🚨
55
56```
57DOMPurify.sanitize(marked.parse(`<img src="x" onerror="alert('not happening')">`));
58```
59
60**CLI**
61
62``` bash
63# Example with stdin input
64$ marked -o hello.html
65hello world
66^D
67$ cat hello.html
68<p>hello world</p>
69```
70
71```bash
72# Print all options
73$ marked --help
74```
75
76**Browser**
77
78```html
79<!doctype html>
80<html>
81<head>
82 <meta charset="utf-8"/>
83 <title>Marked in the browser</title>
84</head>
85<body>
86 <div id="content"></div>
87 <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
88 <script>
89 document.getElementById('content').innerHTML =
90 marked.parse('# Marked in the browser\n\nRendered by **marked**.');
91 </script>
92</body>
93</html>
94```
95
96## License
97
98Copyright (c) 2011-2022, Christopher Jeffrey. (MIT License)