2018-04-05 20:47:03 -04:00
< a href = "https://marked.js.org" >
< img width = "60px" height = "60px" src = "https://marked.js.org/img/logo-black.svg" align = "right" / >
< / a >
2018-02-25 18:09:11 -05:00
2018-04-05 17:15:11 -04:00
# Marked
2018-02-25 14:18:59 -05:00
2018-08-06 11:22:35 -07:00
[](https://www.npmjs.com/package/marked)
2018-08-06 18:36:38 -05:00
[](https://packagephobia.now.sh/result?p=marked)
2018-08-06 11:22:35 -07:00
[](https://www.npmjs.com/package/marked)
2020-04-01 00:53:50 -05:00
[](https://github.com/markedjs/marked/actions)
2019-02-18 08:57:18 -05:00
[](https://snyk.io/test/npm/marked)
2018-04-15 18:29:57 -04:00
2018-04-05 17:15:11 -04:00
- ⚡ built for speed
2018-04-06 16:12:17 -04:00
- ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time
2018-04-05 17:15:11 -04:00
- ⚖️ light-weight while implementing all markdown features from the supported flavors & specifications
2018-04-06 16:12:17 -04:00
- 🌐 works in a browser, on a server, or from a command line interface (CLI)
2018-02-25 14:18:59 -05:00
2018-03-25 20:46:27 -04:00
## Demo
2018-03-27 15:44:02 +03:00
Checkout the [demo page ](https://marked.js.org/demo/ ) to see marked in action ⛹️
2018-03-25 20:46:27 -04:00
2018-04-05 17:15:11 -04:00
## Docs
2018-03-25 20:46:27 -04:00
Our [documentation pages ](https://marked.js.org ) are also rendered using marked 💯
2018-07-18 00:47:31 +03:00
Also read about:
2023-10-17 08:18:16 +03:30
* [Options ](https://marked.js.org/using_advanced )
* [Extensibility ](https://marked.js.org/using_pro )
2018-07-18 00:47:31 +03:00
2021-08-16 15:19:44 +01:00
## Compatibility
**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.
**Browser:** Not IE11 :)
2018-03-11 17:32:23 -04:00
## Installation
2013-06-28 11:54:34 -07:00
2023-11-28 08:12:06 -07:00
**CLI:**
2016-07-08 16:04:04 -03:00
2023-11-28 08:12:06 -07:00
```sh
2022-06-01 08:30:51 +05:30
npm install -g marked
```
2023-11-28 08:12:06 -07:00
**In-browser:**
2022-06-01 08:30:51 +05:30
```sh
npm install marked
```
2016-07-08 16:04:04 -03:00
2018-06-24 01:56:52 -05:00
## Usage
2023-10-17 08:18:16 +03:30
### Warning: 🚨 Marked does not [sanitize](https://marked.js.org/using_advanced#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! 🚨
2013-06-28 11:54:34 -07:00
2022-05-07 18:37:21 +02:00
```
DOMPurify.sanitize(marked.parse(`<img src="x" onerror="alert('not happening')">` ));
```
2013-06-28 11:54:34 -07:00
2022-05-07 18:37:21 +02:00
**CLI**
2021-11-24 22:19:58 +01:00
2018-02-25 15:17:16 -05:00
``` bash
2021-11-24 22:19:58 +01:00
# Example with stdin input
2018-02-25 15:17:16 -05:00
$ marked -o hello.html
hello world
^D
$ cat hello.html
< p > hello world< / p >
2013-06-28 11:54:34 -07:00
```
2021-11-24 22:19:58 +01:00
```bash
# Print all options
$ marked --help
```
2018-02-25 15:17:16 -05:00
**Browser**
2014-05-06 15:48:15 +02:00
```html
<!doctype html>
< html >
< head >
< meta charset = "utf-8" / >
< title > Marked in the browser< / title >
< / head >
< body >
< div id = "content" > < / div >
2018-03-25 20:36:41 -04:00
< script src = "https://cdn.jsdelivr.net/npm/marked/marked.min.js" > < / script >
2014-05-06 15:48:15 +02:00
< script >
document.getElementById('content').innerHTML =
2021-11-02 07:32:17 -07:00
marked.parse('# Marked in the browser\n\nRendered by **marked** .');
2014-05-06 15:48:15 +02:00
< / script >
< / body >
< / html >
```
2023-11-28 08:12:06 -07:00
or import esm module
```html
< script type = "module" >
import { marked } from "https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js";
document.getElementById('content').innerHTML =
marked.parse('# Marked in the browser\n\nRendered by **marked** .');
< / script >
```
2014-05-06 15:48:15 +02:00
2018-03-11 17:32:23 -04:00
## License
2012-01-03 00:35:47 -06:00
2022-01-14 21:35:30 +05:30
Copyright (c) 2011-2022, Christopher Jeffrey. (MIT License)