mirror of https://github.com/lukechilds/node.git
Browse Source
Update module marked. Customize renderer to remove id from heading. PR-URL: https://github.com/nodejs/node/pull/6396 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Anna Henningsen <anna@addaleax.net>process-exit-stdio-flushing
Daniel Wang
9 years ago
committed by
Anna Henningsen
18 changed files with 2052 additions and 438 deletions
@ -0,0 +1,5 @@ |
|||
language: node_js |
|||
node_js: |
|||
- "0.10" |
|||
- "0.8" |
|||
- "0.6" |
@ -0,0 +1,22 @@ |
|||
var gulp = require('gulp'); |
|||
var uglify = require('gulp-uglify'); |
|||
var concat = require('gulp-concat'); |
|||
|
|||
var preserveFirstComment = function() { |
|||
var set = false; |
|||
|
|||
return function() { |
|||
if (set) return false; |
|||
set = true; |
|||
return true; |
|||
}; |
|||
}; |
|||
|
|||
gulp.task('uglify', function() { |
|||
gulp.src('lib/marked.js') |
|||
.pipe(uglify({preserveComments: preserveFirstComment()})) |
|||
.pipe(concat('marked.min.js')) |
|||
.pipe(gulp.dest('.')); |
|||
}); |
|||
|
|||
gulp.task('default', ['uglify']); |
@ -1,9 +1,12 @@ |
|||
all: |
|||
@cp lib/marked.js marked.js |
|||
@uglifyjs -o marked.min.js marked.js |
|||
@uglifyjs --comments '/\*[^\0]+?Copyright[^\0]+?\*/' -o marked.min.js lib/marked.js |
|||
|
|||
clean: |
|||
@rm marked.js |
|||
@rm marked.min.js |
|||
|
|||
bench: |
|||
@node test --bench |
|||
|
|||
.PHONY: clean all |
|||
|
@ -0,0 +1,24 @@ |
|||
{ |
|||
"name": "marked", |
|||
"version": "0.3.4", |
|||
"homepage": "https://github.com/chjj/marked", |
|||
"authors": [ |
|||
"Christopher Jeffrey <chjjeffrey@gmail.com>" |
|||
], |
|||
"description": "A markdown parser built for speed", |
|||
"keywords": [ |
|||
"markdown", |
|||
"markup", |
|||
"html" |
|||
], |
|||
"main": "lib/marked.js", |
|||
"license": "MIT", |
|||
"ignore": [ |
|||
"**/.*", |
|||
"node_modules", |
|||
"bower_components", |
|||
"app/bower_components", |
|||
"test", |
|||
"tests" |
|||
] |
|||
} |
@ -0,0 +1,10 @@ |
|||
{ |
|||
"name": "marked", |
|||
"version": "0.3.4", |
|||
"repo": "chjj/marked", |
|||
"description": "A markdown parser built for speed", |
|||
"keywords": ["markdown", "markup", "html"], |
|||
"scripts": ["lib/marked.js"], |
|||
"main": "lib/marked.js", |
|||
"license": "MIT" |
|||
} |
@ -0,0 +1,426 @@ |
|||
# Markdown is broken |
|||
|
|||
I have a lot of scraps of markdown engine oddities that I've collected over the |
|||
years. What you see below is slightly messy, but it's what I've managed to |
|||
cobble together to illustrate the differences between markdown engines, and |
|||
why, if there ever is a markdown specification, it has to be absolutely |
|||
thorough. There are a lot more of these little differences I have documented |
|||
elsewhere. I know I will find them lingering on my disk one day, but until |
|||
then, I'll continue to add whatever strange nonsensical things I find. |
|||
|
|||
Some of these examples may only mention a particular engine compared to marked. |
|||
However, the examples with markdown.pl could easily be swapped out for |
|||
discount, upskirt, or markdown.js, and you would very easily see even more |
|||
inconsistencies. |
|||
|
|||
A lot of this was written when I was very unsatisfied with the inconsistencies |
|||
between markdown engines. Please excuse the frustration noticeable in my |
|||
writing. |
|||
|
|||
## Examples of markdown's "stupid" list parsing |
|||
|
|||
``` |
|||
$ markdown.pl |
|||
|
|||
* item1 |
|||
|
|||
* item2 |
|||
|
|||
text |
|||
^D |
|||
<ul> |
|||
<li><p>item1</p> |
|||
|
|||
<ul> |
|||
<li>item2</li> |
|||
</ul> |
|||
|
|||
<p><p>text</p></li> |
|||
</ul></p> |
|||
``` |
|||
|
|||
|
|||
``` |
|||
$ marked |
|||
* item1 |
|||
|
|||
* item2 |
|||
|
|||
text |
|||
^D |
|||
<ul> |
|||
<li><p>item1</p> |
|||
<ul> |
|||
<li>item2</li> |
|||
</ul> |
|||
<p>text</p> |
|||
</li> |
|||
</ul> |
|||
``` |
|||
|
|||
Which looks correct to you? |
|||
|
|||
- - - |
|||
|
|||
``` |
|||
$ markdown.pl |
|||
* hello |
|||
> world |
|||
^D |
|||
<p><ul> |
|||
<li>hello</p> |
|||
|
|||
<blockquote> |
|||
<p>world</li> |
|||
</ul></p> |
|||
</blockquote> |
|||
``` |
|||
|
|||
``` |
|||
$ marked |
|||
* hello |
|||
> world |
|||
^D |
|||
<ul> |
|||
<li>hello<blockquote> |
|||
<p>world</p> |
|||
</blockquote> |
|||
</li> |
|||
</ul> |
|||
``` |
|||
|
|||
Again, which looks correct to you? |
|||
|
|||
- - - |
|||
|
|||
EXAMPLE: |
|||
|
|||
``` |
|||
$ markdown.pl |
|||
* hello |
|||
* world |
|||
* hi |
|||
code |
|||
^D |
|||
<ul> |
|||
<li>hello |
|||
<ul> |
|||
<li>world</li> |
|||
<li>hi |
|||
code</li> |
|||
</ul></li> |
|||
</ul> |
|||
``` |
|||
|
|||
The code isn't a code block even though it's after the bullet margin. I know, |
|||
lets give it two more spaces, effectively making it 8 spaces past the bullet. |
|||
|
|||
``` |
|||
$ markdown.pl |
|||
* hello |
|||
* world |
|||
* hi |
|||
code |
|||
^D |
|||
<ul> |
|||
<li>hello |
|||
<ul> |
|||
<li>world</li> |
|||
<li>hi |
|||
code</li> |
|||
</ul></li> |
|||
</ul> |
|||
``` |
|||
|
|||
And, it's still not a code block. Did you also notice that the 3rd item isn't |
|||
even its own list? Markdown screws that up too because of its indentation |
|||
unaware parsing. |
|||
|
|||
- - - |
|||
|
|||
Let's look at some more examples of markdown's list parsing: |
|||
|
|||
``` |
|||
$ markdown.pl |
|||
|
|||
* item1 |
|||
|
|||
* item2 |
|||
|
|||
text |
|||
^D |
|||
<ul> |
|||
<li><p>item1</p> |
|||
|
|||
<ul> |
|||
<li>item2</li> |
|||
</ul> |
|||
|
|||
<p><p>text</p></li> |
|||
</ul></p> |
|||
``` |
|||
|
|||
Misnested tags. |
|||
|
|||
|
|||
``` |
|||
$ marked |
|||
* item1 |
|||
|
|||
* item2 |
|||
|
|||
text |
|||
^D |
|||
<ul> |
|||
<li><p>item1</p> |
|||
<ul> |
|||
<li>item2</li> |
|||
</ul> |
|||
<p>text</p> |
|||
</li> |
|||
</ul> |
|||
``` |
|||
|
|||
Which looks correct to you? |
|||
|
|||
- - - |
|||
|
|||
``` |
|||
$ markdown.pl |
|||
* hello |
|||
> world |
|||
^D |
|||
<p><ul> |
|||
<li>hello</p> |
|||
|
|||
<blockquote> |
|||
<p>world</li> |
|||
</ul></p> |
|||
</blockquote> |
|||
``` |
|||
|
|||
More misnested tags. |
|||
|
|||
|
|||
``` |
|||
$ marked |
|||
* hello |
|||
> world |
|||
^D |
|||
<ul> |
|||
<li>hello<blockquote> |
|||
<p>world</p> |
|||
</blockquote> |
|||
</li> |
|||
</ul> |
|||
``` |
|||
|
|||
Again, which looks correct to you? |
|||
|
|||
- - - |
|||
|
|||
# Why quality matters - Part 2 |
|||
|
|||
``` bash |
|||
$ markdown.pl |
|||
* hello |
|||
> world |
|||
^D |
|||
<p><ul> |
|||
<li>hello</p> |
|||
|
|||
<blockquote> |
|||
<p>world</li> |
|||
</ul></p> |
|||
</blockquote> |
|||
``` |
|||
|
|||
``` bash |
|||
$ sundown # upskirt |
|||
* hello |
|||
> world |
|||
^D |
|||
<ul> |
|||
<li>hello |
|||
> world</li> |
|||
</ul> |
|||
``` |
|||
|
|||
``` bash |
|||
$ marked |
|||
* hello |
|||
> world |
|||
^D |
|||
<ul><li>hello <blockquote><p>world</p></blockquote></li></ul> |
|||
``` |
|||
|
|||
Which looks correct to you? |
|||
|
|||
- - - |
|||
|
|||
See: https://github.com/evilstreak/markdown-js/issues/23 |
|||
|
|||
``` bash |
|||
$ markdown.pl # upskirt/markdown.js/discount |
|||
* hello |
|||
var a = 1; |
|||
* world |
|||
^D |
|||
<ul> |
|||
<li>hello |
|||
var a = 1;</li> |
|||
<li>world</li> |
|||
</ul> |
|||
``` |
|||
|
|||
``` bash |
|||
$ marked |
|||
* hello |
|||
var a = 1; |
|||
* world |
|||
^D |
|||
<ul><li>hello |
|||
<pre>code>var a = 1;</code></pre></li> |
|||
<li>world</li></ul> |
|||
``` |
|||
|
|||
Which looks more reasonable? Why shouldn't code blocks be able to appear in |
|||
list items in a sane way? |
|||
|
|||
- - - |
|||
|
|||
``` bash |
|||
$ markdown.js |
|||
<div>hello</div> |
|||
|
|||
<span>hello</span> |
|||
^D |
|||
<p><div>hello</div></p> |
|||
|
|||
<p><span>hello</span></p> |
|||
``` |
|||
|
|||
``` bash |
|||
$ marked |
|||
<div>hello</div> |
|||
|
|||
<span>hello</span> |
|||
^D |
|||
<div>hello</div> |
|||
|
|||
|
|||
<p><span>hello</span> |
|||
</p> |
|||
``` |
|||
|
|||
- - - |
|||
|
|||
See: https://github.com/evilstreak/markdown-js/issues/27 |
|||
|
|||
``` bash |
|||
$ markdown.js |
|||
[![an image](/image)](/link) |
|||
^D |
|||
<p><a href="/image)](/link">![an image</a></p> |
|||
``` |
|||
|
|||
``` bash |
|||
$ marked |
|||
[![an image](/image)](/link) |
|||
^D |
|||
<p><a href="/link"><img src="/image" alt="an image"></a> |
|||
</p> |
|||
``` |
|||
|
|||
- - - |
|||
|
|||
See: https://github.com/evilstreak/markdown-js/issues/24 |
|||
|
|||
``` bash |
|||
$ markdown.js |
|||
> a |
|||
|
|||
> b |
|||
|
|||
> c |
|||
^D |
|||
<blockquote><p>a</p><p>bundefined> c</p></blockquote> |
|||
``` |
|||
|
|||
``` bash |
|||
$ marked |
|||
> a |
|||
|
|||
> b |
|||
|
|||
> c |
|||
^D |
|||
<blockquote><p>a |
|||
|
|||
</p></blockquote> |
|||
<blockquote><p>b |
|||
|
|||
</p></blockquote> |
|||
<blockquote><p>c |
|||
</p></blockquote> |
|||
``` |
|||
|
|||
- - - |
|||
|
|||
``` bash |
|||
$ markdown.pl |
|||
* hello |
|||
* world |
|||
how |
|||
|
|||
are |
|||
you |
|||
|
|||
* today |
|||
* hi |
|||
^D |
|||
<ul> |
|||
<li><p>hello</p> |
|||
|
|||
<ul> |
|||
<li>world |
|||
how</li> |
|||
</ul> |
|||
|
|||
<p>are |
|||
you</p> |
|||
|
|||
<ul> |
|||
<li>today</li> |
|||
</ul></li> |
|||
<li>hi</li> |
|||
</ul> |
|||
``` |
|||
|
|||
``` bash |
|||
$ marked |
|||
* hello |
|||
* world |
|||
how |
|||
|
|||
are |
|||
you |
|||
|
|||
* today |
|||
* hi |
|||
^D |
|||
<ul> |
|||
<li><p>hello</p> |
|||
<ul> |
|||
<li><p>world |
|||
how</p> |
|||
<p>are |
|||
you</p> |
|||
</li> |
|||
<li><p>today</p> |
|||
</li> |
|||
</ul> |
|||
</li> |
|||
<li>hi</li> |
|||
</ul> |
|||
``` |
@ -0,0 +1,2 @@ |
|||
# Todo |
|||
|
File diff suppressed because it is too large
@ -1,39 +1,91 @@ |
|||
.ds q \N'34' |
|||
.TH marked 1 |
|||
.TH marked 1 "2014-01-31" "v0.3.1" "marked.js" |
|||
|
|||
.SH NAME |
|||
marked \- a javascript markdown parser |
|||
|
|||
.SH SYNOPSIS |
|||
.nf |
|||
.B marked [\-o output] [\-i input] [\-th] |
|||
.fi |
|||
.B marked |
|||
[\-o \fI<output>\fP] [\-i \fI<input>\fP] [\-\-help] |
|||
[\-\-tokens] [\-\-pedantic] [\-\-gfm] |
|||
[\-\-breaks] [\-\-tables] [\-\-sanitize] |
|||
[\-\-smart\-lists] [\-\-lang\-prefix \fI<prefix>\fP] |
|||
[\-\-no\-etc...] [\-\-silent] [\fIfilename\fP] |
|||
|
|||
.SH DESCRIPTION |
|||
.B marked |
|||
is a full-featured javascript markdown parser, built for speed. It also includes |
|||
multiple GFM features. |
|||
|
|||
.SH EXAMPLES |
|||
.TP |
|||
cat in.md | marked > out.html |
|||
.TP |
|||
echo "hello *world*" | marked |
|||
.TP |
|||
marked \-o out.html in.md \-\-gfm |
|||
.TP |
|||
marked \-\-output="hello world.html" \-i in.md \-\-no-breaks |
|||
|
|||
.SH OPTIONS |
|||
.TP |
|||
.BI \-o,\ \-\-output\ [output] |
|||
.BI \-o,\ \-\-output\ [\fIoutput\fP] |
|||
Specify file output. If none is specified, write to stdout. |
|||
.TP |
|||
.BI \-i,\ \-\-input\ [input] |
|||
.BI \-i,\ \-\-input\ [\fIinput\fP] |
|||
Specify file input, otherwise use last argument as input file. If no input file |
|||
is specified, read from stdin. |
|||
.TP |
|||
.BI \-t,\ \-\-tokens |
|||
Output a token stream instead of html. |
|||
.TP |
|||
.BI \-h,\ \-\-help |
|||
Display help information. |
|||
.SH EXAMPLES |
|||
.BI \-\-pedantic |
|||
Conform to obscure parts of markdown.pl as much as possible. Don't fix original |
|||
markdown bugs. |
|||
.TP |
|||
cat in.md | marked > out.html |
|||
.BI \-\-gfm |
|||
Enable github flavored markdown. |
|||
.TP |
|||
echo "hello *world*" | marked |
|||
.BI \-\-breaks |
|||
Enable GFM line breaks. Only works with the gfm option. |
|||
.TP |
|||
.BI \-\-tables |
|||
Enable GFM tables. Only works with the gfm option. |
|||
.TP |
|||
.BI \-\-sanitize |
|||
Sanitize output. Ignore any HTML input. |
|||
.TP |
|||
.BI \-\-smart\-lists |
|||
Use smarter list behavior than the original markdown. |
|||
.TP |
|||
marked -o out.html in.md |
|||
.BI \-\-lang\-prefix\ [\fIprefix\fP] |
|||
Set the prefix for code block classes. |
|||
.TP |
|||
marked --output="hello world.html" -i in.md |
|||
.BI \-\-mangle |
|||
Mangle email addresses. |
|||
.TP |
|||
.BI \-\-no\-sanitize,\ \-no-etc... |
|||
The inverse of any of the marked options above. |
|||
.TP |
|||
.BI \-\-silent |
|||
Silence error output. |
|||
.TP |
|||
.BI \-h,\ \-\-help |
|||
Display help information. |
|||
|
|||
.SH CONFIGURATION |
|||
For configuring and running programmatically. |
|||
|
|||
.B Example |
|||
|
|||
require('marked')('*foo*', { gfm: true }); |
|||
|
|||
.SH BUGS |
|||
Please report any bugs to https://github.com/chjj/marked. |
|||
|
|||
.SH LICENSE |
|||
Copyright (c) 2011-2012, Christopher Jeffrey (MIT License) |
|||
Copyright (c) 2011-2014, Christopher Jeffrey (MIT License). |
|||
|
|||
.SH "SEE ALSO" |
|||
.BR markdown(1), |
|||
.BR node.js(1) |
|||
|
File diff suppressed because one or more lines are too long
@ -1,15 +1,95 @@ |
|||
{ |
|||
"name": "marked", |
|||
"_args": [ |
|||
[ |
|||
"marked", |
|||
"/Users/firedfox/git/node/tools/doc" |
|||
] |
|||
], |
|||
"_from": "marked@latest", |
|||
"_id": "marked@0.3.5", |
|||
"_inCache": true, |
|||
"_installable": true, |
|||
"_location": "/marked", |
|||
"_nodeVersion": "0.12.7", |
|||
"_npmUser": { |
|||
"email": "chjjeffrey@gmail.com", |
|||
"name": "chjj" |
|||
}, |
|||
"_npmVersion": "2.13.2", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"name": "marked", |
|||
"raw": "marked", |
|||
"rawSpec": "", |
|||
"scope": null, |
|||
"spec": "latest", |
|||
"type": "tag" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/marked/-/marked-0.3.5.tgz", |
|||
"_shasum": "4113a15ac5d7bca158a5aae07224587b9fa15b94", |
|||
"_shrinkwrap": null, |
|||
"_spec": "marked", |
|||
"_where": "/Users/firedfox/git/node/tools/doc", |
|||
"author": { |
|||
"name": "Christopher Jeffrey" |
|||
}, |
|||
"bin": { |
|||
"marked": "./bin/marked" |
|||
}, |
|||
"bugs": { |
|||
"url": "http://github.com/chjj/marked/issues" |
|||
}, |
|||
"dependencies": {}, |
|||
"description": "A markdown parser built for speed", |
|||
"author": "Christopher Jeffrey", |
|||
"version": "0.1.9", |
|||
"main": "./lib/marked.js", |
|||
"bin": "./bin/marked", |
|||
"man": "./man/marked.1", |
|||
"preferGlobal": false, |
|||
"repository": "git://github.com/chjj/marked.git", |
|||
"devDependencies": { |
|||
"gulp": "^3.8.11", |
|||
"gulp-concat": "^2.5.2", |
|||
"gulp-uglify": "^1.1.0", |
|||
"markdown": "*", |
|||
"showdown": "*" |
|||
}, |
|||
"directories": {}, |
|||
"dist": { |
|||
"shasum": "4113a15ac5d7bca158a5aae07224587b9fa15b94", |
|||
"tarball": "https://registry.npmjs.org/marked/-/marked-0.3.5.tgz" |
|||
}, |
|||
"gitHead": "88ce4df47c4d994dc1b1df1477a21fb893e11ddc", |
|||
"homepage": "https://github.com/chjj/marked", |
|||
"bugs": "http://github.com/chjj/marked/issues", |
|||
"keywords": [ "markdown", "markup", "html" ], |
|||
"tags": [ "markdown", "markup", "html" ] |
|||
"keywords": [ |
|||
"markdown", |
|||
"markup", |
|||
"html" |
|||
], |
|||
"license": "MIT", |
|||
"main": "./lib/marked.js", |
|||
"maintainers": [ |
|||
{ |
|||
"email": "chjjeffrey@gmail.com", |
|||
"name": "chjj" |
|||
} |
|||
], |
|||
"man": [ |
|||
"./man/marked.1" |
|||
], |
|||
"name": "marked", |
|||
"optionalDependencies": {}, |
|||
"preferGlobal": true, |
|||
"readme": "ERROR: No README data found!", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git://github.com/chjj/marked.git" |
|||
}, |
|||
"scripts": { |
|||
"bench": "node test --bench", |
|||
"test": "node test" |
|||
}, |
|||
"tags": [ |
|||
"markdown", |
|||
"markup", |
|||
"html" |
|||
], |
|||
"version": "0.3.5" |
|||
} |
|||
|
Loading…
Reference in new issue