diff --git a/tools/doc/node_modules/.bin/marked b/tools/doc/node_modules/.bin/marked new file mode 100644 index 000000000..a8d872e9d --- /dev/null +++ b/tools/doc/node_modules/.bin/marked @@ -0,0 +1 @@ +../marked/bin/marked \ No newline at end of file diff --git a/tools/doc/node_modules/marked/.npmignore b/tools/doc/node_modules/marked/.npmignore new file mode 100644 index 000000000..3fb773c03 --- /dev/null +++ b/tools/doc/node_modules/marked/.npmignore @@ -0,0 +1,2 @@ +.git* +test/ diff --git a/tools/doc/node_modules/marked/LICENSE b/tools/doc/node_modules/marked/LICENSE new file mode 100644 index 000000000..40597477c --- /dev/null +++ b/tools/doc/node_modules/marked/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2011-2012, 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. diff --git a/tools/doc/node_modules/marked/Makefile b/tools/doc/node_modules/marked/Makefile new file mode 100644 index 000000000..76904000b --- /dev/null +++ b/tools/doc/node_modules/marked/Makefile @@ -0,0 +1,9 @@ +all: + @cp lib/marked.js marked.js + @uglifyjs -o marked.min.js marked.js + +clean: + @rm marked.js + @rm marked.min.js + +.PHONY: clean all diff --git a/tools/doc/node_modules/marked/README.md b/tools/doc/node_modules/marked/README.md new file mode 100644 index 000000000..1a0747c0d --- /dev/null +++ b/tools/doc/node_modules/marked/README.md @@ -0,0 +1,135 @@ +# marked + +A full-featured markdown parser and compiler. +Built for speed. + +## Benchmarks + +node v0.4.x + +``` bash +$ node test --bench +marked completed in 12071ms. +showdown (reuse converter) completed in 27387ms. +showdown (new converter) completed in 75617ms. +markdown-js completed in 70069ms. +``` + +node v0.6.x + +``` bash +$ node test --bench +marked completed in 6485ms. +marked (with gfm) completed in 7466ms. +discount completed in 7169ms. +showdown (reuse converter) completed in 15937ms. +showdown (new converter) completed in 18279ms. +markdown-js completed in 23572ms. +``` + +__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. + +Benchmarks for other engines to come (?). + +## Install + +``` bash +$ npm install marked +``` + +## Another javascript markdown parser + +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](http://github.github.com/github-flavored-markdown/). + +## Usage + +``` js +var marked = require('marked'); +console.log(marked('i am using __markdown__.')); +``` + +You also have direct access to the lexer and parser if you so desire. + +``` js +var tokens = marked.lexer(str); +console.log(marked.parser(tokens)); +``` + +``` bash +$ node +> require('marked').lexer('> i am using marked.') +[ { type: 'blockquote_start' }, + { type: 'text', text: ' i am using marked.' }, + { type: 'blockquote_end' }, + links: {} ] +``` + +## CLI + +``` bash +$ marked -o hello.html +hello world +^D +$ cat hello.html +
hello world
+``` + +## Syntax Highlighting + +Marked has an interface that allows for a syntax highlighter to highlight code +blocks before they're output. + +Example implementation: + +``` js +var highlight = require('my-syntax-highlighter') + , marked_ = require('marked'); + +var marked = function(text) { + var tokens = marked_.lexer(text) + , l = tokens.length + , i = 0 + , token; + + for (; i < l; i++) { + token = tokens[i]; + if (token.type === 'code') { + token.text = highlight(token.text, token.lang); + // marked should not escape this + token.escaped = true; + } + } + + text = marked_.parser(tokens); + + return text; +}; + +module.exports = marked; +``` + +## License + +Copyright (c) 2011-2012, Christopher Jeffrey. (MIT License) + +See LICENSE for more info. diff --git a/tools/doc/node_modules/marked/bin/marked b/tools/doc/node_modules/marked/bin/marked new file mode 100644 index 000000000..7d00504ed --- /dev/null +++ b/tools/doc/node_modules/marked/bin/marked @@ -0,0 +1,115 @@ +#!/usr/bin/env node + +/** + * Marked CLI + * Copyright (c) 2011-2012, Christopher Jeffrey (MIT License) + */ + +var fs = require('fs') + , util = require('util') + , marked = require('../'); + +/** + * Man Page + */ + +var help = function() { + 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 + */ + +var main = function(argv) { + var files = [] + , data = '' + , input + , output + , arg + , tokens; + + var getarg = function() { + var arg = argv.shift(); + arg = arg.split('='); + if (arg.length > 1) { + argv.unshift(arg.slice(1).join('=')); + } + return arg[0]; + }; + + while (argv.length) { + arg = getarg(); + switch (arg) { + 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: + files.push(arg); + break; + } + } + + if (!input) { + if (files.length <= 2) { + var stdin = process.stdin; + + stdin.setEncoding('utf8'); + stdin.resume(); + + stdin.on('data', function(text) { + data += text; + }); + + stdin.on('end', write); + + return; + } + input = files.pop(); + } + + data = fs.readFileSync(input, 'utf8'); + write(); + + function write() { + data = tokens + ? JSON.stringify(marked.lexer(data), null, 2) + : marked(data); + + if (!output) { + process.stdout.write(data + '\n'); + } else { + fs.writeFileSync(output, data); + } + } +}; + +if (!module.parent) { + process.title = 'marked'; + main(process.argv.slice()); +} else { + module.exports = main; +} diff --git a/tools/doc/node_modules/marked/index.js b/tools/doc/node_modules/marked/index.js new file mode 100644 index 000000000..a12f90569 --- /dev/null +++ b/tools/doc/node_modules/marked/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/marked'); diff --git a/tools/doc/node_modules/marked/lib/marked.js b/tools/doc/node_modules/marked/lib/marked.js new file mode 100644 index 000000000..c6f3d0ac8 --- /dev/null +++ b/tools/doc/node_modules/marked/lib/marked.js @@ -0,0 +1,662 @@ +/** + * marked - A markdown parser (https://github.com/chjj/marked) + * Copyright (c) 2011-2012, Christopher Jeffrey. (MIT Licensed) + */ + +;(function() { + +/** + * Block-Level Grammar + */ + +var block = { + newline: /^\n+/, + code: /^ {4,}[^\n]*(?:\n {4,}[^\n]*|\n)*(?:\n+|$)/, + gfm_code: /^ *``` *(\w+)? *\n([^\0]+?)\s*``` *(?:\n+|$)/, + hr: /^( *[\-*_]){3,} *(?:\n+|$)/, + heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/, + lheading: /^([^\n]+)\n *(=|-){3,} *\n*/, + blockquote: /^( *>[^\n]+(\n[^\n]+)*\n*)+/, + list: /^( *)([*+-]|\d+\.) [^\0]+?(?:\n{2,}(?! )|\s*$)(?!\1bullet)\n*/, + html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/, + def: /^ *\[([^\]]+)\]: *([^\s]+)(?: +["(]([^\n]+)[")])? *(?:\n+|$)/, + paragraph: /^([^\n]+\n?(?!body))+\n*/, + text: /^[^\n]+/ +}; + +block.list = (function() { + var list = block.list.source; + + list = list + .replace('bullet', /(?:[*+-](?!(?: *[-*]){2,})|\d+\.)/.source); + + return new RegExp(list); +})(); + +block.html = (function() { + var html = block.html.source; + + html = html + .replace('comment', //.source) + .replace('closed', /<(tag)[^\0]+?<\/\1>/.source) + .replace('closing', /'
+ + escape(cap[2], true)
+ + '
';
+ continue;
+ }
+
+ // br
+ if (cap = inline.br.exec(src)) {
+ src = src.substring(cap[0].length);
+ out += ''
+ + (token.escaped
+ ? token.text
+ : escape(token.text, true))
+ + '
\n';
+ }
+ case 'blockquote_start': {
+ var body = '';
+
+ while (next().type !== 'blockquote_end') {
+ body += tok();
+ }
+
+ return '\n' + + body + + '\n'; + } + case 'list_start': { + var type = token.ordered ? 'ol' : 'ul' + , body = ''; + + while (next().type !== 'list_end') { + body += tok(); + } + + return '<' + + type + + '>\n' + + body + + '' + + type + + '>\n'; + } + case 'list_item_start': { + var body = ''; + + while (next().type !== 'list_item_end') { + body += token.type === 'text' + ? parseText() + : tok(); + } + + return '
' + + inline.lexer(token.text) + + '
\n'; + } + case 'text': { + return '' + + parseText() + + '
\n'; + } + } +}; + +var parseText = function() { + var body = token.text + , top; + + while ((top = tokens[tokens.length-1]) + && top.type === 'text') { + body += '\n' + next().text; + } + + return inline.lexer(body); +}; + +var parse = function(src) { + tokens = src.reverse(); + + var out = ''; + while (next()) { + out += tok(); + } + + tokens = null; + token = null; + + return out; +}; + +/** + * Helpers + */ + +var escape = function(html, encode) { + return html + .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); +}; + +var mangle = function(text) { + var out = '' + , l = text.length + , i = 0 + , ch; + + for (; i < l; i++) { + ch = text.charCodeAt(i); + if (Math.random() > 0.5) { + ch = 'x' + ch.toString(16); + } + out += '' + ch + ';'; + } + + return out; +}; + +function tag() { + var tag = '(?!(?:' + + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code' + + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo' + + '|span|br|wbr|ins|del|img)\\b)\\w+'; + + return tag; +} + +/** + * Expose + */ + +var marked = function(src) { + return parse(block.lexer(src)); +}; + +marked.parser = parse; +marked.lexer = block.lexer; + +marked.parse = marked; + +if (typeof module !== 'undefined') { + module.exports = marked; +} else { + this.marked = marked; +} + +}).call(this); diff --git a/tools/doc/node_modules/marked/man/marked.1 b/tools/doc/node_modules/marked/man/marked.1 new file mode 100644 index 000000000..214533390 --- /dev/null +++ b/tools/doc/node_modules/marked/man/marked.1 @@ -0,0 +1,39 @@ +.ds q \N'34' +.TH marked 1 +.SH NAME +marked \- a javascript markdown parser +.SH SYNOPSIS +.nf +.B marked [\-o output] [\-i input] [\-th] +.fi +.SH DESCRIPTION +.B marked +is a full-featured javascript markdown parser, built for speed. It also includes +multiple GFM features. +.SH OPTIONS +.TP +.BI \-o,\ \-\-output\ [output] +Specify file output. If none is specified, write to stdout. +.TP +.BI \-i,\ \-\-input\ [input] +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 +.TP +cat in.md | marked > out.html +.TP +echo "hello *world*" | marked +.TP +marked -o out.html in.md +.TP +marked --output="hello world.html" -i in.md +.SH BUGS +Please report any bugs to https://github.com/chjj/marked. +.SH LICENSE +Copyright (c) 2011-2012, Christopher Jeffrey (MIT License) diff --git a/tools/doc/node_modules/marked/package.json b/tools/doc/node_modules/marked/package.json new file mode 100644 index 000000000..f47a9e125 --- /dev/null +++ b/tools/doc/node_modules/marked/package.json @@ -0,0 +1,15 @@ +{ + "name": "marked", + "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", + "homepage": "https://github.com/chjj/marked", + "bugs": "http://github.com/chjj/marked/issues", + "keywords": [ "markdown", "markup", "html" ], + "tags": [ "markdown", "markup", "html" ] +}