[build] 4.8.3

This commit is contained in:
qingwei.li 2018-11-01 19:09:50 +08:00
commit 58b130996e
5 changed files with 386 additions and 170 deletions

View file

@ -1,6 +1,6 @@
![logo](_media/icon.svg) ![logo](_media/icon.svg)
# docsify <small>4.8.2</small> # docsify <small>4.8.3</small>
> A magical documentation site generator. > A magical documentation site generator.

View file

@ -608,7 +608,7 @@ function createCommonjsModule(fn, module) {
var marked = createCommonjsModule(function (module, exports) { var marked = createCommonjsModule(function (module, exports) {
/** /**
* marked - a markdown parser * 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 * https://github.com/markedjs/marked
*/ */
@ -618,20 +618,29 @@ var block = {
code: /^( {4}[^\n]+\n*)+/, code: /^( {4}[^\n]+\n*)+/,
fences: noop, fences: noop,
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/, hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/, heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
nptable: noop, nptable: noop,
blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/, blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/, 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+|$)/, def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
table: noop, table: noop,
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/, 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]+/ text: /^[^\n]+/
}; };
block._label = /(?:\\[\[\]]|[^\[\]])+/; block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
block._title = /(?:"(?:\\"|[^"]|"[^"\n]*")*"|'\n?(?:[^'\n]+\n?)*'|\([^()]*\))/; block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
block.def = edit(block.def) block.def = edit(block.def)
.replace('label', block._label) .replace('label', block._label)
.replace('title', block._title) .replace('title', block._title)
@ -649,23 +658,24 @@ block.list = edit(block.list)
.replace('def', '\\n+(?=' + block.def.source + ')') .replace('def', '\\n+(?=' + block.def.source + ')')
.getRegex(); .getRegex();
block._tag = '(?!(?:' block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
+ 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code' + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
+ '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo' + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
+ '|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b'; + '|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'
block.html = edit(block.html) + '|track|ul';
.replace('comment', /<!--[\s\S]*?-->/) block._comment = /<!--(?!-?>)[\s\S]*?-->/;
.replace('closed', /<(tag)[\s\S]+?<\/\1>/) block.html = edit(block.html, 'i')
.replace('closing', /<tag(?:"[^"]*"|'[^']*'|\s[^'"\/>\s]*)*?\/?>/) .replace('comment', block._comment)
.replace(/tag/g, block._tag) .replace('tag', block._tag)
.replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
.getRegex(); .getRegex();
block.paragraph = edit(block.paragraph) block.paragraph = edit(block.paragraph)
.replace('hr', block.hr) .replace('hr', block.hr)
.replace('heading', block.heading) .replace('heading', block.heading)
.replace('lheading', block.lheading) .replace('lheading', block.lheading)
.replace('tag', '<' + block._tag) .replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
.getRegex(); .getRegex();
block.blockquote = edit(block.blockquote) block.blockquote = edit(block.blockquote)
@ -699,8 +709,26 @@ block.gfm.paragraph = edit(block.paragraph)
*/ */
block.tables = merge({}, block.gfm, { block.tables = merge({}, block.gfm, {
nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/, nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
table: /^ *\|(.+)\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) { function Lexer(options) {
this.tokens = []; this.tokens = [];
this.tokens.links = {}; this.tokens.links = Object.create(null);
this.options = options || marked.defaults; this.options = options || marked.defaults;
this.rules = block.normal; 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) { if (this.options.tables) {
this.rules = block.tables; this.rules = block.tables;
} else { } else {
@ -765,11 +795,16 @@ Lexer.prototype.token = function(src, top) {
bull, bull,
b, b,
item, item,
listStart,
listItems,
t,
space, space,
i, i,
tag, tag,
l, l,
isordered; isordered,
istask,
ischecked;
while (src) { while (src) {
// newline // newline
@ -789,7 +824,7 @@ Lexer.prototype.token = function(src, top) {
this$1.tokens.push({ this$1.tokens.push({
type: 'code', type: 'code',
text: !this$1.options.pedantic text: !this$1.options.pedantic
? cap.replace(/\n+$/, '') ? rtrim(cap, '\n')
: cap : cap
}); });
continue; continue;
@ -819,15 +854,16 @@ Lexer.prototype.token = function(src, top) {
// table no leading pipe (gfm) // table no leading pipe (gfm)
if (top && (cap = this$1.rules.nptable.exec(src))) { if (top && (cap = this$1.rules.nptable.exec(src))) {
src = src.substring(cap[0].length);
item = { item = {
type: 'table', type: 'table',
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */), header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
cells: cap[3].replace(/\n$/, '').split('\n') cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
}; };
if (item.header.length === item.align.length) {
src = src.substring(cap[0].length);
for (i = 0; i < item.align.length; i++) { for (i = 0; i < item.align.length; i++) {
if (/^ *-+: *$/.test(item.align[i])) { if (/^ *-+: *$/.test(item.align[i])) {
item.align[i] = 'right'; item.align[i] = 'right';
@ -841,13 +877,14 @@ Lexer.prototype.token = function(src, top) {
} }
for (i = 0; i < item.cells.length; i++) { for (i = 0; i < item.cells.length; i++) {
item.cells[i] = item.cells[i].split(/ *\| */); item.cells[i] = splitCells(item.cells[i], item.header.length);
} }
this$1.tokens.push(item); this$1.tokens.push(item);
continue; continue;
} }
}
// hr // hr
if (cap = this$1.rules.hr.exec(src)) { if (cap = this$1.rules.hr.exec(src)) {
@ -886,15 +923,19 @@ Lexer.prototype.token = function(src, top) {
bull = cap[2]; bull = cap[2];
isordered = bull.length > 1; isordered = bull.length > 1;
this$1.tokens.push({ listStart = {
type: 'list_start', type: 'list_start',
ordered: isordered, ordered: isordered,
start: isordered ? +bull : '' start: isordered ? +bull : '',
}); loose: false
};
this$1.tokens.push(listStart);
// Get each top-level item. // Get each top-level item.
cap = cap[0].match(this$1.rules.item); cap = cap[0].match(this$1.rules.item);
listItems = [];
next = false; next = false;
l = cap.length; l = cap.length;
i = 0; i = 0;
@ -935,11 +976,27 @@ Lexer.prototype.token = function(src, top) {
if (!loose) { loose = next; } if (!loose) { loose = next; }
} }
this$1.tokens.push({ if (loose) {
type: loose listStart.loose = true;
? 'loose_item_start' }
: 'list_item_start'
}); // 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. // Recurse.
this$1.token(item, false); 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({ this$1.tokens.push({
type: 'list_end' type: 'list_end'
}); });
@ -974,7 +1039,7 @@ Lexer.prototype.token = function(src, top) {
if (top && (cap = this$1.rules.def.exec(src))) { if (top && (cap = this$1.rules.def.exec(src))) {
src = src.substring(cap[0].length); src = src.substring(cap[0].length);
if (cap[3]) { cap[3] = cap[3].substring(1, cap[3].length - 1); } 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]) { if (!this$1.tokens.links[tag]) {
this$1.tokens.links[tag] = { this$1.tokens.links[tag] = {
href: cap[2], href: cap[2],
@ -986,15 +1051,16 @@ Lexer.prototype.token = function(src, top) {
// table (gfm) // table (gfm)
if (top && (cap = this$1.rules.table.exec(src))) { if (top && (cap = this$1.rules.table.exec(src))) {
src = src.substring(cap[0].length);
item = { item = {
type: 'table', type: 'table',
header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */), header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */), align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') cells: cap[3] ? cap[3].replace(/(?: *\| *)?\n$/, '').split('\n') : []
}; };
if (item.header.length === item.align.length) {
src = src.substring(cap[0].length);
for (i = 0; i < item.align.length; i++) { for (i = 0; i < item.align.length; i++) {
if (/^ *-+: *$/.test(item.align[i])) { if (/^ *-+: *$/.test(item.align[i])) {
item.align[i] = 'right'; item.align[i] = 'right';
@ -1008,15 +1074,16 @@ Lexer.prototype.token = function(src, top) {
} }
for (i = 0; i < item.cells.length; i++) { for (i = 0; i < item.cells.length; i++) {
item.cells[i] = item.cells[i] item.cells[i] = splitCells(
.replace(/^ *\| *| *\| *$/g, '') item.cells[i].replace(/^ *\| *| *\| *$/g, ''),
.split(/ *\| */); item.header.length);
} }
this$1.tokens.push(item); this$1.tokens.push(item);
continue; continue;
} }
}
// lheading // lheading
if (cap = this$1.rules.lheading.exec(src)) { if (cap = this$1.rules.lheading.exec(src)) {
@ -1065,39 +1132,54 @@ Lexer.prototype.token = function(src, top) {
*/ */
var inline = { var inline = {
escape: /^\\([\\`*{}\[\]()#+\-.!_>])/, escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/, autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
url: noop, url: noop,
tag: /^<!--[\s\S]*?-->|^<\/?[a-zA-Z0-9\-]+(?:"[^"]*"|'[^']*'|\s[^<'">\/\s]*)*?\/?>/, tag: '^comment'
link: /^!?\[(inside)\]\(href\)/, + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/, + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
nolink: /^!?\[((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\]/, + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/, + '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
em: /^_([^\s_](?:[^_]|__)+?[^\s_])_\b|^\*((?:\*\*|[^*])+?)\*(?!\*)/, + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
code: /^(`+)\s*([\s\S]*?[^`]?)\s*\1(?!`)/, link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,
br: /^ {2,}\n(?!\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, 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._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._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) inline.autolink = edit(inline.autolink)
.replace('scheme', inline._scheme) .replace('scheme', inline._scheme)
.replace('email', inline._email) .replace('email', inline._email)
.getRegex(); .getRegex();
inline._inside = /(?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]]|\](?=[^\[]*\]))*/; inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
inline._href = /\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) inline.link = edit(inline.link)
.replace('inside', inline._inside) .replace('label', inline._label)
.replace('href', inline._href) .replace('href', inline._href)
.replace('title', inline._title)
.getRegex(); .getRegex();
inline.reflink = edit(inline.reflink) inline.reflink = edit(inline.reflink)
.replace('inside', inline._inside) .replace('label', inline._label)
.getRegex(); .getRegex();
/** /**
@ -1112,7 +1194,13 @@ inline.normal = merge({}, inline);
inline.pedantic = merge({}, inline.normal, { inline.pedantic = merge({}, inline.normal, {
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/, 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, { inline.gfm = merge({}, inline.normal, {
escape: edit(inline.escape).replace('])', '~|])').getRegex(), escape: edit(inline.escape).replace('])', '~|])').getRegex(),
url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/) _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
.replace('email', inline._email) url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
.getRegex(),
_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/, _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
del: /^~~(?=\S)([\s\S]*?\S)~~/, del: /^~+(?=\S)([\s\S]*?\S)~+/,
text: edit(inline.text) text: edit(inline.text)
.replace(']|', '~]|') .replace(']|', '~]|')
.replace('|', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|') .replace('|$', '|https?://|ftp://|www\\.|[a-zA-Z0-9.!#$%&\'*+/=?^_`{\\|}~-]+@|$')
.getRegex() .getRegex()
}); });
inline.gfm.url = edit(inline.gfm.url)
.replace('email', inline.gfm._extended_email)
.getRegex();
/** /**
* GFM + Line Breaks Inline Grammar * GFM + Line Breaks Inline Grammar
*/ */
@ -1156,14 +1246,14 @@ function InlineLexer(links, options) {
throw new Error('Tokens array requires a `links` property.'); 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) { if (this.options.breaks) {
this.rules = inline.breaks; this.rules = inline.breaks;
} else { } else {
this.rules = inline.gfm; this.rules = inline.gfm;
} }
} else if (this.options.pedantic) {
this.rules = inline.pedantic;
} }
} }
@ -1193,7 +1283,9 @@ InlineLexer.prototype.output = function(src) {
link, link,
text, text,
href, href,
cap; title,
cap,
prevCapZero;
while (src) { while (src) {
// escape // escape
@ -1219,12 +1311,15 @@ InlineLexer.prototype.output = function(src) {
// url (gfm) // url (gfm)
if (!this$1.inLink && (cap = this$1.rules.url.exec(src))) { 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] === '@') { if (cap[2] === '@') {
text = escape(cap[0]); text = escape(cap[0]);
href = 'mailto:' + text; href = 'mailto:' + text;
} else { } 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]); text = escape(cap[0]);
if (cap[1] === 'www.') { if (cap[1] === 'www.') {
href = 'http://' + text; href = 'http://' + text;
@ -1232,6 +1327,7 @@ InlineLexer.prototype.output = function(src) {
href = text; href = text;
} }
} }
src = src.substring(cap[0].length);
out += this$1.renderer.link(href, null, text); out += this$1.renderer.link(href, null, text);
continue; continue;
} }
@ -1243,6 +1339,12 @@ InlineLexer.prototype.output = function(src) {
} else if (this$1.inLink && /^<\/a>/i.test(cap[0])) { } else if (this$1.inLink && /^<\/a>/i.test(cap[0])) {
this$1.inLink = false; 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); src = src.substring(cap[0].length);
out += this$1.options.sanitize out += this$1.options.sanitize
? this$1.options.sanitizer ? this$1.options.sanitizer
@ -1256,9 +1358,23 @@ InlineLexer.prototype.output = function(src) {
if (cap = this$1.rules.link.exec(src)) { if (cap = this$1.rules.link.exec(src)) {
src = src.substring(cap[0].length); src = src.substring(cap[0].length);
this$1.inLink = true; 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, { out += this$1.outputLink(cap, {
href: cap[2], href: InlineLexer.escapes(href),
title: cap[3] title: InlineLexer.escapes(title)
}); });
this$1.inLink = false; this$1.inLink = false;
continue; continue;
@ -1284,14 +1400,14 @@ InlineLexer.prototype.output = function(src) {
// strong // strong
if (cap = this$1.rules.strong.exec(src)) { if (cap = this$1.rules.strong.exec(src)) {
src = src.substring(cap[0].length); 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; continue;
} }
// em // em
if (cap = this$1.rules.em.exec(src)) { if (cap = this$1.rules.em.exec(src)) {
src = src.substring(cap[0].length); 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; continue;
} }
@ -1319,7 +1435,11 @@ InlineLexer.prototype.output = function(src) {
// text // text
if (cap = this$1.rules.text.exec(src)) { if (cap = this$1.rules.text.exec(src)) {
src = src.substring(cap[0].length); src = src.substring(cap[0].length);
if (this$1.inRawBlock) {
out += this$1.renderer.text(cap[0]);
} else {
out += this$1.renderer.text(escape(this$1.smartypants(cap[0]))); out += this$1.renderer.text(escape(this$1.smartypants(cap[0])));
}
continue; continue;
} }
@ -1331,12 +1451,16 @@ InlineLexer.prototype.output = function(src) {
return out; return out;
}; };
InlineLexer.escapes = function(text) {
return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
};
/** /**
* Compile Link * Compile Link
*/ */
InlineLexer.prototype.outputLink = function(cap, link) { InlineLexer.prototype.outputLink = function(cap, link) {
var href = escape(link.href), var href = link.href,
title = link.title ? escape(link.title) : null; title = link.title ? escape(link.title) : null;
return cap[0].charAt(0) !== '!' return cap[0].charAt(0) !== '!'
@ -1394,7 +1518,7 @@ InlineLexer.prototype.mangle = function(text) {
*/ */
function Renderer(options) { function Renderer(options) {
this.options = options || {}; this.options = options || marked.defaults;
} }
Renderer.prototype.code = function(code, lang, escaped) { Renderer.prototype.code = function(code, lang, escaped) {
@ -1409,7 +1533,7 @@ Renderer.prototype.code = function(code, lang, escaped) {
if (!lang) { if (!lang) {
return '<pre><code>' return '<pre><code>'
+ (escaped ? code : escape(code, true)) + (escaped ? code : escape(code, true))
+ '\n</code></pre>'; + '</code></pre>';
} }
return '<pre><code class="' return '<pre><code class="'
@ -1417,7 +1541,7 @@ Renderer.prototype.code = function(code, lang, escaped) {
+ escape(lang, true) + escape(lang, true)
+ '">' + '">'
+ (escaped ? code : escape(code, true)) + (escaped ? code : escape(code, true))
+ '\n</code></pre>\n'; + '</code></pre>\n';
}; };
Renderer.prototype.blockquote = function(quote) { Renderer.prototype.blockquote = function(quote) {
@ -1429,6 +1553,7 @@ Renderer.prototype.html = function(html) {
}; };
Renderer.prototype.heading = function(text, level, raw) { Renderer.prototype.heading = function(text, level, raw) {
if (this.options.headerIds) {
return '<h' return '<h'
+ level + level
+ ' id="' + ' id="'
@ -1439,6 +1564,9 @@ Renderer.prototype.heading = function(text, level, raw) {
+ '</h' + '</h'
+ level + level
+ '>\n'; + '>\n';
}
// ignore IDs
return '<h' + level + '>' + text + '</h' + level + '>\n';
}; };
Renderer.prototype.hr = function() { Renderer.prototype.hr = function() {
@ -1455,18 +1583,26 @@ Renderer.prototype.listitem = function(text) {
return '<li>' + text + '</li>\n'; 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) { Renderer.prototype.paragraph = function(text) {
return '<p>' + text + '</p>\n'; return '<p>' + text + '</p>\n';
}; };
Renderer.prototype.table = function(header, body) { Renderer.prototype.table = function(header, body) {
if (body) { body = '<tbody>' + body + '</tbody>'; }
return '<table>\n' return '<table>\n'
+ '<thead>\n' + '<thead>\n'
+ header + header
+ '</thead>\n' + '</thead>\n'
+ '<tbody>\n'
+ body + body
+ '</tbody>\n'
+ '</table>\n'; + '</table>\n';
}; };
@ -1477,7 +1613,7 @@ Renderer.prototype.tablerow = function(content) {
Renderer.prototype.tablecell = function(content, flags) { Renderer.prototype.tablecell = function(content, flags) {
var type = flags.header ? 'th' : 'td'; var type = flags.header ? 'th' : 'td';
var tag = flags.align var tag = flags.align
? '<' + type + ' style="text-align:' + flags.align + '">' ? '<' + type + ' align="' + flags.align + '">'
: '<' + type + '>'; : '<' + type + '>';
return tag + content + '</' + type + '>\n'; return tag + content + '</' + type + '>\n';
}; };
@ -1519,7 +1655,12 @@ Renderer.prototype.link = function(href, title, text) {
if (this.options.baseUrl && !originIndependentUrl.test(href)) { if (this.options.baseUrl && !originIndependentUrl.test(href)) {
href = resolveUrl(this.options.baseUrl, 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) { if (title) {
out += ' title="' + title + '"'; out += ' title="' + title + '"';
} }
@ -1726,29 +1867,23 @@ Parser.prototype.tok = function() {
} }
case 'list_item_start': { case 'list_item_start': {
body = ''; body = '';
var loose = this.token.loose;
if (this.token.task) {
body += this.renderer.checkbox(this.token.checked);
}
while (this.next().type !== 'list_item_end') { while (this.next().type !== 'list_item_end') {
body += this$1.token.type === 'text' body += !loose && this$1.token.type === 'text'
? this$1.parseText() ? this$1.parseText()
: this$1.tok(); : this$1.tok();
} }
return this.renderer.listitem(body); return this.renderer.listitem(body);
} }
case 'loose_item_start': {
body = '';
while (this.next().type !== 'list_item_end') {
body += this$1.tok();
}
return this.renderer.listitem(body);
}
case 'html': { case 'html': {
var html = !this.token.pre && !this.options.pedantic // TODO parse inline content if parameter markdown=1
? this.inline.output(this.token.text) return this.renderer.html(this.token.text);
: this.token.text;
return this.renderer.html(html);
} }
case 'paragraph': { case 'paragraph': {
return this.renderer.paragraph(this.inline.output(this.token.text)); return this.renderer.paragraph(this.inline.output(this.token.text));
@ -1764,13 +1899,31 @@ Parser.prototype.tok = function() {
*/ */
function escape(html, encode) { function escape(html, encode) {
return html if (encode) {
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;') if (escape.escapeTest.test(html)) {
.replace(/</g, '&lt;') return html.replace(escape.escapeReplace, function (ch) { return escape.replacements[ch] });
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
} }
} 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 = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;'
};
escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
function unescape(html) { function unescape(html) {
// explicitly match decimal, hex, and named HTML entities // explicitly match decimal, hex, and named HTML entities
@ -1787,7 +1940,7 @@ function unescape(html) {
} }
function edit(regex, opt) { function edit(regex, opt) {
regex = regex.source; regex = regex.source || regex;
opt = opt || ''; opt = opt || '';
return { return {
replace: function(name, val) { replace: function(name, val) {
@ -1810,7 +1963,7 @@ function resolveUrl(base, href) {
if (/^[^:]+:\/*[^/]*$/.test(base)) { if (/^[^:]+:\/*[^/]*$/.test(base)) {
baseUrls[' ' + base] = base + '/'; baseUrls[' ' + base] = base + '/';
} else { } else {
baseUrls[' ' + base] = base.replace(/[^/]*$/, ''); baseUrls[' ' + base] = rtrim(base, '/', true);
} }
} }
base = baseUrls[' ' + base]; base = baseUrls[' ' + base];
@ -1848,6 +2001,64 @@ function merge(obj) {
return 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 * Marked
*/ */
@ -1955,24 +2166,29 @@ marked.setOptions = function(opt) {
return marked; return marked;
}; };
marked.defaults = { marked.getDefaults = function () {
gfm: true, return {
tables: true, baseUrl: null,
breaks: false, breaks: false,
gfm: true,
headerIds: true,
headerPrefix: '',
highlight: null,
langPrefix: 'language-',
mangle: true,
pedantic: false, pedantic: false,
renderer: new Renderer(),
sanitize: false, sanitize: false,
sanitizer: null, sanitizer: null,
mangle: true,
smartLists: false,
silent: false, silent: false,
highlight: null, smartLists: false,
langPrefix: 'lang-',
smartypants: false, smartypants: false,
headerPrefix: '', tables: true,
renderer: new Renderer(), xhtml: false
xhtml: false,
baseUrl: null
}; };
};
marked.defaults = marked.getDefaults();
/** /**
* Expose * Expose
@ -4844,7 +5060,7 @@ initGlobalAPI();
/** /**
* Version * Version
*/ */
Docsify.version = '4.8.2'; Docsify.version = '4.8.3';
/** /**
* Run Docsify * Run Docsify

2
lib/docsify.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -37,5 +37,5 @@
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ=" "integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
} }
}, },
"version": "4.8.2" "version": "4.8.3"
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "docsify-server-renderer", "name": "docsify-server-renderer",
"version": "4.8.2", "version": "4.8.3",
"description": "docsify server renderer", "description": "docsify server renderer",
"author": { "author": {
"name": "qingwei-li", "name": "qingwei-li",