1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

edit ditto.js

This commit is contained in:
ruanyf 2014-04-29 10:49:31 +08:00
parent 9aaebf5aa7
commit cebaf81bcf
243 changed files with 0 additions and 15713 deletions

View File

@ -1 +0,0 @@
es6.ruanyifeng.com

View File

@ -1,22 +0,0 @@
# Creative Commons Attribution-NonCommercial 4.0 International License
Disclaimer: This is a human-readable summary of (and not a substitute for) the [license](http://creativecommons.org/licenses/by-nc/4.0/legalcode).
You are free to:
- Share — copy and redistribute the material in any medium or format
- Adapt — remix, transform, and build upon the material
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
- Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- NonCommercial — You may not use the material for commercial purposes.
- No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
Notices:
You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation.
No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.

View File

@ -1,17 +0,0 @@
# ECMAScript 6入门
《ECMAScript 6入门》是一本开源的JavaScript语言教程全面介绍ECMAScript 6新增的语法特性。
[![cover](images/cover_thumbnail.jpg)](images/cover.jpg)
本书力争覆盖ES6与ES5的所有不同之处对涉及的语法知识给予详细介绍并给出大量简洁易懂的示例代码。
本书为中级难度适合已有一定JavaScript语言基础的读者了解这门语言的最新进展也可当作参考手册查寻新增的语法点。
### 版权许可
本书采用“保持署名—非商用”创意共享4.0许可证。
只要保持原作者署名和非商用,您可以自由地阅读、分享、修改本书。
详细的法律条文请参见[创意共享](http://creativecommons.org/licenses/by-nc/4.0/)网站。

View File

@ -1,19 +0,0 @@
Copyright (c) 2011-2014, Christopher Jeffrey (https://github.com/chjj/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,12 +0,0 @@
all:
@cp lib/marked.js marked.js
@uglifyjs -o marked.min.js marked.js
clean:
@rm marked.js
@rm marked.min.js
bench:
@node test --bench
.PHONY: clean all

View File

@ -1,386 +0,0 @@
# marked
> A full-featured markdown parser and compiler, written in JavaScript. Built
> for speed.
[![NPM version](https://badge.fury.io/js/marked.png)][badge]
## Install
``` bash
npm install marked --save
```
## Usage
Minimal usage:
```js
var marked = require('marked');
console.log(marked('I am using __markdown__.'));
// Outputs: <p>I am using <strong>markdown</strong>.</p>
```
Example setting options with default values:
```js
var marked = require('marked');
marked.setOptions({
renderer: new marked.Renderer(),
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false
});
console.log(marked('I am using __markdown__.'));
```
## marked(markdownString [,options] [,callback])
### markdownString
Type: `string`
String of markdown source to be compiled.
### options
Type: `object`
Hash of options. Can also be set using the `marked.setOptions` method as seen
above.
### callback
Type: `function`
Function called when the `markdownString` has been fully parsed when using
async highlighting. If the `options` argument is omitted, this can be used as
the second argument.
## Options
### highlight
Type: `function`
A function to highlight code blocks. The first example below uses async highlighting with
[node-pygmentize-bundled][pygmentize], and the second is a synchronous example using
[highlight.js][highlight]:
```js
var marked = require('marked');
var markdownString = '```js\n console.log("hello"); \n```';
// Async highlighting with pygmentize-bundled
marked.setOptions({
highlight: function (code, lang, callback) {
require('pygmentize-bundled')({ lang: lang, format: 'html' }, code, function (err, result) {
callback(err, result.toString());
});
}
});
// Using async version of marked
marked(markdownString, function (err, content) {
if (err) throw err;
console.log(content);
});
// Synchronous highlighting with highlight.js
marked.setOptions({
highlight: function (code) {
return require('highlight.js').highlightAuto(code).value;
}
});
console.log(marked(markdownString));
```
#### highlight arguments
`code`
Type: `string`
The section of code to pass to the highlighter.
`lang`
Type: `string`
The programming language specified in the code block.
`callback`
Type: `function`
The callback function to call when using an async highlighter.
### renderer
Type: `object`
Default: `new Renderer()`
An object containing functions to render tokens to HTML.
#### Overriding renderer methods
The renderer option allows you to render tokens in a custom manor. Here is an
example of overriding the default heading token rendering by adding an embedded anchor tag like on GitHub:
```javascript
var marked = require('marked');
var renderer = new marked.Renderer();
renderer.heading = function (text, level) {
var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
return '<h' + level + '><a name="' +
escapedText +
'" class="anchor" href="#' +
escapedText +
'"><span class="header-link"></span></a>' +
text + '</h' + level + '>';
},
console.log(marked('# heading+', { renderer: renderer }));
```
This code will output the following HTML:
```html
<h1>
<a name="heading-" class="anchor" href="#heading-">
<span class="header-link"></span>
</a>
heading+
</h1>
```
#### Block level renderer methods
- code(*string* code, *string* language)
- blockquote(*string* quote)
- html(*string* html)
- heading(*string* text, *number* level)
- hr()
- list(*string* body, *boolean* ordered)
- listitem(*string* text)
- paragraph(*string* text)
- table(*string* header, *string* body)
- tablerow(*string* content)
- tablecell(*string* content, *object* flags)
`flags` has the following properties:
```js
{
header: true || false,
align: 'center' || 'left' || 'right'
}
```
#### Inline level renderer methods
- strong(*string* text)
- em(*string* text)
- codespan(*string* code)
- br()
- del(*string* text)
- link(*string* href, *string* title, *string* text)
- image(*string* href, *string* title, *string* text)
### gfm
Type: `boolean`
Default: `true`
Enable [GitHub flavored markdown][gfm].
### tables
Type: `boolean`
Default: `true`
Enable GFM [tables][tables].
This option requires the `gfm` option to be true.
### breaks
Type: `boolean`
Default: `false`
Enable GFM [line breaks][breaks].
This option requires the `gfm` option to be true.
### pedantic
Type: `boolean`
Default: `false`
Conform to obscure parts of `markdown.pl` as much as possible. Don't fix any of
the original markdown bugs or poor behavior.
### sanitize
Type: `boolean`
Default: `false`
Sanitize the output. Ignore any HTML that has been input.
### smartLists
Type: `boolean`
Default: `true`
Use smarter list behavior than the original markdown. May eventually be
default with the old behavior moved into `pedantic`.
### smartypants
Type: `boolean`
Default: `false`
Use "smart" typograhic punctuation for things like quotes and dashes.
## Access to lexer and parser
You also have direct access to the lexer and parser if you so desire.
``` js
var tokens = marked.lexer(text, options);
console.log(marked.parser(tokens));
```
``` js
var lexer = new marked.Lexer(options);
var tokens = lexer.lex(text);
console.log(tokens);
console.log(lexer.rules);
```
## CLI
``` bash
$ marked -o hello.html
hello world
^D
$ cat hello.html
<p>hello world</p>
```
## Philosophy behind marked
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.
marked is very concise and still implements all markdown features. It is also
now fully compatible with the client-side.
marked more or less passes the official markdown test suite in its
entirety. This is important because a surprising number of markdown compilers
cannot pass more than a few tests. It was very difficult to get marked as
compliant as it is. It could have cut corners in several areas for the sake
of performance, but did not in order to be exactly what you expect in terms
of a markdown rendering. In fact, this is why marked could be considered at a
disadvantage in the benchmarks above.
Along with implementing every markdown feature, marked also implements [GFM
features][gfmf].
## Benchmarks
node v0.8.x
``` bash
$ node test --bench
marked completed in 3411ms.
marked (gfm) completed in 3727ms.
marked (pedantic) completed in 3201ms.
robotskirt completed in 808ms.
showdown (reuse converter) completed in 11954ms.
showdown (new converter) completed in 17774ms.
markdown-js completed in 17191ms.
```
__Marked is now faster than Discount, which is written in C.__
For those feeling skeptical: These benchmarks run the entire markdown test suite 1000 times. The test suite tests every feature. It doesn't cater to specific aspects.
### Pro level
You also have direct access to the lexer and parser if you so desire.
``` js
var tokens = marked.lexer(text, options);
console.log(marked.parser(tokens));
```
``` js
var lexer = new marked.Lexer(options);
var tokens = lexer.lex(text);
console.log(tokens);
console.log(lexer.rules);
```
``` bash
$ node
> require('marked').lexer('> i am using marked.')
[ { type: 'blockquote_start' },
{ type: 'paragraph',
text: 'i am using marked.' },
{ type: 'blockquote_end' },
links: {} ]
```
## Running Tests & Contributing
If you want to submit a pull request, make sure your changes pass the test
suite. If you're adding a new feature, be sure to add your own test.
The marked test suite is set up slightly strangely: `test/new` is for all tests
that are not part of the original markdown.pl test suite (this is where your
test should go if you make one). `test/original` is only for the original
markdown.pl tests. `test/tests` houses both types of tests after they have been
combined and moved/generated by running `node test --fix` or `marked --test
--fix`.
In other words, if you have a test to add, add it to `test/new/` and then
regenerate the tests with `node test --fix`. Commit the result. If your test
uses a certain feature, for example, maybe it assumes GFM is *not* enabled, you
can add `.nogfm` to the filename. So, `my-test.text` becomes
`my-test.nogfm.text`. You can do this with any marked option. Say you want
line breaks and smartypants enabled, your filename should be:
`my-test.breaks.smartypants.text`.
To run the tests:
``` bash
cd marked/
node test
```
### Contribution and License Agreement
If you contribute code to this project, you are implicitly allowing your code
to be distributed under the MIT license. You are also implicitly verifying that
all code is your original work. `</legalese>`
## License
Copyright (c) 2011-2014, Christopher Jeffrey. (MIT License)
See LICENSE for more info.
[gfm]: https://help.github.com/articles/github-flavored-markdown
[gfmf]: http://github.github.com/github-flavored-markdown/
[pygmentize]: https://github.com/rvagg/node-pygmentize-bundled
[highlight]: https://github.com/isagalaev/highlight.js
[badge]: http://badge.fury.io/js/marked
[tables]: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#wiki-tables
[breaks]: https://help.github.com/articles/github-flavored-markdown#newlines

View File

@ -1,187 +0,0 @@
#!/usr/bin/env node
/**
* Marked CLI
* Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
*/
var fs = require('fs')
, util = require('util')
, marked = require('../');
/**
* Man Page
*/
function help() {
var spawn = require('child_process').spawn;
var options = {
cwd: process.cwd(),
env: process.env,
setsid: false,
customFds: [0, 1, 2]
};
spawn('man',
[__dirname + '/../man/marked.1'],
options);
}
/**
* Main
*/
function main(argv, callback) {
var files = []
, options = {}
, input
, output
, arg
, tokens
, opt;
function getarg() {
var arg = argv.shift();
if (arg.indexOf('--') === 0) {
// e.g. --opt
arg = arg.split('=');
if (arg.length > 1) {
// e.g. --opt=val
argv.unshift(arg.slice(1).join('='));
}
arg = arg[0];
} else if (arg[0] === '-') {
if (arg.length > 2) {
// e.g. -abc
argv = arg.substring(1).split('').map(function(ch) {
return '-' + ch;
}).concat(argv);
arg = argv.shift();
} else {
// e.g. -a
}
} else {
// e.g. foo
}
return arg;
}
while (argv.length) {
arg = getarg();
switch (arg) {
case '--test':
return require('../test').main(process.argv.slice());
case '-o':
case '--output':
output = argv.shift();
break;
case '-i':
case '--input':
input = argv.shift();
break;
case '-t':
case '--tokens':
tokens = true;
break;
case '-h':
case '--help':
return help();
default:
if (arg.indexOf('--') === 0) {
opt = camelize(arg.replace(/^--(no-)?/, ''));
if (!marked.defaults.hasOwnProperty(opt)) {
continue;
}
if (arg.indexOf('--no-') === 0) {
options[opt] = typeof marked.defaults[opt] !== 'boolean'
? null
: false;
} else {
options[opt] = typeof marked.defaults[opt] !== 'boolean'
? argv.shift()
: true;
}
} else {
files.push(arg);
}
break;
}
}
function getData(callback) {
if (!input) {
if (files.length <= 2) {
return getStdin(callback);
}
input = files.pop();
}
return fs.readFile(input, 'utf8', callback);
}
return getData(function(err, data) {
if (err) return callback(err);
data = tokens
? JSON.stringify(marked.lexer(data, options), null, 2)
: marked(data, options);
if (!output) {
process.stdout.write(data + '\n');
return callback();
}
return fs.writeFile(output, data, callback);
});
}
/**
* Helpers
*/
function getStdin(callback) {
var stdin = process.stdin
, buff = '';
stdin.setEncoding('utf8');
stdin.on('data', function(data) {
buff += data;
});
stdin.on('error', function(err) {
return callback(err);
});
stdin.on('end', function() {
return callback(null, buff);
});
try {
stdin.resume();
} catch (e) {
callback(e);
}
}
function camelize(text) {
return text.replace(/(\w)-(\w)/g, function(_, a, b) {
return a + b.toUpperCase();
});
}
/**
* Expose / Entry Point
*/
if (!module.parent) {
process.title = 'marked';
main(process.argv.slice(), function(err, code) {
if (err) throw err;
return process.exit(code || 0);
});
} else {
module.exports = main;
}

View File

@ -1,10 +0,0 @@
{
"name": "marked",
"version": "0.3.2",
"repo": "chjj/marked",
"description": "A markdown parser built for speed",
"keywords": ["markdown", "markup", "html"],
"scripts": ["lib/marked.js"],
"main": "lib/marked.js",
"license": "MIT"
}

View File

@ -1,426 +0,0 @@
# 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
&gt; 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>&lt;div&gt;hello&lt;/div&gt;</p>
<p>&lt;span&gt;hello&lt;/span&gt;</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&gt; 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>
```

View File

@ -1,2 +0,0 @@
# Todo

View File

@ -1 +0,0 @@
module.exports = require('./lib/marked');

File diff suppressed because it is too large Load Diff

View File

@ -1,88 +0,0 @@
.ds q \N'34'
.TH marked 1 "2014-01-31" "v0.3.1" "marked.js"
.SH NAME
marked \- a javascript markdown parser
.SH SYNOPSIS
.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\ [\fIoutput\fP]
Specify file output. If none is specified, write to stdout.
.TP
.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 \-\-pedantic
Conform to obscure parts of markdown.pl as much as possible. Don't fix original
markdown bugs.
.TP
.BI \-\-gfm
Enable github flavored markdown.
.TP
.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
.BI \-\-lang\-prefix\ [\fIprefix\fP]
Set the prefix for code block classes.
.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-2014, Christopher Jeffrey (MIT License).
.SH "SEE ALSO"
.BR markdown(1),
.BR node.js(1)

View File

@ -1,22 +0,0 @@
{
"name": "marked",
"description": "A markdown parser built for speed",
"author": "Christopher Jeffrey",
"version": "0.3.2",
"main": "./lib/marked.js",
"bin": "./bin/marked",
"man": "./man/marked.1",
"preferGlobal": true,
"repository": "git://github.com/chjj/marked.git",
"homepage": "https://github.com/chjj/marked",
"bugs": { "url": "http://github.com/chjj/marked/issues" },
"license": "MIT",
"keywords": ["markdown", "markup", "html"],
"tags": ["markdown", "markup", "html"],
"devDependencies": {
"markdown": "*",
"showdown": "*",
"robotskirt": "*"
},
"scripts": { "test": "node test", "bench": "node test --bench" }
}

View File

@ -1,10 +0,0 @@
In this directory:
#
# MarkdownTester -- Run tests for Markdown implementations
#
# Copyright (c) 2004-2005 John Gruber
# <http://daringfireball.net/projects/markdown/>
#
Partially modified for testing purposes.

View File

@ -1,5 +0,0 @@
<!doctype html>
<title>marked tests</title>
<p>testing...</p>
<script src="marked.js"></script>
<script src="test.js"></script>

View File

@ -1,41 +0,0 @@
var fs = require('fs');
var test = require('../')
, runTests = test.runTests
, load = test.load;
var express = require('express')
, app = express();
app.use(function(req, res, next) {
var setHeader = res.setHeader;
res.setHeader = function(name) {
switch (name) {
case 'Cache-Control':
case 'Last-Modified':
case 'ETag':
return;
}
return setHeader.apply(res, arguments);
};
next();
});
var dir = __dirname + '/../tests'
, files = {};
app.get('/test.js', function(req, res, next) {
var test = fs.readFileSync(__dirname + '/test.js', 'utf8')
, files = load();
test = test.replace('__TESTS__', JSON.stringify(files));
test = test.replace('__MAIN__', runTests + '');
res.contentType('.js');
res.send(test);
});
app.use(express.static(__dirname + '/../../lib'));
app.use(express.static(__dirname));
app.listen(8080);

View File

@ -1,62 +0,0 @@
;(function() {
var console = {}
, files = __TESTS__;
console.log = function(text) {
var args = Array.prototype.slice.call(arguments, 1)
, i = 0;
text = text.replace(/%\w/g, function() {
return args[i++] || '';
});
if (window.console) window.console.log(text);
document.body.innerHTML += '<pre>' + escape(text) + '</pre>';
};
if (!Object.keys) {
Object.keys = function(obj) {
var out = []
, key;
for (key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
out.push(key);
}
}
return out;
};
}
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback, context) {
for (var i = 0; i < this.length; i++) {
callback.call(context || null, this[i], i, obj);
}
};
}
if (!String.prototype.trim) {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
}
function load() {
return files;
}
function escape(html, encode) {
return html
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
(__MAIN__)();
}).call(this);

View File

@ -1,543 +0,0 @@
#!/usr/bin/env node
/**
* marked tests
* Copyright (c) 2011-2013, Christopher Jeffrey. (MIT Licensed)
* https://github.com/chjj/marked
*/
/**
* Modules
*/
var fs = require('fs')
, path = require('path')
, marked = require('../');
/**
* Load Tests
*/
function load() {
var dir = __dirname + '/tests'
, files = {}
, list
, file
, i
, l;
list = fs
.readdirSync(dir)
.filter(function(file) {
return path.extname(file) !== '.html';
})
.sort(function(a, b) {
a = path.basename(a).toLowerCase().charCodeAt(0);
b = path.basename(b).toLowerCase().charCodeAt(0);
return a > b ? 1 : (a < b ? -1 : 0);
});
i = 0;
l = list.length;
for (; i < l; i++) {
file = path.join(dir, list[i]);
files[path.basename(file)] = {
text: fs.readFileSync(file, 'utf8'),
html: fs.readFileSync(file.replace(/[^.]+$/, 'html'), 'utf8')
};
}
return files;
}
/**
* Test Runner
*/
function runTests(engine, options) {
if (typeof engine !== 'function') {
options = engine;
engine = null;
}
var engine = engine || marked
, options = options || {}
, files = options.files || load()
, complete = 0
, failed = 0
, failures = []
, keys = Object.keys(files)
, i = 0
, len = keys.length
, filename
, file
, flags
, text
, html
, j
, l;
if (options.marked) {
marked.setOptions(options.marked);
}
main:
for (; i < len; i++) {
filename = keys[i];
file = files[filename];
if (marked._original) {
marked.defaults = marked._original;
delete marked._original;
}
flags = filename.split('.').slice(1, -1);
if (flags.length) {
marked._original = marked.defaults;
marked.defaults = {};
Object.keys(marked._original).forEach(function(key) {
marked.defaults[key] = marked._original[key];
});
flags.forEach(function(key) {
var val = true;
if (key.indexOf('no') === 0) {
key = key.substring(2);
val = false;
}
if (marked.defaults.hasOwnProperty(key)) {
marked.defaults[key] = val;
}
});
}
try {
text = engine(file.text).replace(/\s/g, '');
html = file.html.replace(/\s/g, '');
} catch(e) {
console.log('%s failed.', filename);
throw e;
}
j = 0;
l = html.length;
for (; j < l; j++) {
if (text[j] !== html[j]) {
failed++;
failures.push(filename);
text = text.substring(
Math.max(j - 30, 0),
Math.min(j + 30, text.length));
html = html.substring(
Math.max(j - 30, 0),
Math.min(j + 30, html.length));
console.log(
'\n#%d. %s failed at offset %d. Near: "%s".\n',
i + 1, filename, j, text);
console.log('\nGot:\n%s\n', text.trim() || text);
console.log('\nExpected:\n%s\n', html.trim() || html);
if (options.stop) {
break main;
}
continue main;
}
}
complete++;
console.log('#%d. %s completed.', i + 1, filename);
}
console.log('%d/%d tests completed successfully.', complete, len);
if (failed) console.log('%d/%d tests failed.', failed, len);
// Tests currently failing.
if (~failures.indexOf('def_blocks.text')
&& ~failures.indexOf('double_link.text')
&& ~failures.indexOf('gfm_code_hr_list.text')) {
failed -= 3;
}
return !failed;
}
/**
* Benchmark a function
*/
function bench(name, func) {
var files = bench.files || load();
if (!bench.files) {
bench.files = files;
// Change certain tests to allow
// comparison to older benchmark times.
fs.readdirSync(__dirname + '/new').forEach(function(name) {
if (path.extname(name) === '.html') return;
if (name === 'main.text') return;
delete files[name];
});
files['backslash_escapes.text'] = {
text: 'hello world \\[how](are you) today'
};
files['main.text'].text = files['main.text'].text.replace('* * *\n\n', '');
}
var start = Date.now()
, times = 1000
, keys = Object.keys(files)
, i
, l = keys.length
, filename
, file;
while (times--) {
for (i = 0; i < l; i++) {
filename = keys[i];
file = files[filename];
func(file.text);
}
}
console.log('%s completed in %dms.', name, Date.now() - start);
}
/**
* Benchmark all engines
*/
function runBench(options) {
var options = options || {};
// Non-GFM, Non-pedantic
marked.setOptions({
gfm: false,
tables: false,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: false
});
if (options.marked) {
marked.setOptions(options.marked);
}
bench('marked', marked);
// GFM
marked.setOptions({
gfm: true,
tables: false,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: false
});
if (options.marked) {
marked.setOptions(options.marked);
}
bench('marked (gfm)', marked);
// Pedantic
marked.setOptions({
gfm: false,
tables: false,
breaks: false,
pedantic: true,
sanitize: false,
smartLists: false
});
if (options.marked) {
marked.setOptions(options.marked);
}
bench('marked (pedantic)', marked);
// robotskirt
try {
bench('robotskirt', (function() {
var rs = require('robotskirt');
return function(text) {
var parser = rs.Markdown.std();
return parser.render(text);
};
})());
} catch (e) {
console.log('Could not bench robotskirt.');
}
// showdown
try {
bench('showdown (reuse converter)', (function() {
var Showdown = require('showdown');
var convert = new Showdown.converter();
return function(text) {
return convert.makeHtml(text);
};
})());
bench('showdown (new converter)', (function() {
var Showdown = require('showdown');
return function(text) {
var convert = new Showdown.converter();
return convert.makeHtml(text);
};
})());
} catch (e) {
console.log('Could not bench showdown.');
}
// markdown.js
try {
bench('markdown.js', require('markdown').parse);
} catch (e) {
console.log('Could not bench markdown.js.');
}
}
/**
* A simple one-time benchmark
*/
function time(options) {
var options = options || {};
if (options.marked) {
marked.setOptions(options.marked);
}
bench('marked', marked);
}
/**
* Markdown Test Suite Fixer
* This function is responsible for "fixing"
* the markdown test suite. There are
* certain aspects of the suite that
* are strange or might make tests
* fail for reasons unrelated to
* conformance.
*/
function fix(options) {
['tests', 'original', 'new'].forEach(function(dir) {
try {
fs.mkdirSync(path.resolve(__dirname, dir), 0755);
} catch (e) {
;
}
});
// rm -rf tests
fs.readdirSync(path.resolve(__dirname, 'tests')).forEach(function(file) {
fs.unlinkSync(path.resolve(__dirname, 'tests', file));
});
// cp -r original tests
fs.readdirSync(path.resolve(__dirname, 'original')).forEach(function(file) {
var nfile = file;
if (file.indexOf('hard_wrapped_paragraphs_with_list_like_lines.') === 0) {
nfile = file.replace(/\.(text|html)$/, '.nogfm.$1');
}
fs.writeFileSync(path.resolve(__dirname, 'tests', nfile),
fs.readFileSync(path.resolve(__dirname, 'original', file)));
});
// node fix.js
var dir = __dirname + '/tests';
fs.readdirSync(dir).filter(function(file) {
return path.extname(file) === '.html';
}).forEach(function(file) {
var file = path.join(dir, file)
, html = fs.readFileSync(file, 'utf8');
// fix unencoded quotes
html = html
.replace(/='([^\n']*)'(?=[^<>\n]*>)/g, '=&__APOS__;$1&__APOS__;')
.replace(/="([^\n"]*)"(?=[^<>\n]*>)/g, '=&__QUOT__;$1&__QUOT__;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/&__QUOT__;/g, '"')
.replace(/&__APOS__;/g, '\'');
// add heading id's
html = html.replace(/<(h[1-6])>([^<]+)<\/\1>/g, function(s, h, text) {
var id = text
.replace(/&#39;/g, '\'')
.replace(/&quot;/g, '"')
.replace(/&gt;/g, '>')
.replace(/&lt;/g, '<')
.replace(/&amp;/g, '&');
id = id.toLowerCase().replace(/[^\w]+/g, '-');
return '<' + h + ' id="' + id + '">' + text + '</' + h + '>';
});
fs.writeFileSync(file, html);
});
// turn <hr /> into <hr>
fs.readdirSync(dir).forEach(function(file) {
var file = path.join(dir, file)
, text = fs.readFileSync(file, 'utf8');
text = text.replace(/(<|&lt;)hr\s*\/(>|&gt;)/g, '$1hr$2');
fs.writeFileSync(file, text);
});
// markdown does some strange things.
// it does not encode naked `>`, marked does.
(function() {
var file = dir + '/amps_and_angles_encoding.html';
var html = fs.readFileSync(file, 'utf8')
.replace('6 > 5.', '6 &gt; 5.');
fs.writeFileSync(file, html);
})();
// cp new/* tests/
fs.readdirSync(path.resolve(__dirname, 'new')).forEach(function(file) {
fs.writeFileSync(path.resolve(__dirname, 'tests', file),
fs.readFileSync(path.resolve(__dirname, 'new', file)));
});
}
/**
* Argument Parsing
*/
function parseArg(argv) {
var argv = process.argv.slice(2)
, options = {}
, orphans = []
, arg;
function getarg() {
var arg = argv.shift();
if (arg.indexOf('--') === 0) {
// e.g. --opt
arg = arg.split('=');
if (arg.length > 1) {
// e.g. --opt=val
argv.unshift(arg.slice(1).join('='));
}
arg = arg[0];
} else if (arg[0] === '-') {
if (arg.length > 2) {
// e.g. -abc
argv = arg.substring(1).split('').map(function(ch) {
return '-' + ch;
}).concat(argv);
arg = argv.shift();
} else {
// e.g. -a
}
} else {
// e.g. foo
}
return arg;
}
while (argv.length) {
arg = getarg();
switch (arg) {
case '-f':
case '--fix':
case 'fix':
options.fix = true;
break;
case '-b':
case '--bench':
options.bench = true;
break;
case '-s':
case '--stop':
options.stop = true;
break;
case '-t':
case '--time':
options.time = true;
break;
default:
if (arg.indexOf('--') === 0) {
opt = camelize(arg.replace(/^--(no-)?/, ''));
if (!marked.defaults.hasOwnProperty(opt)) {
continue;
}
options.marked = options.marked || {};
if (arg.indexOf('--no-') === 0) {
options.marked[opt] = typeof marked.defaults[opt] !== 'boolean'
? null
: false;
} else {
options.marked[opt] = typeof marked.defaults[opt] !== 'boolean'
? argv.shift()
: true;
}
} else {
orphans.push(arg);
}
break;
}
}
return options;
}
/**
* Helpers
*/
function camelize(text) {
return text.replace(/(\w)-(\w)/g, function(_, a, b) {
return a + b.toUpperCase();
});
}
/**
* Main
*/
function main(argv) {
var opt = parseArg();
if (opt.fix) {
return fix(opt);
}
if (opt.bench) {
return runBench(opt);
}
if (opt.time) {
return time(opt);
}
return runTests(opt);
}
/**
* Execute
*/
if (!module.parent) {
process.title = 'marked';
process.exit(main(process.argv.slice()) ? 0 : 1);
} else {
exports = main;
exports.main = main;
exports.runTests = runTests;
exports.runBench = runBench;
exports.load = load;
exports.bench = bench;
module.exports = exports;
}

View File

@ -1,3 +0,0 @@
<p>hello world
<a href="http://example.com">http://example.com</a>
</p>

View File

@ -1,2 +0,0 @@
hello world
<http://example.com>

View File

@ -1,3 +0,0 @@
<p>This fails in markdown.pl and upskirt:</p>
<ul><li>hello<blockquote><p>world</p></blockquote></li></ul>

View File

@ -1,4 +0,0 @@
This fails in markdown.pl and upskirt:
* hello
> world

View File

@ -1 +0,0 @@
<p><a href="/url">hi</a></p>

View File

@ -1,3 +0,0 @@
[hi]
[HI]: /url

View File

@ -1,28 +0,0 @@
<blockquote>
<p>hello
[1]: hello</p>
</blockquote>
<hr>
<blockquote>
<p>hello</p>
</blockquote>
<ul>
<li>hello</li>
<li>[3]: hello</li>
</ul>
<ul>
<li>hello</li>
</ul>
<blockquote>
<p>foo
bar
bar</p>
</blockquote>

View File

@ -1,21 +0,0 @@
> hello
> [1]: hello
* * *
> hello
[2]: hello
* hello
* [3]: hello
* hello
[4]: hello
> foo
> bar
[1]: foo
> bar

View File

@ -1,5 +0,0 @@
<p>Already linked: <a href="http://example.com/">http://example.com/</a>.</p>
<p>Already linked: <a href="http://example.com/">http://example.com/</a>.</p>
<p>Already linked: <a href="http://example.com/"><strong>http://example.com/</strong></a>.</p>

View File

@ -1,5 +0,0 @@
<p>Already linked: <a href="http://example.com/">http://example.com/</a>.</p>
Already linked: [http://example.com/](http://example.com/).
Already linked: <a href="http://example.com/">**http://example.com/**</a>.

View File

@ -1 +0,0 @@
<p>></p>

View File

@ -1 +0,0 @@
<p>Look at the<br>pretty line<br>breaks.</p>

View File

@ -1,3 +0,0 @@
Look at the
pretty line
breaks.

View File

@ -1,5 +0,0 @@
<pre><code class="lang-js">var a = &#39;hello&#39;;
console.log(a + &#39; world&#39;);</code></pre>
<pre><code class="lang-bash">echo &quot;hello, ${WORLD}&quot;</code></pre>
<pre><code class="lang-longfence">Q: What do you call a tall person who sells stolen goods?</code></pre>
<pre><code class="lang-ManyTildes">A longfence!</code></pre>

View File

@ -1,16 +0,0 @@
``` js
var a = 'hello';
console.log(a + ' world');
```
~~~bash
echo "hello, ${WORLD}"
~~~
```````longfence
Q: What do you call a tall person who sells stolen goods?
```````
~~~~~~~~~~ ManyTildes
A longfence!
~~~~~~~~~~

View File

@ -1,52 +0,0 @@
<h2 id="foo">foo</h2>
<ol>
<li><p>bar:</p>
<blockquote>
<ul>
<li>one<ul>
<li>two<ul>
<li>three</li>
<li>four</li>
<li>five</li>
</ul>
</li>
</ul>
</li>
</ul>
</blockquote>
</li>
<li><p>foo:</p>
<pre><code> line 1
line 2</code></pre>
</li>
<li><p>foo:</p>
<ol>
<li><p>foo <code>bar</code> bar:</p>
<pre><code class="lang-erb"> some code here
</code></pre>
</li>
<li><p>foo <code>bar</code> bar:</p>
<pre><code class="lang-erb"> foo
---
bar
---
foo
bar</code></pre>
</li>
<li><p>foo <code>bar</code> bar:</p>
<pre><code class="lang-html"> ---
foo
foo
---
bar</code></pre>
</li>
<li><p>foo <code>bar</code> bar:</p>
<pre><code> foo
---
bar</code></pre>
</li>
<li><p>foo</p>
</li>
</ol>
</li>
</ol>

View File

@ -1,53 +0,0 @@
## foo
1. bar:
> - one
- two
- three
- four
- five
1. foo:
```
line 1
line 2
```
1. foo:
1. foo `bar` bar:
``` erb
some code here
```
2. foo `bar` bar:
``` erb
foo
---
bar
---
foo
bar
```
3. foo `bar` bar:
``` html
---
foo
foo
---
bar
```
4. foo `bar` bar:
foo
---
bar
5. foo

View File

@ -1 +0,0 @@
<p>hello <del>hi</del> world</p>

View File

@ -1 +0,0 @@
hello ~~hi~~ world

View File

@ -1 +0,0 @@
<p>These words should_not_be_emphasized.</p>

View File

@ -1 +0,0 @@
These words should_not_be_emphasized.

View File

@ -1,2 +0,0 @@
<p>This should be a link:
<a href="http://example.com/hello-world">http://example.com/hello-world</a>.</p>

View File

@ -1 +0,0 @@
This should be a link: http://example.com/hello-world.

View File

@ -1,37 +0,0 @@
<table>
<thead>
<tr><th>Heading 1</th><th>Heading 2</th></tr>
</thead>
<tbody>
<tr><td>Cell 1</td><td>Cell 2</td></tr>
<tr><td>Cell 3</td><td>Cell 4</td></tr>
</tbody>
</table>
<table>
<thead>
<tr><th style="text-align:center">Header 1</th><th style="text-align:right">Header 2</th><th style="text-align:left">Header 3</th><th>Header 4</th></tr>
</thead>
<tbody>
<tr><td style="text-align:center">Cell 1</td><td style="text-align:right">Cell 2</td><td style="text-align:left">Cell 3</td><td>Cell 4</td></tr>
<tr><td style="text-align:center">Cell 5</td><td style="text-align:right">Cell 6</td><td style="text-align:left">Cell 7</td><td>Cell 8</td></tr>
</tbody>
</table>
<pre><code>Test code</code></pre>
<table>
<thead>
<tr><th>Header 1</th><th>Header 2</th></tr>
</thead>
<tbody>
<tr><td>Cell 1</td><td>Cell 2</td></tr>
<tr><td>Cell 3</td><td>Cell 4</td></tr>
</tbody>
</table>
<table>
<thead>
<tr><th style="text-align:left">Header 1</th><th style="text-align:center">Header 2</th><th style="text-align:right">Header 3</th><th>Header 4</th></tr>
</thead>
<tbody>
<tr><td style="text-align:left">Cell 1</td><td style="text-align:center">Cell 2</td><td style="text-align:right">Cell 3</td><td>Cell 4</td></tr>
<tr><td style="text-align:left"><em>Cell 5</em></td><td style="text-align:center">Cell 6</td><td style="text-align:right">Cell 7</td><td>Cell 8</td></tr>
</tbody>
</table>

View File

@ -1,21 +0,0 @@
| Heading 1 | Heading 2
| --------- | ---------
| Cell 1 | Cell 2
| Cell 3 | Cell 4
| Header 1 | Header 2 | Header 3 | Header 4 |
| :------: | -------: | :------- | -------- |
| Cell 1 | Cell 2 | Cell 3 | Cell 4 |
| Cell 5 | Cell 6 | Cell 7 | Cell 8 |
Test code
Header 1 | Header 2
-------- | --------
Cell 1 | Cell 2
Cell 3 | Cell 4
Header 1|Header 2|Header 3|Header 4
:-------|:------:|-------:|--------
Cell 1 |Cell 2 |Cell 3 |Cell 4
*Cell 5*|Cell 6 |Cell 7 |Cell 8

View File

@ -1,10 +0,0 @@
<ul>
<li>hello
world</li>
<li>how
are</li>
</ul>
<hr>
<p>you today?</p>

View File

@ -1,6 +0,0 @@
* hello
world
* how
are
* * *
you today?

View File

@ -1,4 +0,0 @@
<blockquote>
<p>hi there
bud</p>
</blockquote>

View File

@ -1,2 +0,0 @@
> hi there
bud

View File

@ -1 +0,0 @@
<ul><li><p>item1</p> <ul><li>item2 </li></ul> <p>text</p> </li></ul>

View File

@ -1,5 +0,0 @@
* item1
* item2
text

View File

@ -1,62 +0,0 @@
<ul>
<li><p>hello
world </p>
<p>how
are</p></li>
<li>you </li>
</ul>
<p>better behavior:</p>
<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>
<ul>
<li><p>hello</p></li>
<li><p>world</p></li>
<li>hi</li>
</ul>
<ul>
<li>hello</li>
<li><p>world</p></li>
<li><p>hi</p></li>
</ul>
<ul>
<li>hello</li>
<li><p>world</p>
<p>how</p></li>
<li>hi</li>
</ul>
<ul>
<li>hello</li>
<li>world</li>
<li><p>how</p>
<p>are</p></li>
</ul>
<ul>
<li>hello</li>
<li><p>world</p></li>
<li><p>how</p>
<p>are</p></li>
</ul>

View File

@ -1,59 +0,0 @@
* hello
world
how
are
* you
better behavior:
* hello
* world
how
are
you
* today
* hi
* hello
* world
* hi
* hello
* world
* hi
* hello
* world
how
* hi
* hello
* world
* how
are
* hello
* world
* how
are

View File

@ -1,4 +0,0 @@
<h1 id="a-heading">A heading</h1> <p>Just a note, I&#39;ve found that I can&#39;t test my markdown parser vs others. For example, both markdown.js and showdown code blocks in lists wrong. They&#39;re also completely <a href="http://google.com/" title="Google">inconsistent</a> with regards to paragraphs in list items.</p> <p>A link. Not anymore.</p> <aside>This will make me fail the test because
markdown.js doesnt acknowledge arbitrary html blocks =/</aside> <ul><li><p>List Item 1</p></li><li><p>List Item 2 </p><ul><li>New List Item 1 Hi, this is a list item.</li><li>New List Item 2 Another item <pre><code>Code goes here.
Lots of it...</code></pre></li><li>New List Item 3 The last item</li></ul></li><li><p>List Item 3 The final item.</p></li><li><p>List Item 4 The real final item.</p></li></ul> <p>Paragraph.</p> <blockquote><ul><li>bq Item 1</li><li>bq Item 2 <ul><li>New bq Item 1</li><li>New bq Item 2 Text here</li></ul></li></ul></blockquote> <hr> <blockquote><p> Another blockquote! I really need to get more creative with mockup text.. markdown.js breaks here again</p></blockquote> <h2 id="another-heading">Another Heading</h2> <p>Hello <em>world</em>. Here is a <a href="//hello">link</a>. And an image <img src="src" alt="alt">.</p> <pre><code>Code goes here.
Lots of it...</code></pre>

View File

@ -1,55 +0,0 @@
[test]: http://google.com/ "Google"
# A heading
Just a note, I've found that I can't test my markdown parser vs others.
For example, both markdown.js and showdown code blocks in lists wrong. They're
also completely [inconsistent][test] with regards to paragraphs in list items.
A link. Not anymore.
<aside>This will make me fail the test because
markdown.js doesnt acknowledge arbitrary html blocks =/</aside>
* List Item 1
* List Item 2
* New List Item 1
Hi, this is a list item.
* New List Item 2
Another item
Code goes here.
Lots of it...
* New List Item 3
The last item
* List Item 3
The final item.
* List Item 4
The real final item.
Paragraph.
> * bq Item 1
> * bq Item 2
> * New bq Item 1
> * New bq Item 2
> Text here
* * *
> Another blockquote!
> I really need to get
> more creative with
> mockup text..
> markdown.js breaks here again
Another Heading
-------------
Hello *world*. Here is a [link](//hello).
And an image ![alt](src).
Code goes here.
Lots of it...

View File

@ -1 +0,0 @@
<p><code>hi ther `` ok ```</code></p>

View File

@ -1 +0,0 @@
````` hi ther `` ok ``` `````

View File

@ -1,3 +0,0 @@
<p><em>test <strong>test</strong> test</em></p>
<p><em>test <strong>test</strong> test</em></p>

View File

@ -1,3 +0,0 @@
*test **test** test*
_test __test__ test_

View File

@ -1 +0,0 @@
<p><a href="/url">the <code>]</code> character</a></p>

View File

@ -1 +0,0 @@
[the `]` character](/url)

View File

@ -1 +0,0 @@
<p>[test](not a link)</p>

View File

@ -1 +0,0 @@
\[test](not a link)

View File

@ -1 +0,0 @@
<p><a href="/url" title="there">hi</a></p>

View File

@ -1,3 +0,0 @@
[hi]
[hi]: /url (there)

View File

@ -1,5 +0,0 @@
<ul>
<li>test</li>
<li>test</li>
<li>test</li>
</ul>

View File

@ -1,3 +0,0 @@
* test
+ test
- test

View File

@ -1,6 +0,0 @@
<p>Hello world how “are” you — today…</p>
<p>“Its a more challenging smartypants test…”</p>
<p>And, as a bonus — “one
multiline” test!</p>

View File

@ -1,6 +0,0 @@
Hello world 'how' "are" you -- today...
"It's a more 'challenging' smartypants test..."
'And,' as a bonus -- "one
multiline" test!

View File

@ -1,34 +0,0 @@
<p>hello world
how are you
how are you</p>
<p>hello world</p>
<pre><code>how are you</code></pre>
<p>hello world</p>
<hr>
<p>hello world</p>
<h1 id="how-are-you">how are you</h1>
<p>hello world</p>
<h1 id="how-are-you">how are you</h1>
<p>hello world</p>
<blockquote><p>how are you</p></blockquote>
<p>hello world</p>
<ul><li>how are you</li></ul>
<p>hello world</p>
<div>how are you</div>
<p>hello world
<span>how are you</span></p>
<p>hello <a href="/are/you">world</a>
</p>
<div>hello</div>
<p><span>hello</span></p>

View File

@ -1,37 +0,0 @@
hello world
how are you
how are you
hello world
```
how are you
```
hello world
* * *
hello world
# how are you
hello world
how are you
===========
hello world
> how are you
hello world
* how are you
hello world
<div>how are you</div>
hello world
<span>how are you</span>
hello [world][how]
[how]: /are/you
<div>hello</div>
<span>hello</span>

View File

@ -1,23 +0,0 @@
<p><strong>hello</strong> <em>world</em></p>
<ul>
<li>hello world</li>
</ul>
<p><strong>hello</strong> <em>world</em></p>
<ul>
<li>hello world</li>
</ul>
<p><strong>hello</strong> <em>world</em></p>
<ul>
<li>Hello world</li>
</ul>
<p><strong>hello</strong> <em>world</em></p>
<ul>
<li>hello world</li>
</ul>

View File

@ -1,15 +0,0 @@
**hello** _world_
* hello world
**hello** _world_
* hello world
**hello** _world_
* Hello world
**hello** _world_
* hello world

View File

@ -1,17 +0,0 @@
<p>AT&amp;T has an ampersand in their name.</p>
<p>AT&amp;T is another way to write it.</p>
<p>This &amp; that.</p>
<p>4 &lt; 5.</p>
<p>6 > 5.</p>
<p>Here's a <a href="http://example.com/?foo=1&amp;bar=2">link</a> with an ampersand in the URL.</p>
<p>Here's a link with an amersand in the link text: <a href="http://att.com/" title="AT&amp;T">AT&amp;T</a>.</p>
<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
<p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>

View File

@ -1,21 +0,0 @@
AT&T has an ampersand in their name.
AT&amp;T is another way to write it.
This & that.
4 < 5.
6 > 5.
Here's a [link] [1] with an ampersand in the URL.
Here's a link with an amersand in the link text: [AT&T] [2].
Here's an inline [link](/script?foo=1&bar=2).
Here's an inline [link](</script?foo=1&bar=2>).
[1]: http://example.com/?foo=1&bar=2
[2]: http://att.com/ "AT&T"

View File

@ -1,18 +0,0 @@
<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>
<p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</a></p>
<ul>
<li>In a list?</li>
<li><a href="http://example.com/">http://example.com/</a></li>
<li>It should.</li>
</ul>
<blockquote>
<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
</blockquote>
<p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
<pre><code>or here: &lt;http://example.com/&gt;
</code></pre>

View File

@ -1,13 +0,0 @@
Link: <http://example.com/>.
With an ampersand: <http://example.com/?foo=1&bar=2>
* In a list?
* <http://example.com/>
* It should.
> Blockquoted: <http://example.com/>
Auto-links should not occur here: `<http://example.com/>`
or here: <http://example.com/>

View File

@ -1,118 +0,0 @@
<p>These should all get escaped:</p>
<p>Backslash: \</p>
<p>Backtick: `</p>
<p>Asterisk: *</p>
<p>Underscore: _</p>
<p>Left brace: {</p>
<p>Right brace: }</p>
<p>Left bracket: [</p>
<p>Right bracket: ]</p>
<p>Left paren: (</p>
<p>Right paren: )</p>
<p>Greater-than: ></p>
<p>Hash: #</p>
<p>Period: .</p>
<p>Bang: !</p>
<p>Plus: +</p>
<p>Minus: -</p>
<p>These should not, because they occur within a code block:</p>
<pre><code>Backslash: \\
Backtick: \`
Asterisk: \*
Underscore: \_
Left brace: \{
Right brace: \}
Left bracket: \[
Right bracket: \]
Left paren: \(
Right paren: \)
Greater-than: \&gt;
Hash: \#
Period: \.
Bang: \!
Plus: \+
Minus: \-
</code></pre>
<p>Nor should these, which occur in code spans:</p>
<p>Backslash: <code>\\</code></p>
<p>Backtick: <code>\`</code></p>
<p>Asterisk: <code>\*</code></p>
<p>Underscore: <code>\_</code></p>
<p>Left brace: <code>\{</code></p>
<p>Right brace: <code>\}</code></p>
<p>Left bracket: <code>\[</code></p>
<p>Right bracket: <code>\]</code></p>
<p>Left paren: <code>\(</code></p>
<p>Right paren: <code>\)</code></p>
<p>Greater-than: <code>\&gt;</code></p>
<p>Hash: <code>\#</code></p>
<p>Period: <code>\.</code></p>
<p>Bang: <code>\!</code></p>
<p>Plus: <code>\+</code></p>
<p>Minus: <code>\-</code></p>
<p>These should get escaped, even though they're matching pairs for
other Markdown constructs:</p>
<p>*asterisks*</p>
<p>_underscores_</p>
<p>`backticks`</p>
<p>This is a code span with a literal backslash-backtick sequence: <code>\`</code></p>
<p>This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.</p>
<p>This is a tag with backslashes <span attr='\\backslashes\\'>bar</span>.</p>

View File

@ -1,120 +0,0 @@
These should all get escaped:
Backslash: \\
Backtick: \`
Asterisk: \*
Underscore: \_
Left brace: \{
Right brace: \}
Left bracket: \[
Right bracket: \]
Left paren: \(
Right paren: \)
Greater-than: \>
Hash: \#
Period: \.
Bang: \!
Plus: \+
Minus: \-
These should not, because they occur within a code block:
Backslash: \\
Backtick: \`
Asterisk: \*
Underscore: \_
Left brace: \{
Right brace: \}
Left bracket: \[
Right bracket: \]
Left paren: \(
Right paren: \)
Greater-than: \>
Hash: \#
Period: \.
Bang: \!
Plus: \+
Minus: \-
Nor should these, which occur in code spans:
Backslash: `\\`
Backtick: `` \` ``
Asterisk: `\*`
Underscore: `\_`
Left brace: `\{`
Right brace: `\}`
Left bracket: `\[`
Right bracket: `\]`
Left paren: `\(`
Right paren: `\)`
Greater-than: `\>`
Hash: `\#`
Period: `\.`
Bang: `\!`
Plus: `\+`
Minus: `\-`
These should get escaped, even though they're matching pairs for
other Markdown constructs:
\*asterisks\*
\_underscores\_
\`backticks\`
This is a code span with a literal backslash-backtick sequence: `` \` ``
This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.
This is a tag with backslashes <span attr='\\backslashes\\'>bar</span>.

View File

@ -1,15 +0,0 @@
<blockquote>
<p>Example:</p>
<pre><code>sub status {
print "working";
}
</code></pre>
<p>Or:</p>
<pre><code>sub status {
return "working";
}
</code></pre>
</blockquote>

View File

@ -1,11 +0,0 @@
> Example:
>
> sub status {
> print "working";
> }
>
> Or:
>
> sub status {
> return "working";
> }

View File

@ -1,18 +0,0 @@
<pre><code>code block on the first line
</code></pre>
<p>Regular text.</p>
<pre><code>code block indented by spaces
</code></pre>
<p>Regular text.</p>
<pre><code>the lines in this block
all contain trailing spaces
</code></pre>
<p>Regular Text.</p>
<pre><code>code block on the last line
</code></pre>

View File

@ -1,14 +0,0 @@
code block on the first line
Regular text.
code block indented by spaces
Regular text.
the lines in this block
all contain trailing spaces
Regular Text.
code block on the last line

View File

@ -1,6 +0,0 @@
<p><code>&lt;test a="</code> content of attribute <code>"&gt;</code></p>
<p>Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span></p>
<p>Here's how you put <code>`backticks`</code> in a code span.</p>

View File

@ -1,6 +0,0 @@
`<test a="` content of attribute `">`
Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span>
Here's how you put `` `backticks` `` in a code span.

View File

@ -1,8 +0,0 @@
<p>In Markdown 1.0.0 and earlier. Version
8. This line turns into a list item.
Because a hard-wrapped line in the
middle of a paragraph looked like a
list item.</p>
<p>Here's one with a bullet.
* criminey.</p>

View File

@ -1,8 +0,0 @@
In Markdown 1.0.0 and earlier. Version
8. This line turns into a list item.
Because a hard-wrapped line in the
middle of a paragraph looked like a
list item.
Here's one with a bullet.
* criminey.

View File

@ -1,71 +0,0 @@
<p>Dashes:</p>
<hr />
<hr />
<hr />
<hr />
<pre><code>---
</code></pre>
<hr />
<hr />
<hr />
<hr />
<pre><code>- - -
</code></pre>
<p>Asterisks:</p>
<hr />
<hr />
<hr />
<hr />
<pre><code>***
</code></pre>
<hr />
<hr />
<hr />
<hr />
<pre><code>* * *
</code></pre>
<p>Underscores:</p>
<hr />
<hr />
<hr />
<hr />
<pre><code>___
</code></pre>
<hr />
<hr />
<hr />
<hr />
<pre><code>_ _ _
</code></pre>

View File

@ -1,67 +0,0 @@
Dashes:
---
---
---
---
---
- - -
- - -
- - -
- - -
- - -
Asterisks:
***
***
***
***
***
* * *
* * *
* * *
* * *
* * *
Underscores:
___
___
___
___
___
_ _ _
_ _ _
_ _ _
_ _ _
_ _ _

View File

@ -1,15 +0,0 @@
<p>Simple block on one line:</p>
<div>foo</div>
<p>And nested without indentation:</p>
<div>
<div>
<div>
foo
</div>
<div style=">"/>
</div>
<div>bar</div>
</div>

View File

@ -1,15 +0,0 @@
Simple block on one line:
<div>foo</div>
And nested without indentation:
<div>
<div>
<div>
foo
</div>
<div style=">"/>
</div>
<div>bar</div>
</div>

View File

@ -1,13 +0,0 @@
<p>Paragraph one.</p>
<!-- This is a simple comment -->
<!--
This is another comment.
-->
<p>Paragraph two.</p>
<!-- one comment block -- -- with two comments -->
<p>The end.</p>

View File

@ -1,13 +0,0 @@
Paragraph one.
<!-- This is a simple comment -->
<!--
This is another comment.
-->
Paragraph two.
<!-- one comment block -- -- with two comments -->
The end.

View File

@ -1,72 +0,0 @@
<p>Here's a simple block:</p>
<div>
foo
</div>
<p>This should be a code block, though:</p>
<pre><code>&lt;div&gt;
foo
&lt;/div&gt;
</code></pre>
<p>As should this:</p>
<pre><code>&lt;div&gt;foo&lt;/div&gt;
</code></pre>
<p>Now, nested:</p>
<div>
<div>
<div>
foo
</div>
</div>
</div>
<p>This should just be an HTML comment:</p>
<!-- Comment -->
<p>Multiline:</p>
<!--
Blah
Blah
-->
<p>Code block:</p>
<pre><code>&lt;!-- Comment --&gt;
</code></pre>
<p>Just plain comment, with trailing spaces on the line:</p>
<!-- foo -->
<p>Code:</p>
<pre><code>&lt;hr /&gt;
</code></pre>
<p>Hr's:</p>
<hr>
<hr/>
<hr />
<hr>
<hr/>
<hr />
<hr class="foo" id="bar" />
<hr class="foo" id="bar"/>
<hr class="foo" id="bar" >

View File

@ -1,69 +0,0 @@
Here's a simple block:
<div>
foo
</div>
This should be a code block, though:
<div>
foo
</div>
As should this:
<div>foo</div>
Now, nested:
<div>
<div>
<div>
foo
</div>
</div>
</div>
This should just be an HTML comment:
<!-- Comment -->
Multiline:
<!--
Blah
Blah
-->
Code block:
<!-- Comment -->
Just plain comment, with trailing spaces on the line:
<!-- foo -->
Code:
<hr />
Hr's:
<hr>
<hr/>
<hr />
<hr>
<hr/>
<hr />
<hr class="foo" id="bar" />
<hr class="foo" id="bar"/>
<hr class="foo" id="bar" >

View File

@ -1,15 +0,0 @@
<p>Just a <a href="/url/">URL</a>.</p>
<p><a href="/url/" title="title">URL and title</a>.</p>
<p><a href="/url/" title="title preceded by two spaces">URL and title</a>.</p>
<p><a href="/url/" title="title preceded by a tab">URL and title</a>.</p>
<p><a href="/url/" title="title has spaces afterward">URL and title</a>.</p>
<p><a href="/url/has space">URL and title</a>.</p>
<p><a href="/url/has space/" title="url has space and title">URL and title</a>.</p>
<p><a href="">Empty</a>.</p>

View File

@ -1,15 +0,0 @@
Just a [URL](/url/).
[URL and title](/url/ "title").
[URL and title](/url/ "title preceded by two spaces").
[URL and title](/url/ "title preceded by a tab").
[URL and title](/url/ "title has spaces afterward" ).
[URL and title]( /url/has space ).
[URL and title]( /url/has space/ "url has space and title").
[Empty]().

View File

@ -1,52 +0,0 @@
<p>Foo <a href="/url/" title="Title">bar</a>.</p>
<p>Foo <a href="/url/" title="Title">bar</a>.</p>
<p>Foo <a href="/url/" title="Title">bar</a>.</p>
<p>With <a href="/url/">embedded [brackets]</a>.</p>
<p>Indented <a href="/url">once</a>.</p>
<p>Indented <a href="/url">twice</a>.</p>
<p>Indented <a href="/url">thrice</a>.</p>
<p>Indented [four][] times.</p>
<pre><code>[four]: /url
</code></pre>
<hr />
<p><a href="foo">this</a> should work</p>
<p>So should <a href="foo">this</a>.</p>
<p>And <a href="foo">this</a>.</p>
<p>And <a href="foo">this</a>.</p>
<p>And <a href="foo">this</a>.</p>
<p>But not [that] [].</p>
<p>Nor [that][].</p>
<p>Nor [that].</p>
<p>[Something in brackets like <a href="foo">this</a> should work]</p>
<p>[Same with <a href="foo">this</a>.]</p>
<p>In this case, <a href="/somethingelse/">this</a> points to something else.</p>
<p>Backslashing should suppress [this] and [this].</p>
<hr />
<p>Here's one where the <a href="/url/">link
breaks</a> across lines.</p>
<p>Here's another where the <a href="/url/">link
breaks</a> across lines, but with a line-ending space.</p>

View File

@ -1,71 +0,0 @@
Foo [bar] [1].
Foo [bar][1].
Foo [bar]
[1].
[1]: /url/ "Title"
With [embedded [brackets]] [b].
Indented [once][].
Indented [twice][].
Indented [thrice][].
Indented [four][] times.
[once]: /url
[twice]: /url
[thrice]: /url
[four]: /url
[b]: /url/
* * *
[this] [this] should work
So should [this][this].
And [this] [].
And [this][].
And [this].
But not [that] [].
Nor [that][].
Nor [that].
[Something in brackets like [this][] should work]
[Same with [this].]
In this case, [this](/somethingelse/) points to something else.
Backslashing should suppress \[this] and [this\].
[this]: foo
* * *
Here's one where the [link
breaks] across lines.
Here's another where the [link
breaks] across lines, but with a line-ending space.
[link breaks]: /url/

View File

@ -1,9 +0,0 @@
<p>This is the <a href="/simple">simple case</a>.</p>
<p>This one has a <a href="/foo">line
break</a>.</p>
<p>This one has a <a href="/foo">line
break</a> with a line-ending space.</p>
<p><a href="/that">this</a> and the <a href="/other">other</a></p>

Some files were not shown because too many files have changed in this diff Show More