diff -Nru node-marked-0.3.0+dfsg/component.json node-marked-0.3.1+dfsg/component.json --- node-marked-0.3.0+dfsg/component.json 2013-12-24 14:08:54.000000000 +0000 +++ node-marked-0.3.1+dfsg/component.json 2014-01-31 23:00:36.000000000 +0000 @@ -1,6 +1,6 @@ { "name": "marked", - "version": "0.2.10", + "version": "0.3.1", "repo": "chjj/marked", "description": "A markdown parser built for speed", "keywords": ["markdown", "markup", "html"], diff -Nru node-marked-0.3.0+dfsg/debian/changelog node-marked-0.3.1+dfsg/debian/changelog --- node-marked-0.3.0+dfsg/debian/changelog 2014-01-02 22:55:24.000000000 +0000 +++ node-marked-0.3.1+dfsg/debian/changelog 2014-02-15 18:33:47.000000000 +0000 @@ -1,3 +1,10 @@ +node-marked (0.3.1+dfsg-1) unstable; urgency=medium + + * New upstream release + * drop upstream applied man-hyphen.patch + + -- Julian Taylor Sat, 15 Feb 2014 19:32:37 +0100 + node-marked (0.3.0+dfsg-1) unstable; urgency=low * New upstream release diff -Nru node-marked-0.3.0+dfsg/debian/patches/man-hyphen.patch node-marked-0.3.1+dfsg/debian/patches/man-hyphen.patch --- node-marked-0.3.0+dfsg/debian/patches/man-hyphen.patch 2014-01-02 22:55:24.000000000 +0000 +++ node-marked-0.3.1+dfsg/debian/patches/man-hyphen.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -Description: fix hyphen used as minus -Bug: https://github.com/chjj/marked/issues/231 - ---- a/man/marked.1 -+++ b/man/marked.1 -@@ -23,9 +23,9 @@ - .TP - echo "hello *world*" | marked - .TP --marked -o out.html in.md --gfm -+marked \-o out.html in.md \-\-gfm - .TP --marked --output="hello world.html" -i in.md --no-breaks -+marked \-\-output="hello world.html" \-i in.md \-\-no-breaks - - .SH OPTIONS - .TP diff -Nru node-marked-0.3.0+dfsg/debian/patches/series node-marked-0.3.1+dfsg/debian/patches/series --- node-marked-0.3.0+dfsg/debian/patches/series 2014-01-02 22:55:24.000000000 +0000 +++ node-marked-0.3.1+dfsg/debian/patches/series 2014-02-15 18:33:47.000000000 +0000 @@ -1,2 +1 @@ 2001_man_global.patch -man-hyphen.patch diff -Nru node-marked-0.3.0+dfsg/lib/marked.js node-marked-0.3.1+dfsg/lib/marked.js --- node-marked-0.3.0+dfsg/lib/marked.js 2013-12-24 14:08:54.000000000 +0000 +++ node-marked-0.3.1+dfsg/lib/marked.js 2014-01-31 23:00:36.000000000 +0000 @@ -41,7 +41,7 @@ block._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+(?!:/|@)\\b'; + + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b'; block.html = replace(block.html) ('comment', //) @@ -515,6 +515,7 @@ this.links = links; this.rules = inline.normal; this.renderer = this.options.renderer || new Renderer; + this.renderer.options = this.options; if (!this.links) { throw new @@ -735,13 +736,13 @@ * Renderer */ -function Renderer() {} - -Renderer.prototype.code = function(code, lang, escaped, options) { - options = options || {}; +function Renderer(options) { + this.options = options || {}; +} - if (options.highlight) { - var out = options.highlight(code, lang); +Renderer.prototype.code = function(code, lang, escaped) { + if (this.options.highlight) { + var out = this.options.highlight(code, lang); if (out != null && out !== code) { escaped = true; code = out; @@ -755,10 +756,10 @@ } return '
'
-    + (escaped ? code : escape(code))
+    + (escaped ? code : escape(code, true))
     + '\n
\n'; }; @@ -770,11 +771,11 @@ return html; }; -Renderer.prototype.heading = function(text, level, raw, options) { +Renderer.prototype.heading = function(text, level, raw) { return '' + text @@ -845,6 +846,18 @@ }; Renderer.prototype.link = function(href, title, text) { + if (this.options.sanitize) { + try { + var prot = decodeURIComponent(unescape(href)) + .replace(/[^\w:]/g, '') + .toLowerCase(); + } catch (e) { + return ''; + } + if (prot.indexOf('javascript:') === 0) { + return ''; + } + } var out = ' A full-featured markdown parser and compiler, written in javascript. Built +> A full-featured markdown parser and compiler, written in JavaScript. Built > for speed. [![NPM version](https://badge.fury.io/js/marked.png)][badge] @@ -16,65 +16,194 @@ Minimal usage: ```js +var marked = require('marked'); console.log(marked('I am using __markdown__.')); // Outputs:

I am using markdown.

``` -Example using all options: +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, + smartypants: false }); -// Using async version of marked -marked('I am using __markdown__.', function (err, content) { - if (err) throw err; - console.log(content); -}); +console.log(marked('I am using __markdown__.')); ``` -## marked(markdownString, [options], [callback]) +## marked(markdownString [,options] [,callback]) ### markdownString -Type: `String` +Type: `string` String of markdown source to be compiled. ### options -Type: `Object` +Type: `object` Hash of options. Can also be set using the `marked.setOptions` method as seen above. ### callback -Type: `Function` +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 as seen above: +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 '
' + + text + '
'; +}, + +console.log(marked('# heading+', { renderer: renderer })); +``` +This code will output the following HTML: +```html +

+ + + + heading+ +

+``` + +#### 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` +Type: `boolean` Default: `true` Enable [GitHub flavored markdown][gfm]. ### tables -Type: `Boolean` +Type: `boolean` Default: `true` Enable GFM [tables][tables]. @@ -82,7 +211,7 @@ ### breaks -Type: `Boolean` +Type: `boolean` Default: `false` Enable GFM [line breaks][breaks]. @@ -90,7 +219,7 @@ ### pedantic -Type: `Boolean` +Type: `boolean` Default: `false` Conform to obscure parts of `markdown.pl` as much as possible. Don't fix any of @@ -98,14 +227,14 @@ ### sanitize -Type: `Boolean` +Type: `boolean` Default: `false` Sanitize the output. Ignore any HTML that has been input. ### smartLists -Type: `Boolean` +Type: `boolean` Default: `true` Use smarter list behavior than the original markdown. May eventually be @@ -113,68 +242,11 @@ ### smartypants -Type: `Boolean` +Type: `boolean` Default: `false` Use "smart" typograhic punctuation for things like quotes and dashes. -### renderer - -Type: `Renderer` -Default: `new Renderer()` - -A renderer instance for rendering ast to html. Learn more on the Renderer -section. - -## Renderer - -Renderer is a the new way for rendering tokens to html. Here is a simple -example: - -```javascript -var r = new marked.Renderer() -r.blockcode = function(code, lang) { - return highlight(lang, code).value; -} - -console.log(marked(text, {renderer: r})) -``` - -You can control anything you want. - -### Block Level - -- code(code, language) -- blockquote(quote) -- html(html) -- heading(text, level) -- hr() -- list(body, ordered) -- listitem(text) -- paragraph(text) -- table(header, body) -- tablerow(content) -- tablecell(content, flags) - -`flags` is an object like this: - -``` -{ - header: true, - align: 'center' -} -``` - -### Span Level - -- strong(text) -- em(text) -- codespan(code) -- br() -- del(text) -- link(href, title, text) -- image(href, title, text) - ## Access to lexer and parser You also have direct access to the lexer and parser if you so desire. @@ -201,51 +273,7 @@

hello world

``` -## 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 6448ms. -marked (gfm) completed in 7357ms. -marked (pedantic) completed in 6092ms. -discount completed in 7314ms. -showdown (reuse converter) completed in 16018ms. -showdown (new converter) completed in 18234ms. -markdown-js completed in 24270ms. -``` - -__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. - -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. -``` - -## Another Javascript Markdown Parser +## 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 @@ -265,46 +293,24 @@ Along with implementing every markdown feature, marked also implements [GFM features][gfmf]. -### High level - -You can customize the result with a customized renderer. - -``` js -var renderer = new marked.Renderer() - -renderer.heading = function(text, level) { - return '
' + text + '
' -} - -var parse = function(src, options) { - options = options || {}; - options.renderer = renderer - return marked.parser(marked.lexer(src, options), options); -} - -console.log(parse('# h1')) -``` +## Benchmarks -The renderer API: +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. ``` -code: function(code, lang) -blockquote: function(text) -html: function(html) -heading: function(text, level) -paragraph: function(text) - -hr: function() - -list: function(contents, isOrdered) -listitem: function(text) +__Marked is now faster than Discount, which is written in C.__ -table: function(header, body) -tablerow: function(content) -tablecell: function(text, flags) -// flags: {header: false, align: 'center'} -``` +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 @@ -367,7 +373,7 @@ ## License -Copyright (c) 2011-2013, Christopher Jeffrey. (MIT License) +Copyright (c) 2011-2014, Christopher Jeffrey. (MIT License) See LICENSE for more info.