|
|
|
@ -608,7 +608,7 @@ function createCommonjsModule(fn, module) { |
|
|
|
|
var marked = createCommonjsModule(function (module, exports) { |
|
|
|
|
/** |
|
|
|
|
* marked - a markdown parser |
|
|
|
|
* Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed) |
|
|
|
|
* Copyright (c) 2011-2018, Christopher Jeffrey. (MIT Licensed) |
|
|
|
|
* https://github.com/markedjs/marked
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
@ -618,20 +618,29 @@ var block = { |
|
|
|
|
code: /^( {4}[^\n]+\n*)+/, |
|
|
|
|
fences: noop, |
|
|
|
|
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/, |
|
|
|
|
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/, |
|
|
|
|
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/, |
|
|
|
|
nptable: noop, |
|
|
|
|
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/, |
|
|
|
|
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, |
|
|
|
|
html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/, |
|
|
|
|
html: '^ {0,3}(?:' // optional indentation
|
|
|
|
|
+ '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
|
|
|
|
|
+ '|comment[^\\n]*(\\n+|$)' // (2)
|
|
|
|
|
+ '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
|
|
|
|
|
+ '|<![A-Z][\\s\\S]*?>\\n*' // (4)
|
|
|
|
|
+ '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
|
|
|
|
|
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
|
|
|
|
|
+ '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
|
|
|
|
|
+ '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=\\h*\\n)[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
|
|
|
|
|
+ ')', |
|
|
|
|
def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/, |
|
|
|
|
table: noop, |
|
|
|
|
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/, |
|
|
|
|
paragraph: /^([^\n]+(?:\n?(?!hr|heading|lheading| {0,3}>|tag)[^\n]+)+)/, |
|
|
|
|
paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/, |
|
|
|
|
text: /^[^\n]+/ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
block._label = /(?:\\[\[\]]|[^\[\]])+/; |
|
|
|
|
block._title = /(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/; |
|
|
|
|
block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/; |
|
|
|
|
block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/; |
|
|
|
|
block.def = edit(block.def) |
|
|
|
|
.replace('label', block._label) |
|
|
|
|
.replace('title', block._title) |
|
|
|
@ -649,23 +658,24 @@ block.list = edit(block.list) |
|
|
|
|
.replace('def', '\\n+(?=' + block.def.source + ')') |
|
|
|
|
.getRegex(); |
|
|
|
|
|
|
|
|
|
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+(?!:|[^\\w\\s@]*@)\\b'; |
|
|
|
|
|
|
|
|
|
block.html = edit(block.html) |
|
|
|
|
.replace('comment', /<!--[\s\S]*?-->/) |
|
|
|
|
.replace('closed', /<(tag)[\s\S]+?<\/\1>/) |
|
|
|
|
.replace('closing', /<tag(?:"[^"]*"|'[^']*'|\s[^'"\/>\s]*)*?\/?>/) |
|
|
|
|
.replace(/tag/g, block._tag) |
|
|
|
|
block._tag = 'address|article|aside|base|basefont|blockquote|body|caption' |
|
|
|
|
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption' |
|
|
|
|
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe' |
|
|
|
|
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option' |
|
|
|
|
+ '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr' |
|
|
|
|
+ '|track|ul'; |
|
|
|
|
block._comment = /<!--(?!-?>)[\s\S]*?-->/; |
|
|
|
|
block.html = edit(block.html, 'i') |
|
|
|
|
.replace('comment', block._comment) |
|
|
|
|
.replace('tag', block._tag) |
|
|
|
|
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/) |
|
|
|
|
.getRegex(); |
|
|
|
|
|
|
|
|
|
block.paragraph = edit(block.paragraph) |
|
|
|
|
.replace('hr', block.hr) |
|
|
|
|
.replace('heading', block.heading) |
|
|
|
|
.replace('lheading', block.lheading) |
|
|
|
|
.replace('tag', '<' + block._tag) |
|
|
|
|
.replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
|
|
|
|
|
.getRegex(); |
|
|
|
|
|
|
|
|
|
block.blockquote = edit(block.blockquote) |
|
|
|
@ -699,8 +709,26 @@ block.gfm.paragraph = edit(block.paragraph) |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
block.tables = merge({}, block.gfm, { |
|
|
|
|
nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/, |
|
|
|
|
table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/ |
|
|
|
|
nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/, |
|
|
|
|
table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/ |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Pedantic grammar |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
block.pedantic = merge({}, block.normal, { |
|
|
|
|
html: edit( |
|
|
|
|
'^ *(?:comment *(?:\\n|\\s*$)' |
|
|
|
|
+ '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
|
|
|
|
|
+ '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))') |
|
|
|
|
.replace('comment', block._comment) |
|
|
|
|
.replace(/tag/g, '(?!(?:' |
|
|
|
|
+ '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+(?!:|[^\\w\\s@]*@)\\b') |
|
|
|
|
.getRegex(), |
|
|
|
|
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/ |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -709,11 +737,13 @@ block.tables = merge({}, block.gfm, { |
|
|
|
|
|
|
|
|
|
function Lexer(options) { |
|
|
|
|
this.tokens = []; |
|
|
|
|
this.tokens.links = {}; |
|
|
|
|
this.tokens.links = Object.create(null); |
|
|
|
|
this.options = options || marked.defaults; |
|
|
|
|
this.rules = block.normal; |
|
|
|
|
|
|
|
|
|
if (this.options.gfm) { |
|
|
|
|
if (this.options.pedantic) { |
|
|
|
|
this.rules = block.pedantic; |
|
|
|
|
} else if (this.options.gfm) { |
|
|
|
|
if (this.options.tables) { |
|
|
|
|
this.rules = block.tables; |
|
|
|
|
} else { |
|
|
|
@ -765,11 +795,16 @@ Lexer.prototype.token = function(src, top) { |
|
|
|
|
bull, |
|
|
|
|
b, |
|
|
|
|
item, |
|
|
|
|
listStart, |
|
|
|
|
listItems, |
|
|
|
|
t, |
|
|
|
|
space, |
|
|
|
|
i, |
|
|
|
|
tag, |
|
|
|
|
l, |
|
|
|
|
isordered; |
|
|
|
|
isordered, |
|
|
|
|
istask, |
|
|
|
|
ischecked; |
|
|
|
|
|
|
|
|
|
while (src) { |
|
|
|
|
// newline
|
|
|
|
@ -789,7 +824,7 @@ Lexer.prototype.token = function(src, top) { |
|
|
|
|
this$1.tokens.push({ |
|
|
|
|
type: 'code', |
|
|
|
|
text: !this$1.options.pedantic |
|
|
|
|
? cap.replace(/\n+$/, '') |
|
|
|
|
? rtrim(cap, '\n') |
|
|
|
|
: cap |
|
|
|
|
}); |
|
|
|
|
continue; |
|
|
|
@ -819,34 +854,36 @@ Lexer.prototype.token = function(src, top) { |
|
|
|
|
|
|
|
|
|
// table no leading pipe (gfm)
|
|
|
|
|
if (top && (cap = this$1.rules.nptable.exec(src))) { |
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
|
|
|
|
|
item = { |
|
|
|
|
type: 'table', |
|
|
|
|
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */), |
|
|
|
|
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')), |
|
|
|
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), |
|
|
|
|
cells: cap[3].replace(/\n$/, '').split('\n') |
|
|
|
|
cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : [] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < item.align.length; i++) { |
|
|
|
|
if (/^ *-+: *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'right'; |
|
|
|
|
} else if (/^ *:-+: *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'center'; |
|
|
|
|
} else if (/^ *:-+ *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'left'; |
|
|
|
|
} else { |
|
|
|
|
item.align[i] = null; |
|
|
|
|
if (item.header.length === item.align.length) { |
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
|
|
|
|
|
for (i = 0; i < item.align.length; i++) { |
|
|
|
|
if (/^ *-+: *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'right'; |
|
|
|
|
} else if (/^ *:-+: *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'center'; |
|
|
|
|
} else if (/^ *:-+ *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'left'; |
|
|
|
|
} else { |
|
|
|
|
item.align[i] = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (i = 0; i < item.cells.length; i++) { |
|
|
|
|
item.cells[i] = item.cells[i].split(/ *\| */); |
|
|
|
|
} |
|
|
|
|
for (i = 0; i < item.cells.length; i++) { |
|
|
|
|
item.cells[i] = splitCells(item.cells[i], item.header.length); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this$1.tokens.push(item); |
|
|
|
|
this$1.tokens.push(item); |
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// hr
|
|
|
|
@ -886,15 +923,19 @@ Lexer.prototype.token = function(src, top) { |
|
|
|
|
bull = cap[2]; |
|
|
|
|
isordered = bull.length > 1; |
|
|
|
|
|
|
|
|
|
this$1.tokens.push({ |
|
|
|
|
listStart = { |
|
|
|
|
type: 'list_start', |
|
|
|
|
ordered: isordered, |
|
|
|
|
start: isordered ? +bull : '' |
|
|
|
|
}); |
|
|
|
|
start: isordered ? +bull : '', |
|
|
|
|
loose: false |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
this$1.tokens.push(listStart); |
|
|
|
|
|
|
|
|
|
// Get each top-level item.
|
|
|
|
|
cap = cap[0].match(this$1.rules.item); |
|
|
|
|
|
|
|
|
|
listItems = []; |
|
|
|
|
next = false; |
|
|
|
|
l = cap.length; |
|
|
|
|
i = 0; |
|
|
|
@ -935,11 +976,27 @@ Lexer.prototype.token = function(src, top) { |
|
|
|
|
if (!loose) { loose = next; } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this$1.tokens.push({ |
|
|
|
|
type: loose |
|
|
|
|
? 'loose_item_start' |
|
|
|
|
: 'list_item_start' |
|
|
|
|
}); |
|
|
|
|
if (loose) { |
|
|
|
|
listStart.loose = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Check for task list items
|
|
|
|
|
istask = /^\[[ xX]\] /.test(item); |
|
|
|
|
ischecked = undefined; |
|
|
|
|
if (istask) { |
|
|
|
|
ischecked = item[1] !== ' '; |
|
|
|
|
item = item.replace(/^\[[ xX]\] +/, ''); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
t = { |
|
|
|
|
type: 'list_item_start', |
|
|
|
|
task: istask, |
|
|
|
|
checked: ischecked, |
|
|
|
|
loose: loose |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
listItems.push(t); |
|
|
|
|
this$1.tokens.push(t); |
|
|
|
|
|
|
|
|
|
// Recurse.
|
|
|
|
|
this$1.token(item, false); |
|
|
|
@ -949,6 +1006,14 @@ Lexer.prototype.token = function(src, top) { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (listStart.loose) { |
|
|
|
|
l = listItems.length; |
|
|
|
|
i = 0; |
|
|
|
|
for (; i < l; i++) { |
|
|
|
|
listItems[i].loose = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this$1.tokens.push({ |
|
|
|
|
type: 'list_end' |
|
|
|
|
}); |
|
|
|
@ -974,7 +1039,7 @@ Lexer.prototype.token = function(src, top) { |
|
|
|
|
if (top && (cap = this$1.rules.def.exec(src))) { |
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
if (cap[3]) { cap[3] = cap[3].substring(1, cap[3].length - 1); } |
|
|
|
|
tag = cap[1].toLowerCase(); |
|
|
|
|
tag = cap[1].toLowerCase().replace(/\s+/g, ' '); |
|
|
|
|
if (!this$1.tokens.links[tag]) { |
|
|
|
|
this$1.tokens.links[tag] = { |
|
|
|
|
href: cap[2], |
|
|
|
@ -986,36 +1051,38 @@ Lexer.prototype.token = function(src, top) { |
|
|
|
|
|
|
|
|
|
// table (gfm)
|
|
|
|
|
if (top && (cap = this$1.rules.table.exec(src))) { |
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
|
|
|
|
|
item = { |
|
|
|
|
type: 'table', |
|
|
|
|
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */), |
|
|
|
|
header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')), |
|
|
|
|
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), |
|
|
|
|
cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') |
|
|
|
|
cells: cap[3] ? cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') : [] |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < item.align.length; i++) { |
|
|
|
|
if (/^ *-+: *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'right'; |
|
|
|
|
} else if (/^ *:-+: *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'center'; |
|
|
|
|
} else if (/^ *:-+ *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'left'; |
|
|
|
|
} else { |
|
|
|
|
item.align[i] = null; |
|
|
|
|
if (item.header.length === item.align.length) { |
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
|
|
|
|
|
for (i = 0; i < item.align.length; i++) { |
|
|
|
|
if (/^ *-+: *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'right'; |
|
|
|
|
} else if (/^ *:-+: *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'center'; |
|
|
|
|
} else if (/^ *:-+ *$/.test(item.align[i])) { |
|
|
|
|
item.align[i] = 'left'; |
|
|
|
|
} else { |
|
|
|
|
item.align[i] = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (i = 0; i < item.cells.length; i++) { |
|
|
|
|
item.cells[i] = item.cells[i] |
|
|
|
|
.replace(/^ *\| *| *\| *$/g, '') |
|
|
|
|
.split(/ *\| */); |
|
|
|
|
} |
|
|
|
|
for (i = 0; i < item.cells.length; i++) { |
|
|
|
|
item.cells[i] = splitCells( |
|
|
|
|
item.cells[i].replace(/^ *\| *| *\| *$/g, ''), |
|
|
|
|
item.header.length); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this$1.tokens.push(item); |
|
|
|
|
this$1.tokens.push(item); |
|
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// lheading
|
|
|
|
@ -1065,39 +1132,54 @@ Lexer.prototype.token = function(src, top) { |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
var inline = { |
|
|
|
|
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/, |
|
|
|
|
escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, |
|
|
|
|
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/, |
|
|
|
|
url: noop, |
|
|
|
|
tag: /^<!--[\s\S]*?-->|^<\/?[a-zA-Z0-9\-]+(?:"[^"]*"|'[^']*'|\s[^<'">\/\s]*)*?\/?>/, |
|
|
|
|
link: /^!?\[(inside)\]\(href\)/, |
|
|
|
|
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/, |
|
|
|
|
nolink: /^!?\[((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\]/, |
|
|
|
|
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/, |
|
|
|
|
em: /^_([^\s_](?:[^_]|__)+?[^\s_])_\b|^\*((?:\*\*|[^*])+?)\*(?!\*)/, |
|
|
|
|
code: /^(`+)\s*([\s\S]*?[^`]?)\s*\1(?!`)/, |
|
|
|
|
br: /^ {2,}\n(?!\s*$)/, |
|
|
|
|
tag: '^comment' |
|
|
|
|
+ '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
|
|
|
|
|
+ '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
|
|
|
|
|
+ '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
|
|
|
|
|
+ '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
|
|
|
|
|
+ '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
|
|
|
|
|
link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/, |
|
|
|
|
reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/, |
|
|
|
|
nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/, |
|
|
|
|
strong: /^__([^\s])__(?!_)|^\*\*([^\s])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/, |
|
|
|
|
em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_)|^_([^\s_][\s\S]*?[^\s])_(?!_)|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/, |
|
|
|
|
code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, |
|
|
|
|
br: /^( {2,}|\\)\n(?!\s*$)/, |
|
|
|
|
del: noop, |
|
|
|
|
text: /^[\s\S]+?(?=[\\<!\[`*]|\b_| {2,}\n|$)/ |
|
|
|
|
text: /^(`+|[^`])[\s\S]*?(?=[\\<!\[`*]|\b_| {2,}\n|$)/ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g; |
|
|
|
|
|
|
|
|
|
inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/; |
|
|
|
|
inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/; |
|
|
|
|
|
|
|
|
|
inline.autolink = edit(inline.autolink) |
|
|
|
|
.replace('scheme', inline._scheme) |
|
|
|
|
.replace('email', inline._email) |
|
|
|
|
.getRegex(); |
|
|
|
|
|
|
|
|
|
inline._inside = /(?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/; |
|
|
|
|
inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/; |
|
|
|
|
inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/; |
|
|
|
|
|
|
|
|
|
inline.tag = edit(inline.tag) |
|
|
|
|
.replace('comment', block._comment) |
|
|
|
|
.replace('attribute', inline._attribute) |
|
|
|
|
.getRegex(); |
|
|
|
|
|
|
|
|
|
inline._label = /(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|[^\[\]\\])*?/; |
|
|
|
|
inline._href = /\s*(<(?:\\[<>]?|[^\s<>\\])*>|(?:\\[()]?|\([^\s\x00-\x1f\\]*\)|[^\s\x00-\x1f()\\])*?)/; |
|
|
|
|
inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/; |
|
|
|
|
|
|
|
|
|
inline.link = edit(inline.link) |
|
|
|
|
.replace('inside', inline._inside) |
|
|
|
|
.replace('label', inline._label) |
|
|
|
|
.replace('href', inline._href) |
|
|
|
|
.replace('title', inline._title) |
|
|
|
|
.getRegex(); |
|
|
|
|
|
|
|
|
|
inline.reflink = edit(inline.reflink) |
|
|
|
|
.replace('inside', inline._inside) |
|
|
|
|
.replace('label', inline._label) |
|
|
|
|
.getRegex(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -1112,7 +1194,13 @@ inline.normal = merge({}, inline); |
|
|
|
|
|
|
|
|
|
inline.pedantic = merge({}, inline.normal, { |
|
|
|
|
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/, |
|
|
|
|
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/ |
|
|
|
|
em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/, |
|
|
|
|
link: edit(/^!?\[(label)\]\((.*?)\)/) |
|
|
|
|
.replace('label', inline._label) |
|
|
|
|
.getRegex(), |
|
|
|
|
reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/) |
|
|
|
|
.replace('label', inline._label) |
|
|
|
|
.getRegex() |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -1121,17 +1209,19 @@ inline.pedantic = merge({}, inline.normal, { |
|
|
|
|
|
|
|
|
|
inline.gfm = merge({}, inline.normal, { |
|
|
|
|
escape: edit(inline.escape).replace('])', '~|])').getRegex(), |
|
|
|
|
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/) |
|
|
|
|
.replace('email', inline._email) |
|
|
|
|
.getRegex(), |
|
|
|
|
_extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/, |
|
|
|
|
url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, |
|
|
|
|
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/, |
|
|
|
|
del: /^~~(?=\S)([\s\S]*?\S)~~/, |
|
|
|
|
del: /^~+(?=\S)([\s\S]*?\S)~+/, |
|
|
|
|
text: edit(inline.text) |
|
|
|
|
.replace(']|', '~]|') |
|
|
|
|
.replace('|', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|') |
|
|
|
|
.replace('|$', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|$') |
|
|
|
|
.getRegex() |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
inline.gfm.url = edit(inline.gfm.url) |
|
|
|
|
.replace('email', inline.gfm._extended_email) |
|
|
|
|
.getRegex(); |
|
|
|
|
/** |
|
|
|
|
* GFM + Line Breaks Inline Grammar |
|
|
|
|
*/ |
|
|
|
@ -1156,14 +1246,14 @@ function InlineLexer(links, options) { |
|
|
|
|
throw new Error('Tokens array requires a `links` property.'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.options.gfm) { |
|
|
|
|
if (this.options.pedantic) { |
|
|
|
|
this.rules = inline.pedantic; |
|
|
|
|
} else if (this.options.gfm) { |
|
|
|
|
if (this.options.breaks) { |
|
|
|
|
this.rules = inline.breaks; |
|
|
|
|
} else { |
|
|
|
|
this.rules = inline.gfm; |
|
|
|
|
} |
|
|
|
|
} else if (this.options.pedantic) { |
|
|
|
|
this.rules = inline.pedantic; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1193,7 +1283,9 @@ InlineLexer.prototype.output = function(src) { |
|
|
|
|
link, |
|
|
|
|
text, |
|
|
|
|
href, |
|
|
|
|
cap; |
|
|
|
|
title, |
|
|
|
|
cap, |
|
|
|
|
prevCapZero; |
|
|
|
|
|
|
|
|
|
while (src) { |
|
|
|
|
// escape
|
|
|
|
@ -1219,12 +1311,15 @@ InlineLexer.prototype.output = function(src) { |
|
|
|
|
|
|
|
|
|
// url (gfm)
|
|
|
|
|
if (!this$1.inLink && (cap = this$1.rules.url.exec(src))) { |
|
|
|
|
cap[0] = this$1.rules._backpedal.exec(cap[0])[0]; |
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
if (cap[2] === '@') { |
|
|
|
|
text = escape(cap[0]); |
|
|
|
|
href = 'mailto:' + text; |
|
|
|
|
} else { |
|
|
|
|
// do extended autolink path validation
|
|
|
|
|
do { |
|
|
|
|
prevCapZero = cap[0]; |
|
|
|
|
cap[0] = this$1.rules._backpedal.exec(cap[0])[0]; |
|
|
|
|
} while (prevCapZero !== cap[0]); |
|
|
|
|
text = escape(cap[0]); |
|
|
|
|
if (cap[1] === 'www.') { |
|
|
|
|
href = 'http://' + text; |
|
|
|
@ -1232,6 +1327,7 @@ InlineLexer.prototype.output = function(src) { |
|
|
|
|
href = text; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
out += this$1.renderer.link(href, null, text); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
@ -1243,6 +1339,12 @@ InlineLexer.prototype.output = function(src) { |
|
|
|
|
} else if (this$1.inLink && /^<\/a>/i.test(cap[0])) { |
|
|
|
|
this$1.inLink = false; |
|
|
|
|
} |
|
|
|
|
if (!this$1.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) { |
|
|
|
|
this$1.inRawBlock = true; |
|
|
|
|
} else if (this$1.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) { |
|
|
|
|
this$1.inRawBlock = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
out += this$1.options.sanitize |
|
|
|
|
? this$1.options.sanitizer |
|
|
|
@ -1256,9 +1358,23 @@ InlineLexer.prototype.output = function(src) { |
|
|
|
|
if (cap = this$1.rules.link.exec(src)) { |
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
this$1.inLink = true; |
|
|
|
|
href = cap[2]; |
|
|
|
|
if (this$1.options.pedantic) { |
|
|
|
|
link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href); |
|
|
|
|
|
|
|
|
|
if (link) { |
|
|
|
|
href = link[1]; |
|
|
|
|
title = link[3]; |
|
|
|
|
} else { |
|
|
|
|
title = ''; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
title = cap[3] ? cap[3].slice(1, -1) : ''; |
|
|
|
|
} |
|
|
|
|
href = href.trim().replace(/^<([\s\S]*)>$/, '$1'); |
|
|
|
|
out += this$1.outputLink(cap, { |
|
|
|
|
href: cap[2], |
|
|
|
|
title: cap[3] |
|
|
|
|
href: InlineLexer.escapes(href), |
|
|
|
|
title: InlineLexer.escapes(title) |
|
|
|
|
}); |
|
|
|
|
this$1.inLink = false; |
|
|
|
|
continue; |
|
|
|
@ -1284,14 +1400,14 @@ InlineLexer.prototype.output = function(src) { |
|
|
|
|
// strong
|
|
|
|
|
if (cap = this$1.rules.strong.exec(src)) { |
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
out += this$1.renderer.strong(this$1.output(cap[2] || cap[1])); |
|
|
|
|
out += this$1.renderer.strong(this$1.output(cap[4] || cap[3] || cap[2] || cap[1])); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// em
|
|
|
|
|
if (cap = this$1.rules.em.exec(src)) { |
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
out += this$1.renderer.em(this$1.output(cap[2] || cap[1])); |
|
|
|
|
out += this$1.renderer.em(this$1.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1])); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1319,7 +1435,11 @@ InlineLexer.prototype.output = function(src) { |
|
|
|
|
// text
|
|
|
|
|
if (cap = this$1.rules.text.exec(src)) { |
|
|
|
|
src = src.substring(cap[0].length); |
|
|
|
|
out += this$1.renderer.text(escape(this$1.smartypants(cap[0]))); |
|
|
|
|
if (this$1.inRawBlock) { |
|
|
|
|
out += this$1.renderer.text(cap[0]); |
|
|
|
|
} else { |
|
|
|
|
out += this$1.renderer.text(escape(this$1.smartypants(cap[0]))); |
|
|
|
|
} |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1331,12 +1451,16 @@ InlineLexer.prototype.output = function(src) { |
|
|
|
|
return out; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
InlineLexer.escapes = function(text) { |
|
|
|
|
return text ? text.replace(InlineLexer.rules._escapes, '$1') : text; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Compile Link |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
InlineLexer.prototype.outputLink = function(cap, link) { |
|
|
|
|
var href = escape(link.href), |
|
|
|
|
var href = link.href, |
|
|
|
|
title = link.title ? escape(link.title) : null; |
|
|
|
|
|
|
|
|
|
return cap[0].charAt(0) !== '!' |
|
|
|
@ -1394,7 +1518,7 @@ InlineLexer.prototype.mangle = function(text) { |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
function Renderer(options) { |
|
|
|
|
this.options = options || {}; |
|
|
|
|
this.options = options || marked.defaults; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Renderer.prototype.code = function(code, lang, escaped) { |
|
|
|
@ -1409,7 +1533,7 @@ Renderer.prototype.code = function(code, lang, escaped) { |
|
|
|
|
if (!lang) { |
|
|
|
|
return '<pre><code>' |
|
|
|
|
+ (escaped ? code : escape(code, true)) |
|
|
|
|
+ '\n</code></pre>'; |
|
|
|
|
+ '</code></pre>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return '<pre><code class="' |
|
|
|
@ -1417,7 +1541,7 @@ Renderer.prototype.code = function(code, lang, escaped) { |
|
|
|
|
+ escape(lang, true) |
|
|
|
|
+ '">' |
|
|
|
|
+ (escaped ? code : escape(code, true)) |
|
|
|
|
+ '\n</code></pre>\n'; |
|
|
|
|
+ '</code></pre>\n'; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Renderer.prototype.blockquote = function(quote) { |
|
|
|
@ -1429,16 +1553,20 @@ Renderer.prototype.html = function(html) { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Renderer.prototype.heading = function(text, level, raw) { |
|
|
|
|
return '<h' |
|
|
|
|
+ level |
|
|
|
|
+ ' id="' |
|
|
|
|
+ this.options.headerPrefix |
|
|
|
|
+ raw.toLowerCase().replace(/[^\w]+/g, '-') |
|
|
|
|
+ '">' |
|
|
|
|
+ text |
|
|
|
|
+ '</h' |
|
|
|
|
+ level |
|
|
|
|
+ '>\n'; |
|
|
|
|
if (this.options.headerIds) { |
|
|
|
|
return '<h' |
|
|
|
|
+ level |
|
|
|
|
+ ' id="' |
|
|
|
|
+ this.options.headerPrefix |
|
|
|
|
+ raw.toLowerCase().replace(/[^\w]+/g, '-') |
|
|
|
|
+ '">' |
|
|
|
|
+ text |
|
|
|
|
+ '</h' |
|
|
|
|
+ level |
|
|
|
|
+ '>\n'; |
|
|
|
|
} |
|
|
|
|
// ignore IDs
|
|
|
|
|
return '<h' + level + '>' + text + '</h' + level + '>\n'; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Renderer.prototype.hr = function() { |
|
|
|
@ -1455,18 +1583,26 @@ Renderer.prototype.listitem = function(text) { |
|
|
|
|
return '<li>' + text + '</li>\n'; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Renderer.prototype.checkbox = function(checked) { |
|
|
|
|
return '<input ' |
|
|
|
|
+ (checked ? 'checked="" ' : '') |
|
|
|
|
+ 'disabled="" type="checkbox"' |
|
|
|
|
+ (this.options.xhtml ? ' /' : '') |
|
|
|
|
+ '> '; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Renderer.prototype.paragraph = function(text) { |
|
|
|
|
return '<p>' + text + '</p>\n'; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Renderer.prototype.table = function(header, body) { |
|
|
|
|
if (body) { body = '<tbody>' + body + '</tbody>'; } |
|
|
|
|
|
|
|
|
|
return '<table>\n' |
|
|
|
|
+ '<thead>\n' |
|
|
|
|
+ header |
|
|
|
|
+ '</thead>\n' |
|
|
|
|
+ '<tbody>\n' |
|
|
|
|
+ body |
|
|
|
|
+ '</tbody>\n' |
|
|
|
|
+ '</table>\n'; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -1477,7 +1613,7 @@ Renderer.prototype.tablerow = function(content) { |
|
|
|
|
Renderer.prototype.tablecell = function(content, flags) { |
|
|
|
|
var type = flags.header ? 'th' : 'td'; |
|
|
|
|
var tag = flags.align |
|
|
|
|
? '<' + type + ' style="text-align:' + flags.align + '">' |
|
|
|
|
? '<' + type + ' align="' + flags.align + '">' |
|
|
|
|
: '<' + type + '>'; |
|
|
|
|
return tag + content + '</' + type + '>\n'; |
|
|
|
|
}; |
|
|
|
@ -1519,7 +1655,12 @@ Renderer.prototype.link = function(href, title, text) { |
|
|
|
|
if (this.options.baseUrl && !originIndependentUrl.test(href)) { |
|
|
|
|
href = resolveUrl(this.options.baseUrl, href); |
|
|
|
|
} |
|
|
|
|
var out = '<a href="' + href + '"'; |
|
|
|
|
try { |
|
|
|
|
href = encodeURI(href).replace(/%25/g, '%'); |
|
|
|
|
} catch (e) { |
|
|
|
|
return text; |
|
|
|
|
} |
|
|
|
|
var out = '<a href="' + escape(href) + '"'; |
|
|
|
|
if (title) { |
|
|
|
|
out += ' title="' + title + '"'; |
|
|
|
|
} |
|
|
|
@ -1726,29 +1867,23 @@ Parser.prototype.tok = function() { |
|
|
|
|
} |
|
|
|
|
case 'list_item_start': { |
|
|
|
|
body = ''; |
|
|
|
|
var loose = this.token.loose; |
|
|
|
|
|
|
|
|
|
while (this.next().type !== 'list_item_end') { |
|
|
|
|
body += this$1.token.type === 'text' |
|
|
|
|
? this$1.parseText() |
|
|
|
|
: this$1.tok(); |
|
|
|
|
if (this.token.task) { |
|
|
|
|
body += this.renderer.checkbox(this.token.checked); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return this.renderer.listitem(body); |
|
|
|
|
} |
|
|
|
|
case 'loose_item_start': { |
|
|
|
|
body = ''; |
|
|
|
|
|
|
|
|
|
while (this.next().type !== 'list_item_end') { |
|
|
|
|
body += this$1.tok(); |
|
|
|
|
body += !loose && this$1.token.type === 'text' |
|
|
|
|
? this$1.parseText() |
|
|
|
|
: this$1.tok(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return this.renderer.listitem(body); |
|
|
|
|
} |
|
|
|
|
case 'html': { |
|
|
|
|
var html = !this.token.pre && !this.options.pedantic |
|
|
|
|
? this.inline.output(this.token.text) |
|
|
|
|
: this.token.text; |
|
|
|
|
return this.renderer.html(html); |
|
|
|
|
// TODO parse inline content if parameter markdown=1
|
|
|
|
|
return this.renderer.html(this.token.text); |
|
|
|
|
} |
|
|
|
|
case 'paragraph': { |
|
|
|
|
return this.renderer.paragraph(this.inline.output(this.token.text)); |
|
|
|
@ -1764,14 +1899,32 @@ Parser.prototype.tok = function() { |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
function escape(html, encode) { |
|
|
|
|
return html |
|
|
|
|
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&') |
|
|
|
|
.replace(/</g, '<') |
|
|
|
|
.replace(/>/g, '>') |
|
|
|
|
.replace(/"/g, '"') |
|
|
|
|
.replace(/'/g, '''); |
|
|
|
|
if (encode) { |
|
|
|
|
if (escape.escapeTest.test(html)) { |
|
|
|
|
return html.replace(escape.escapeReplace, function (ch) { return escape.replacements[ch] }); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (escape.escapeTestNoEncode.test(html)) { |
|
|
|
|
return html.replace(escape.escapeReplaceNoEncode, function (ch) { return escape.replacements[ch] }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return html; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
escape.escapeTest = /[&<>"']/; |
|
|
|
|
escape.escapeReplace = /[&<>"']/g; |
|
|
|
|
escape.replacements = { |
|
|
|
|
'&': '&', |
|
|
|
|
'<': '<', |
|
|
|
|
'>': '>', |
|
|
|
|
'"': '"', |
|
|
|
|
"'": ''' |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/; |
|
|
|
|
escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g; |
|
|
|
|
|
|
|
|
|
function unescape(html) { |
|
|
|
|
// explicitly match decimal, hex, and named HTML entities
|
|
|
|
|
return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) { |
|
|
|
@ -1787,7 +1940,7 @@ function unescape(html) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function edit(regex, opt) { |
|
|
|
|
regex = regex.source; |
|
|
|
|
regex = regex.source || regex; |
|
|
|
|
opt = opt || ''; |
|
|
|
|
return { |
|
|
|
|
replace: function(name, val) { |
|
|
|
@ -1810,7 +1963,7 @@ function resolveUrl(base, href) { |
|
|
|
|
if (/^[^:]+:\/*[^/]*$/.test(base)) { |
|
|
|
|
baseUrls[' ' + base] = base + '/'; |
|
|
|
|
} else { |
|
|
|
|
baseUrls[' ' + base] = base.replace(/[^/]*$/, ''); |
|
|
|
|
baseUrls[' ' + base] = rtrim(base, '/', true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
base = baseUrls[' ' + base]; |
|
|
|
@ -1848,6 +2001,64 @@ function merge(obj) { |
|
|
|
|
return obj; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function splitCells(tableRow, count) { |
|
|
|
|
// ensure that every cell-delimiting pipe has a space
|
|
|
|
|
// before it to distinguish it from an escaped pipe
|
|
|
|
|
var row = tableRow.replace(/\|/g, function (match, offset, str) { |
|
|
|
|
var escaped = false, |
|
|
|
|
curr = offset; |
|
|
|
|
while (--curr >= 0 && str[curr] === '\\') { escaped = !escaped; } |
|
|
|
|
if (escaped) { |
|
|
|
|
// odd number of slashes means | is escaped
|
|
|
|
|
// so we leave it alone
|
|
|
|
|
return '|'; |
|
|
|
|
} else { |
|
|
|
|
// add space before unescaped |
|
|
|
|
|
return ' |'; |
|
|
|
|
} |
|
|
|
|
}), |
|
|
|
|
cells = row.split(/ \|/), |
|
|
|
|
i = 0; |
|
|
|
|
|
|
|
|
|
if (cells.length > count) { |
|
|
|
|
cells.splice(count); |
|
|
|
|
} else { |
|
|
|
|
while (cells.length < count) { cells.push(''); } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (; i < cells.length; i++) { |
|
|
|
|
// leading or trailing whitespace is ignored per the gfm spec
|
|
|
|
|
cells[i] = cells[i].trim().replace(/\\\|/g, '|'); |
|
|
|
|
} |
|
|
|
|
return cells; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
|
|
|
|
|
// /c*$/ is vulnerable to REDOS.
|
|
|
|
|
// invert: Remove suffix of non-c chars instead. Default falsey.
|
|
|
|
|
function rtrim(str, c, invert) { |
|
|
|
|
if (str.length === 0) { |
|
|
|
|
return ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Length of suffix matching the invert condition.
|
|
|
|
|
var suffLen = 0; |
|
|
|
|
|
|
|
|
|
// Step left until we fail to match the invert condition.
|
|
|
|
|
while (suffLen < str.length) { |
|
|
|
|
var currChar = str.charAt(str.length - suffLen - 1); |
|
|
|
|
if (currChar === c && !invert) { |
|
|
|
|
suffLen++; |
|
|
|
|
} else if (currChar !== c && invert) { |
|
|
|
|
suffLen++; |
|
|
|
|
} else { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return str.substr(0, str.length - suffLen); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Marked |
|
|
|
|
*/ |
|
|
|
@ -1955,25 +2166,30 @@ marked.setOptions = function(opt) { |
|
|
|
|
return marked; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
marked.defaults = { |
|
|
|
|
gfm: true, |
|
|
|
|
tables: true, |
|
|
|
|
breaks: false, |
|
|
|
|
pedantic: false, |
|
|
|
|
sanitize: false, |
|
|
|
|
sanitizer: null, |
|
|
|
|
mangle: true, |
|
|
|
|
smartLists: false, |
|
|
|
|
silent: false, |
|
|
|
|
highlight: null, |
|
|
|
|
langPrefix: 'lang-', |
|
|
|
|
smartypants: false, |
|
|
|
|
headerPrefix: '', |
|
|
|
|
renderer: new Renderer(), |
|
|
|
|
xhtml: false, |
|
|
|
|
baseUrl: null |
|
|
|
|
marked.getDefaults = function () { |
|
|
|
|
return { |
|
|
|
|
baseUrl: null, |
|
|
|
|
breaks: false, |
|
|
|
|
gfm: true, |
|
|
|
|
headerIds: true, |
|
|
|
|
headerPrefix: '', |
|
|
|
|
highlight: null, |
|
|
|
|
langPrefix: 'language-', |
|
|
|
|
mangle: true, |
|
|
|
|
pedantic: false, |
|
|
|
|
renderer: new Renderer(), |
|
|
|
|
sanitize: false, |
|
|
|
|
sanitizer: null, |
|
|
|
|
silent: false, |
|
|
|
|
smartLists: false, |
|
|
|
|
smartypants: false, |
|
|
|
|
tables: true, |
|
|
|
|
xhtml: false |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
marked.defaults = marked.getDefaults(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Expose |
|
|
|
|
*/ |
|
|
|
@ -4844,7 +5060,7 @@ initGlobalAPI(); |
|
|
|
|
/** |
|
|
|
|
* Version |
|
|
|
|
*/ |
|
|
|
|
Docsify.version = '4.8.2'; |
|
|
|
|
Docsify.version = '4.8.3'; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Run Docsify |
|
|
|
|