bump 1.7.0

This commit is contained in:
qingwei.li 2017-01-12 20:29:40 +08:00
commit 64093c0567
7 changed files with 80 additions and 64 deletions

View file

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

View file

@ -6,7 +6,7 @@
<link rel="icon" href="favicon.ico"> <link rel="icon" href="favicon.ico">
<meta name="description" content="A magical documentation generator."> <meta name="description" content="A magical documentation generator.">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css"> <link rel="stylesheet" href="/lib/themes/vue.css">
</head> </head>
<body> <body>
<nav> <nav>
@ -16,10 +16,11 @@
<div id="app"></div> <div id="app"></div>
</body> </body>
<script <script
src="//unpkg.com/docsify/lib/docsify.min.js" src="/lib/docsify.min.js"
data-max-level="4" data-max-level="4"
data-sidebar-toggle data-sidebar-toggle
data-coverpage data-coverpage
data-name="docsify"
data-router></script> data-router></script>
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script> <script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script> <script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>

View file

@ -216,7 +216,7 @@ function scrollActiveSidebar () {
li.classList.add('active'); li.classList.add('active');
active = li; active = li;
!hoveredOverSidebar && sticky.isSticky && active.scrollIntoView(); !hoveredOverSidebar && !sticky.noSticky && active.scrollIntoView(false);
} }
window.removeEventListener('scroll', highlight); window.removeEventListener('scroll', highlight);
@ -287,16 +287,16 @@ function scroll2Top (offset) {
} }
function sticky () { function sticky () {
var dom = document.querySelector('section.cover'); sticky.dom = sticky.dom || document.querySelector('section.cover');
var coverHeight = dom.getBoundingClientRect().height; var coverHeight = sticky.dom.getBoundingClientRect().height;
return (function () { return (function () {
if (window.pageYOffset >= coverHeight || dom.classList.contains('hidden')) { if (window.pageYOffset >= coverHeight || sticky.dom.classList.contains('hidden')) {
document.body.classList.add('sticky'); document.body.classList.add('sticky');
sticky.isSticky = true; sticky.noSticky = false;
} else { } else {
document.body.classList.remove('sticky'); document.body.classList.remove('sticky');
sticky.isSticky = false; sticky.noSticky = true;
} }
})() })()
} }
@ -1599,12 +1599,8 @@ marked.inlineLexer = InlineLexer.output;
marked.parse = marked; marked.parse = marked;
if (typeof module !== 'undefined' && typeof exports === 'object') { {
module.exports = marked; module.exports = marked;
} else if (typeof define === 'function' && define.amd) {
define(function() { return marked; });
} else {
this.marked = marked;
} }
}).call(function() { }).call(function() {
@ -1822,6 +1818,9 @@ var _ = _self.Prism = {
_.hooks.run('before-sanity-check', env); _.hooks.run('before-sanity-check', env);
if (!env.code || !env.grammar) { if (!env.code || !env.grammar) {
if (env.code) {
env.element.textContent = env.code;
}
_.hooks.run('complete', env); _.hooks.run('complete', env);
return; return;
} }
@ -1899,9 +1898,16 @@ var _ = _self.Prism = {
lookbehindLength = 0, lookbehindLength = 0,
alias = pattern.alias; alias = pattern.alias;
if (greedy && !pattern.pattern.global) {
// Without the global flag, lastIndex won't work
var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
}
pattern = pattern.pattern || pattern; pattern = pattern.pattern || pattern;
for (var i=0; i<strarr.length; i++) { // Don’t cache length as it changes during the loop // Don’t cache length as it changes during the loop
for (var i=0, pos = 0; i<strarr.length; pos += strarr[i].length, ++i) {
var str = strarr[i]; var str = strarr[i];
@ -1921,40 +1927,38 @@ var _ = _self.Prism = {
// Greedy patterns can override/remove up to two previously matched tokens // Greedy patterns can override/remove up to two previously matched tokens
if (!match && greedy && i != strarr.length - 1) { if (!match && greedy && i != strarr.length - 1) {
// Reconstruct the original text using the next two tokens pattern.lastIndex = pos;
var nextToken = strarr[i + 1].matchedStr || strarr[i + 1], match = pattern.exec(text);
combStr = str + nextToken;
if (i < strarr.length - 2) {
combStr += strarr[i + 2].matchedStr || strarr[i + 2];
}
// Try the pattern again on the reconstructed text
pattern.lastIndex = 0;
match = pattern.exec(combStr);
if (!match) { if (!match) {
continue; break;
} }
var from = match.index + (lookbehind ? match[1].length : 0); var from = match.index + (lookbehind ? match[1].length : 0),
// To be a valid candidate, the new match has to start inside of str to = match.index + match[0].length,
if (from >= str.length) { k = i,
p = pos;
for (var len = strarr.length; k < len && p < to; ++k) {
p += strarr[k].length;
// Move the index i to the element in strarr that is closest to from
if (from >= p) {
++i;
pos = p;
}
}
/*
* If strarr[i] is a Token, then the match starts inside another Token, which is invalid
* If strarr[k - 1] is greedy we are in conflict with another greedy pattern
*/
if (strarr[i] instanceof Token || strarr[k - 1].greedy) {
continue; continue;
} }
var to = match.index + match[0].length,
len = str.length + nextToken.length;
// Number of tokens to delete and replace with the new match // Number of tokens to delete and replace with the new match
delNum = 3; delNum = k - i;
str = text.slice(pos, p);
if (to <= len) { match.index -= pos;
if (strarr[i + 1].greedy) {
continue;
}
delNum = 2;
combStr = combStr.slice(0, len);
}
str = combStr;
} }
if (!match) { if (!match) {
@ -2023,7 +2027,7 @@ var Token = _.Token = function(type, content, alias, matchedStr, greedy) {
this.content = content; this.content = content;
this.alias = alias; this.alias = alias;
// Copy of the full string this token was created from // Copy of the full string this token was created from
this.matchedStr = matchedStr || null; this.length = (matchedStr || "").length|0;
this.greedy = !!greedy; this.greedy = !!greedy;
}; };
@ -2059,13 +2063,11 @@ Token.stringify = function(o, language, parent) {
_.hooks.run('wrap', env); _.hooks.run('wrap', env);
var attributes = ''; var attributes = Object.keys(env.attributes).map(function(name) {
return name + '="' + (env.attributes[name] || '').replace(/"/g, '&quot;') + '"';
}).join(' ');
for (var name in env.attributes) { return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + (attributes ? ' ' + attributes : '') + '>' + env.content + '</' + env.tag + '>';
attributes += (attributes ? ' ' : '') + name + '="' + (env.attributes[name] || '') + '"';
}
return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + '</' + env.tag + '>';
}; };
@ -2098,7 +2100,11 @@ if (script) {
if (document.addEventListener && !script.hasAttribute('data-manual')) { if (document.addEventListener && !script.hasAttribute('data-manual')) {
if(document.readyState !== "loading") { if(document.readyState !== "loading") {
requestAnimationFrame(_.highlightAll, 0); if (window.requestAnimationFrame) {
window.requestAnimationFrame(_.highlightAll);
} else {
window.setTimeout(_.highlightAll, 16);
}
} }
else { else {
document.addEventListener('DOMContentLoaded', _.highlightAll); document.addEventListener('DOMContentLoaded', _.highlightAll);
@ -2110,7 +2116,7 @@ return _self.Prism;
})(); })();
if (typeof module !== 'undefined' && module.exports) { if ('object' !== 'undefined' && module.exports) {
module.exports = Prism; module.exports = Prism;
} }
@ -2127,10 +2133,10 @@ if (typeof commonjsGlobal !== 'undefined') {
Prism.languages.markup = { Prism.languages.markup = {
'comment': /<!--[\w\W]*?-->/, 'comment': /<!--[\w\W]*?-->/,
'prolog': /<\?[\w\W]+?\?>/, 'prolog': /<\?[\w\W]+?\?>/,
'doctype': /<!DOCTYPE[\w\W]+?>/, 'doctype': /<!DOCTYPE[\w\W]+?>/i,
'cdata': /<!\[CDATA\[[\w\W]*?]]>/i, 'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
'tag': { 'tag': {
pattern: /<\/?(?!\d)[^\s>\/=.$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i, pattern: /<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,
inside: { inside: {
'tag': { 'tag': {
pattern: /^<\/?[^\s>\/]+/i, pattern: /^<\/?[^\s>\/]+/i,
@ -2187,7 +2193,10 @@ Prism.languages.css = {
}, },
'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i, 'url': /url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,
'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/, 'selector': /[^\{\}\s][^\{\};]*?(?=\s*\{)/,
'string': /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/, 'string': {
pattern: /("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,
greedy: true
},
'property': /(\b|\B)[\w-]+(?=\s*:)/i, 'property': /(\b|\B)[\w-]+(?=\s*:)/i,
'important': /\B!important\b/i, 'important': /\B!important\b/i,
'function': /[-a-z0-9]+(?=\()/i, 'function': /[-a-z0-9]+(?=\()/i,
@ -2268,7 +2277,8 @@ Prism.languages.javascript = Prism.languages.extend('clike', {
'keyword': /\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/, 'keyword': /\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,
'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/, 'number': /\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i 'function': /[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,
'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/
}); });
Prism.languages.insertBefore('javascript', 'keyword', { Prism.languages.insertBefore('javascript', 'keyword', {
@ -2576,12 +2586,15 @@ function renderSidebar (content) {
if (content) { if (content) {
html = markdown(content); html = markdown(content);
// find url tag
html = html.match(/<ul[^>]*>([\s\S]+)<\/ul>/g)[0];
} else if (OPTIONS$1.sidebar) { } else if (OPTIONS$1.sidebar) {
html = tree(OPTIONS$1.sidebar, '<ul>'); html = tree(OPTIONS$1.sidebar, '<ul>');
} else { } else {
html = tree(genTree(toc, OPTIONS$1.maxLevel), '<ul>'); html = tree(genTree(toc, OPTIONS$1.maxLevel), '<ul>');
} }
html = (OPTIONS$1.name ? ("<h1><a href=\"" + (OPTIONS$1.nameLink) + "\">" + (OPTIONS$1.name) + "</a></h1>") : '') + html;
renderTo('aside.sidebar', html); renderTo('aside.sidebar', html);
var target = activeLink('aside.sidebar', true); var target = activeLink('aside.sidebar', true);
if (target) { renderSubSidebar(target); } if (target) { renderSubSidebar(target); }
@ -2605,18 +2618,18 @@ function renderCover (content) {
return return
} }
renderCover.dom.classList.add('show'); renderCover.dom.classList.add('show');
if (renderCover.rendered) { return } if (renderCover.rendered) { return sticky() }
// render cover // render cover
var html = markdown(content); var html = markdown(content);
var match = html.trim().match('<p><img[^s]+src="(.*?)"[^a]+alt="(.*?)"></p>$'); var match = html.trim().match('<p><img[^s]+src="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$');
// render background // render background
if (match) { if (match) {
var coverEl = document.querySelector('section.cover'); var coverEl = document.querySelector('section.cover');
if (match[2] === 'color') { if (match[2] === 'color') {
coverEl.style.background = match[1]; coverEl.style.background = match[1] + (match[3] || '');
} else { } else {
coverEl.classList.add('has-mask'); coverEl.classList.add('has-mask');
coverEl.style.backgroundImage = "url(" + (match[1]) + ")"; coverEl.style.backgroundImage = "url(" + (match[1]) + ")";
@ -2680,7 +2693,9 @@ var OPTIONS = merge({
homepage: 'README.md', homepage: 'README.md',
coverpage: '', coverpage: '',
basePath: '', basePath: '',
auto2top: false auto2top: false,
name: '',
nameLink: window.location.pathname
}, window.$docsify); }, window.$docsify);
var script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop(); var script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop();

4
lib/docsify.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long