提交 3fb0d025 编写于 作者: M Matt Bierner

Update marked version

Fixes Microsoft/vscode-internalbacklog#40
上级 8c6f1b29
......@@ -3,6 +3,6 @@
[{
"name": "chjj-marked",
"repositoryURL": "https://github.com/npmcomponent/chjj-marked",
"version": "0.3.2",
"version": "0.3.6",
"license": "MIT"
}]
/**
* marked - a markdown parser
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
......@@ -78,8 +77,9 @@ block.normal = merge({}, block);
*/
block.gfm = merge({}, block.normal, {
fences: /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,
paragraph: /^/
fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,
paragraph: /^/,
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
});
block.gfm.paragraph = replace(block.paragraph)
......@@ -191,7 +191,7 @@ Lexer.prototype.token = function(src, top, bq) {
this.tokens.push({
type: 'code',
lang: cap[2],
text: cap[3]
text: cap[3] || ''
});
continue;
}
......@@ -362,7 +362,8 @@ Lexer.prototype.token = function(src, top, bq) {
type: this.options.sanitize
? 'paragraph'
: 'html',
pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
pre: !this.options.sanitizer
&& (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
text: cap[0]
});
continue;
......@@ -457,7 +458,7 @@ var inline = {
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
br: /^ {2,}\n(?!\s*$)/,
del: noop,
......@@ -609,8 +610,10 @@ InlineLexer.prototype.output = function(src) {
}
src = src.substring(cap[0].length);
out += this.options.sanitize
? escape(cap[0])
: cap[0];
? this.options.sanitizer
? this.options.sanitizer(cap[0])
: escape(cap[0])
: cap[0]
continue;
}
......@@ -681,7 +684,7 @@ InlineLexer.prototype.output = function(src) {
// text
if (cap = this.rules.text.exec(src)) {
src = src.substring(cap[0].length);
out += escape(this.smartypants(cap[0]));
out += this.renderer.text(escape(this.smartypants(cap[0])));
continue;
}
......@@ -710,24 +713,24 @@ InlineLexer.prototype.outputLink = function(cap, link) {
/**
* Smartypants Transformations
*/
// TODO MonacoChange: Our build fails over the following lines if they are not commented out
InlineLexer.prototype.smartypants = function(text) {
return text;
// if (!this.options.smartypants) return text;
// return text
// // em-dashes
// .replace(/--/g, '\u2014')
// // opening singles
// .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
// // closing singles & apostrophes
// .replace(/'/g, '\u2019')
// // opening doubles
// .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
// // closing doubles
// .replace(/"/g, '\u201d')
// // ellipses
// .replace(/\.{3}/g, '\u2026');
// END MonacoChange
if (!this.options.smartypants) return text;
return text
// em-dashes
.replace(/---/g, '\u2014')
// en-dashes
.replace(/--/g, '\u2013')
// opening singles
.replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
// closing singles & apostrophes
.replace(/'/g, '\u2019')
// opening doubles
.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
// closing doubles
.replace(/"/g, '\u201d')
// ellipses
.replace(/\.{3}/g, '\u2026');
};
/**
......@@ -735,6 +738,7 @@ InlineLexer.prototype.smartypants = function(text) {
*/
InlineLexer.prototype.mangle = function(text) {
if (!this.options.mangle) return text;
var out = ''
, l = text.length
, i = 0
......@@ -873,7 +877,7 @@ Renderer.prototype.link = function(href, title, text) {
} catch (e) {
return '';
}
if (prot.indexOf('javascript:') === 0) {
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
return '';
}
}
......@@ -894,6 +898,10 @@ Renderer.prototype.image = function(href, title, text) {
return out;
};
Renderer.prototype.text = function(text) {
return text;
};
/**
* Parsing & Compiling
*/
......@@ -1088,7 +1096,8 @@ function escape(html, encode) {
}
function unescape(html) {
return html.replace(/&([#\w]+);/g, function(_, n) {
// explicitly match decimal, hex, and named HTML entities
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) {
n = n.toLowerCase();
if (n === 'colon') return ':';
if (n.charAt(0) === '#') {
......@@ -1237,6 +1246,8 @@ marked.defaults = {
breaks: false,
pedantic: false,
sanitize: false,
sanitizer: null,
mangle: true,
smartLists: false,
silent: false,
highlight: null,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册