2011-07-24 08:15:35 -05:00
|
|
|
# marked
|
|
|
|
|
2011-08-14 03:34:10 -05:00
|
|
|
A full-featured markdown parser and compiler implemented in ~430 lines of JS.
|
2011-07-24 08:15:35 -05:00
|
|
|
Built for speed.
|
|
|
|
|
|
|
|
## Benchmarks
|
|
|
|
|
2011-08-10 21:52:54 -05:00
|
|
|
``` bash
|
|
|
|
$ node test/bench
|
|
|
|
marked: 6260ms
|
|
|
|
showdown: 21665ms
|
|
|
|
markdownjs: 69168ms
|
|
|
|
```
|
2011-07-24 08:15:35 -05:00
|
|
|
|
|
|
|
The point of marked was to create a markdown compiler where it was possible to
|
|
|
|
frequently parse huge chunks of markdown without having to worry about
|
|
|
|
caching the compiled output somehow...or blocking for an unnecesarily long time.
|
|
|
|
|
2011-08-14 03:34:10 -05:00
|
|
|
marked lingers around 430 (may vary) lines long and still implements all
|
|
|
|
markdown features. It is also now fully compatible with the client-side.
|
2011-07-24 08:15:35 -05:00
|
|
|
|
|
|
|
## Install
|
|
|
|
|
2011-08-10 21:50:25 -05:00
|
|
|
``` bash
|
|
|
|
$ npm install marked
|
|
|
|
```
|
2011-07-24 08:15:35 -05:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2011-08-10 21:50:25 -05:00
|
|
|
``` js
|
|
|
|
var marked = require('marked');
|
|
|
|
console.log(marked('i am using __markdown__.'));
|
|
|
|
```
|
2011-07-24 08:15:35 -05:00
|
|
|
|
|
|
|
You also have direct access to the lexer and parser if you so desire.
|
|
|
|
|
2011-08-10 21:50:25 -05:00
|
|
|
``` js
|
|
|
|
var tokens = marked.lexer(str);
|
|
|
|
console.log(marked.parser(tokens));
|
|
|
|
```
|
2011-07-24 08:15:35 -05:00
|
|
|
|
|
|
|
## Todo (& notes to self)
|
|
|
|
|
|
|
|
This parser was written in one night, so there's still a lot on the todo list.
|
|
|
|
There may also be some bugs.
|
|
|
|
|
|
|
|
- Implement GFM features.
|
|
|
|
- Possibly add some
|
|
|
|
[ReMarkable](http://camendesign.com/code/remarkable/documentation.html)
|
|
|
|
features while remaining backwardly compatible with all markdown syntax.
|
2011-08-15 21:14:51 -05:00
|
|
|
- Optimize the parser so it accepts a stream of tokens from the lexer. This
|
|
|
|
should enhance performance even further, although, no lookaheads would
|
|
|
|
be possible.
|
2011-07-24 08:15:35 -05:00
|
|
|
- Add an explicit pretty printing and minification feature.
|
|
|
|
|
2011-08-10 21:50:25 -05:00
|
|
|
I've still just begun to write this. I expect I will be updating it frequently.
|