[build] 4.3.7

This commit is contained in:
qingwei.li 2017-10-02 13:27:15 +08:00
commit 7923608bc9
9 changed files with 1390 additions and 622 deletions

View file

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

View file

@ -22,7 +22,9 @@ var hyphenate = cached(function (str) {
/** /**
* Simple Object.assign polyfill * Simple Object.assign polyfill
*/ */
var merge = Object.assign || function (to) { var merge =
Object.assign ||
function (to) {
var arguments$1 = arguments; var arguments$1 = arguments;
var hasOwn = Object.prototype.hasOwnProperty; var hasOwn = Object.prototype.hasOwnProperty;
@ -59,7 +61,8 @@ function isFn (obj) {
return typeof obj === 'function' return typeof obj === 'function'
} }
var config = merge({ var config = merge(
{
el: '#app', el: '#app',
repo: '', repo: '',
maxLevel: 6, maxLevel: 6,
@ -82,10 +85,14 @@ var config = merge({
externalLinkTarget: '_blank', externalLinkTarget: '_blank',
routerMode: 'hash', routerMode: 'hash',
noCompileLinks: [] noCompileLinks: []
}, window.$docsify); },
window.$docsify
);
var script = document.currentScript || var script =
[].slice.call(document.getElementsByTagName('script')) document.currentScript ||
[].slice
.call(document.getElementsByTagName('script'))
.filter(function (n) { return /docsify\./.test(n.src); })[0]; .filter(function (n) { return /docsify\./.test(n.src); })[0];
if (script) { if (script) {
@ -119,7 +126,7 @@ function initLifecycle (vm) {
vm._hooks = {}; vm._hooks = {};
vm._lifecycle = {}; vm._lifecycle = {};
hooks.forEach(function (hook) { hooks.forEach(function (hook) {
var arr = vm._hooks[hook] = []; var arr = (vm._hooks[hook] = []);
vm._lifecycle[hook] = function (fn) { return arr.push(fn); }; vm._lifecycle[hook] = function (fn) { return arr.push(fn); };
}); });
} }
@ -267,13 +274,19 @@ var isMobile = inBrowser && document.body.clientWidth <= 600;
/** /**
* @see https://github.com/MoOx/pjax/blob/master/lib/is-supported.js * @see https://github.com/MoOx/pjax/blob/master/lib/is-supported.js
*/ */
var supportsPushState = inBrowser && (function () { var supportsPushState =
inBrowser &&
(function () {
// Borrowed wholesale from https://github.com/defunkt/jquery-pjax // Borrowed wholesale from https://github.com/defunkt/jquery-pjax
return window.history && return (
window.history &&
window.history.pushState && window.history.pushState &&
window.history.replaceState && window.history.replaceState &&
// pushState isn’t reliable on iOS until 5. // pushState isn’t reliable on iOS until 5.
!navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/) !navigator.userAgent.match(
/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/
)
)
})(); })();
/** /**
@ -293,14 +306,15 @@ function corner (data) {
'<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>' + '<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>' +
'<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>' + '<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>' +
'</svg>' + '</svg>' +
'</a>') '</a>'
)
} }
/** /**
* Render main content * Render main content
*/ */
function main (config) { function main (config) {
var aside = ( var aside =
'<button class="sidebar-toggle">' + '<button class="sidebar-toggle">' +
'<div class="sidebar-toggle-button">' + '<div class="sidebar-toggle-button">' +
'<span></span><span></span><span></span>' + '<span></span><span></span><span></span>' +
@ -311,13 +325,15 @@ function main (config) {
? ("<h1><a class=\"app-name-link\" data-nosearch>" + (config.name) + "</a></h1>") ? ("<h1><a class=\"app-name-link\" data-nosearch>" + (config.name) + "</a></h1>")
: '') + : '') +
'<div class="sidebar-nav"><!--sidebar--></div>' + '<div class="sidebar-nav"><!--sidebar--></div>' +
'</aside>'); '</aside>';
return (isMobile ? (aside + "<main>") : ("<main>" + aside)) + return (
(isMobile ? (aside + "<main>") : ("<main>" + aside)) +
'<section class="content">' + '<section class="content">' +
'<article class="markdown-section" id="main"><!--main--></article>' + '<article class="markdown-section" id="main"><!--main--></article>' +
'</section>' + '</section>' +
'</main>' '</main>'
)
} }
/** /**
@ -325,14 +341,17 @@ function main (config) {
*/ */
function cover () { function cover () {
var SL = ', 100%, 85%'; var SL = ', 100%, 85%';
var bgc = 'linear-gradient(to left bottom, ' + var bgc =
'linear-gradient(to left bottom, ' +
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 0%," + "hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 0%," +
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 100%)"; "hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 100%)";
return "<section class=\"cover\" style=\"background: " + bgc + "\">" + return (
"<section class=\"cover\" style=\"background: " + bgc + "\">" +
'<div class="cover-main"></div>' + '<div class="cover-main"></div>' +
'<div class="mask"></div>' + '<div class="mask"></div>' +
'</section>' '</section>'
)
} }
/** /**
@ -437,9 +456,12 @@ function get (url, hasBar) {
if ( error === void 0 ) error = noop; if ( error === void 0 ) error = noop;
if (hasBar) { if (hasBar) {
var id = setInterval(function (_) { return progressbar({ var id = setInterval(
function (_) { return progressbar({
step: Math.floor(Math.random() * 5 + 1) step: Math.floor(Math.random() * 5 + 1)
}); }, 500); }); },
500
);
on('progress', progressbar); on('progress', progressbar);
on('loadend', function (evt) { on('loadend', function (evt) {
@ -455,12 +477,12 @@ function get (url, hasBar) {
if (target.status >= 400) { if (target.status >= 400) {
error(target); error(target);
} else { } else {
var result = cache[url] = { var result = (cache[url] = {
content: target.response, content: target.response,
opt: { opt: {
updatedAt: xhr.getResponseHeader('last-modified') updatedAt: xhr.getResponseHeader('last-modified')
} }
}; });
success(result.content, result.opt); success(result.content, result.opt);
} }
@ -471,15 +493,15 @@ function get (url, hasBar) {
} }
function replaceVar (block, color) { function replaceVar (block, color) {
block.innerHTML = block.innerHTML block.innerHTML = block.innerHTML.replace(
.replace(/var\(\s*--theme-color.*?\)/g, color); /var\(\s*--theme-color.*?\)/g,
color
);
} }
var cssVars = function (color) { var cssVars = function (color) {
// Variable support // Variable support
if (window.CSS && if (window.CSS && window.CSS.supports && window.CSS.supports('(--v:red)')) { return }
window.CSS.supports &&
window.CSS.supports('(--v:red)')) { return }
var styleBlocks = findAll('style:not(.inserted),link');[].forEach.call(styleBlocks, function (block) { var styleBlocks = findAll('style:not(.inserted),link');[].forEach.call(styleBlocks, function (block) {
if (block.nodeName === 'STYLE') { if (block.nodeName === 'STYLE') {
@ -2675,7 +2697,10 @@ var re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g;
function slugify (str) { function slugify (str) {
if (typeof str !== 'string') { return '' } if (typeof str !== 'string') { return '' }
var slug = str.toLowerCase().trim() str = /^[\w\s]+$/g.test(str) ? str.toLowerCase() : str;
var slug = str
.trim()
.replace(/<[^>\d]+>/g, '') .replace(/<[^>\d]+>/g, '')
.replace(re, '') .replace(re, '')
.replace(/\s/g, '-') .replace(/\s/g, '-')
@ -2683,7 +2708,7 @@ function slugify (str) {
.replace(/^(\d)/, '_$1'); .replace(/^(\d)/, '_$1');
var count = cache$1[slug]; var count = cache$1[slug];
count = cache$1.hasOwnProperty(slug) ? (count + 1) : 0; count = cache$1.hasOwnProperty(slug) ? count + 1 : 0;
cache$1[slug] = count; cache$1[slug] = count;
if (count) { if (count) {
@ -2734,9 +2759,11 @@ function stringifyQuery (obj) {
var qs = []; var qs = [];
for (var key in obj) { for (var key in obj) {
qs.push(obj[key] qs.push(
obj[key]
? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase() ? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase()
: encode(key)); : encode(key)
);
} }
return qs.length ? ("?" + (qs.join('&'))) : '' return qs.length ? ("?" + (qs.join('&'))) : ''
@ -2756,15 +2783,11 @@ var isAbsolutePath = cached(function (path) {
var getParentPath = cached(function (path) { var getParentPath = cached(function (path) {
return /\/$/g.test(path) return /\/$/g.test(path)
? path ? path
: (path = path.match(/(\S*\/)[^\/]+$/)) : (path = path.match(/(\S*\/)[^\/]+$/)) ? path[1] : ''
? path[1]
: ''
}); });
var cleanPath = cached(function (path) { var cleanPath = cached(function (path) {
return path return path.replace(/^\/+/, '/').replace(/([^:])\/{2,}/g, '$1/')
.replace(/^\/+/, '/')
.replace(/([^:])\/{2,}/g, '$1/')
}); });
var cachedLinks = {}; var cachedLinks = {};
@ -2983,7 +3006,11 @@ function btn (el, router) {
var sidebar = getNode('.sidebar'); var sidebar = getNode('.sidebar');
isMobile && on(body, 'click', function (_) { return body.classList.contains('close') && toggle(); } isMobile &&
on(
body,
'click',
function (_) { return body.classList.contains('close') && toggle(); }
); );
on(sidebar, 'click', function (_) { return setTimeout((function (_) { return getAndActive(router, sidebar, true, true); }, 0)); } on(sidebar, 'click', function (_) { return setTimeout((function (_) { return getAndActive(router, sidebar, true, true); }, 0)); }
); );
@ -3016,9 +3043,7 @@ function getAndActive (router, el, isParent, autoTitle) {
var hash = router.toURL(router.getCurrentPath()); var hash = router.toURL(router.getCurrentPath());
var target; var target;
links links.sort(function (a, b) { return b.href.length - a.href.length; }).forEach(function (a) {
.sort(function (a, b) { return b.href.length - a.href.length; })
.forEach(function (a) {
var href = a.getAttribute('href'); var href = a.getAttribute('href');
var node = isParent ? a.parentNode : a; var node = isParent ? a.parentNode : a;
@ -3147,7 +3172,10 @@ function scrollTo (el) {
duration: 500 duration: 500
}) })
.on('tick', function (v) { return window.scrollTo(0, v); }) .on('tick', function (v) { return window.scrollTo(0, v); })
.on('done', function () { enableScrollEvent = true; scroller = null; }) .on('done', function () {
enableScrollEvent = true;
scroller = null;
})
.begin(); .begin();
} }
@ -3158,7 +3186,7 @@ function highlight () {
var wrap = find(sidebar, '.sidebar-nav'); var wrap = find(sidebar, '.sidebar-nav');
var active = find(sidebar, 'li.active'); var active = find(sidebar, 'li.active');
var doc = document.documentElement; var doc = document.documentElement;
var top = (doc && doc.scrollTop || document.body.scrollTop) - coverHeight; var top = ((doc && doc.scrollTop) || document.body.scrollTop) - coverHeight;
var last; var last;
for (var i = 0, len = anchors.length; i < len; i += 1) { for (var i = 0, len = anchors.length; i < len; i += 1) {
@ -3186,16 +3214,10 @@ function highlight () {
var height = sidebar.clientHeight; var height = sidebar.clientHeight;
var curOffset = 0; var curOffset = 0;
var cur = active.offsetTop + active.clientHeight + 40; var cur = active.offsetTop + active.clientHeight + 40;
var isInView = ( var isInView =
active.offsetTop >= wrap.scrollTop && active.offsetTop >= wrap.scrollTop && cur <= wrap.scrollTop + height;
cur <= wrap.scrollTop + height
);
var notThan = cur - curOffset < height; var notThan = cur - curOffset < height;
var top$1 = isInView var top$1 = isInView ? wrap.scrollTop : notThan ? curOffset : cur - height;
? wrap.scrollTop
: notThan
? curOffset
: cur - height;
sidebar.scrollTop = top$1; sidebar.scrollTop = top$1;
} }
@ -3225,8 +3247,12 @@ function scrollActiveSidebar (router) {
off('scroll', highlight); off('scroll', highlight);
on('scroll', highlight); on('scroll', highlight);
on(sidebar, 'mouseover', function () { hoverOver = true; }); on(sidebar, 'mouseover', function () {
on(sidebar, 'mouseleave', function () { hoverOver = false; }); hoverOver = true;
});
on(sidebar, 'mouseleave', function () {
hoverOver = false;
});
} }
function scrollIntoView (id) { function scrollIntoView (id) {
@ -3477,15 +3503,15 @@ function getAlias (path, alias, last) {
return re.test(path) && path !== last return re.test(path) && path !== last
})[0]; })[0];
return match ? getAlias(path.replace(cached$1[match], alias[match]), alias, path) : path return match
? getAlias(path.replace(cached$1[match], alias[match]), alias, path)
: path
} }
function getFileName (path) { function getFileName (path) {
return /\.(md|html)$/g.test(path) return /\.(md|html)$/g.test(path)
? path ? path
: /\/$/g.test(path) : /\/$/g.test(path) ? (path + "README.md") : (path + ".md")
? (path + "README.md")
: (path + ".md")
} }
var History = function History (config) { var History = function History (config) {
@ -3505,7 +3531,7 @@ History.prototype.getFile = function getFile (path, isRelative) {
path = config.alias ? getAlias(path, config.alias) : path; path = config.alias ? getAlias(path, config.alias) : path;
path = getFileName(path); path = getFileName(path);
path = path === '/README.md' ? (config.homepage || path) : path; path = path === '/README.md' ? config.homepage || path : path;
path = isAbsolutePath(path) ? path : getPath(base, path); path = isAbsolutePath(path) ? path : getPath(base, path);
if (isRelative) { if (isRelative) {
@ -3531,9 +3557,7 @@ History.prototype.toURL = function toURL () {};
function replaceHash (path) { function replaceHash (path) {
var i = location.href.indexOf('#'); var i = location.href.indexOf('#');
location.replace( location.replace(location.href.slice(0, i >= 0 ? i : 0) + '#' + path);
location.href.slice(0, i >= 0 ? i : 0) + '#' + path
);
} }
var replaceSlug = cached(function (path) { var replaceSlug = cached(function (path) {
@ -3554,9 +3578,7 @@ var HashHistory = (function (History$$1) {
var path = window.location.pathname || ''; var path = window.location.pathname || '';
var base = this.config.basePath; var base = this.config.basePath;
return /^(\/|https?:)/g.test(base) return /^(\/|https?:)/g.test(base) ? base : cleanPath(path + '/' + base)
? base
: cleanPath(path + '/' + base)
}; };
HashHistory.prototype.getCurrentPath = function getCurrentPath () { HashHistory.prototype.getCurrentPath = function getCurrentPath () {
@ -3651,9 +3673,7 @@ var HTML5History = (function (History$$1) {
if ( cb === void 0 ) cb = noop; if ( cb === void 0 ) cb = noop;
on('click', function (e) { on('click', function (e) {
var el = e.target.tagName === 'A' var el = e.target.tagName === 'A' ? e.target : e.target.parentNode;
? e.target
: e.target.parentNode;
if (el.tagName === 'A' && !/_blank/.test(el.target)) { if (el.tagName === 'A' && !/_blank/.test(el.target)) {
e.preventDefault(); e.preventDefault();
@ -3956,7 +3976,7 @@ initGlobalAPI();
/** /**
* Version * Version
*/ */
Docsify.version = '4.3.6'; Docsify.version = '4.3.7';
/** /**
* Run Docsify * Run Docsify

4
lib/docsify.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -32,26 +32,24 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* @namespace * @namespace
*/ */
var errors = []; var errors = [];
var reference_blocks = []; var reference_blocks = [];
var processing_time = 0; var processing_time = 0;
var regex$1 = var regex$1 = {
{ regLevel: new RegExp('^([\\s\\-]+)'),
"regLevel" : new RegExp("^([\\s\\-]+)"), invalidLine: new RegExp('^\\-\\-\\-|^\\.\\.\\.|^\\s*#.*|^\\s*$'),
"invalidLine" : new RegExp("^\\-\\-\\-|^\\.\\.\\.|^\\s*#.*|^\\s*$"), dashesString: new RegExp('^\\s*\\"([^\\"]*)\\"\\s*$'),
"dashesString" : new RegExp("^\\s*\\\"([^\\\"]*)\\\"\\s*$"), quotesString: new RegExp("^\\s*\\'([^\\']*)\\'\\s*$"),
"quotesString" : new RegExp("^\\s*\\\'([^\\\']*)\\\'\\s*$"), float: new RegExp('^[+-]?[0-9]+\\.[0-9]+(e[+-]?[0-9]+(\\.[0-9]+)?)?$'),
"float" : new RegExp("^[+-]?[0-9]+\\.[0-9]+(e[+-]?[0-9]+(\\.[0-9]+)?)?$"), integer: new RegExp('^[+-]?[0-9]+$'),
"integer" : new RegExp("^[+-]?[0-9]+$"), array: new RegExp('\\[\\s*(.*)\\s*\\]'),
"array" : new RegExp("\\[\\s*(.*)\\s*\\]"), map: new RegExp('\\{\\s*(.*)\\s*\\}'),
"map" : new RegExp("\\{\\s*(.*)\\s*\\}"), key_value: new RegExp('([a-z0-9_-][ a-z0-9_-]*):( .+)', 'i'),
"key_value" : new RegExp("([a-z0-9_-][ a-z0-9_-]*):( .+)", "i"), single_key_value: new RegExp('^([a-z0-9_-][ a-z0-9_-]*):( .+?)$', 'i'),
"single_key_value" : new RegExp("^([a-z0-9_-][ a-z0-9_-]*):( .+?)$", "i"), key: new RegExp('([a-z0-9_-][ a-z0-9_-]+):( .+)?', 'i'),
"key" : new RegExp("([a-z0-9_-][ a-z0-9_-]+):( .+)?", "i"), item: new RegExp('^-\\s+'),
"item" : new RegExp("^-\\s+"), trim: new RegExp('^\\s+|\\s+$'),
"trim" : new RegExp("^\\s+|\\s+$"), comment: new RegExp('([^\\\'\\"#]+([\\\'\\"][^\\\'\\"]*[\\\'\\"])*)*(#.*)?')
"comment" : new RegExp("([^\\\'\\\"#]+([\\\'\\\"][^\\\'\\\"]*[\\\'\\\"])*)*(#.*)?")
}; };
/** /**
@ -77,15 +75,16 @@ function Block(lvl) {
obj.parent = this; obj.parent = this;
++this.length; ++this.length;
} }
}; }
} }
function parser$1(str) { function parser$1(str) {
var regLevel = regex$1["regLevel"]; var regLevel = regex$1['regLevel'];
var invalidLine = regex$1["invalidLine"]; var invalidLine = regex$1['invalidLine'];
var lines = str.split("\n"); var lines = str.split('\n');
var m; var m;
var level = 0, curLevel = 0; var level = 0,
curLevel = 0;
var blocks = []; var blocks = [];
@ -93,7 +92,7 @@ function parser$1(str) {
var currentBlock = new Block(0); var currentBlock = new Block(0);
result.addChild(currentBlock); result.addChild(currentBlock);
var levels = []; var levels = [];
var line = ""; var line = '';
blocks.push(currentBlock); blocks.push(currentBlock);
levels.push(level); levels.push(level);
@ -102,13 +101,12 @@ function parser$1(str) {
line = lines[i]; line = lines[i];
if (line.match(invalidLine)) { if (line.match(invalidLine)) {
continue; continue
} }
if(m = regLevel.exec(line)) { if ((m = regLevel.exec(line))) {
level = m[1].length; level = m[1].length;
} else } else { level = 0; }
{ level = 0; }
if (level > curLevel) { if (level > curLevel) {
var oldBlock = currentBlock; var oldBlock = currentBlock;
@ -125,72 +123,72 @@ function parser$1(str) {
currentBlock = new Block(level); currentBlock = new Block(level);
blocks.push(currentBlock); blocks.push(currentBlock);
levels.push(level); levels.push(level);
if(blocks[k].parent!= null) if (blocks[k].parent != null) { blocks[k].parent.addChild(currentBlock); }
{ blocks[k].parent.addChild(currentBlock); }
added = true; added = true;
break; break
} }
} }
if (!added) { if (!added) {
errors.push("Error: Invalid indentation at line " + i + ": " + line); errors.push('Error: Invalid indentation at line ' + i + ': ' + line);
return; return
} }
} }
currentBlock.lines.push(line.replace(regex$1["trim"], "")); currentBlock.lines.push(line.replace(regex$1['trim'], ''));
curLevel = level; curLevel = level;
} }
return result; return result
} }
function processValue(val) { function processValue(val) {
val = val.replace(regex$1["trim"], ""); val = val.replace(regex$1['trim'], '');
var m = null; var m = null;
if (val == 'true') { if (val == 'true') {
return true; return true
} else if (val == 'false') { } else if (val == 'false') {
return false; return false
} else if (val == '.NaN') { } else if (val == '.NaN') {
return Number.NaN; return Number.NaN
} else if (val == 'null') { } else if (val == 'null') {
return null; return null
} else if (val == '.inf') { } else if (val == '.inf') {
return Number.POSITIVE_INFINITY; return Number.POSITIVE_INFINITY
} else if (val == '-.inf') { } else if (val == '-.inf') {
return Number.NEGATIVE_INFINITY; return Number.NEGATIVE_INFINITY
} else if(m = val.match(regex$1["dashesString"])) { } else if ((m = val.match(regex$1['dashesString']))) {
return m[1]; return m[1]
} else if(m = val.match(regex$1["quotesString"])) { } else if ((m = val.match(regex$1['quotesString']))) {
return m[1]; return m[1]
} else if(m = val.match(regex$1["float"])) { } else if ((m = val.match(regex$1['float']))) {
return parseFloat(m[0]); return parseFloat(m[0])
} else if(m = val.match(regex$1["integer"])) { } else if ((m = val.match(regex$1['integer']))) {
return parseInt(m[0]); return parseInt(m[0])
} else if( !isNaN(m = Date.parse(val))) { } else if (!isNaN((m = Date.parse(val)))) {
return new Date(m); return new Date(m)
} else if(m = val.match(regex$1["single_key_value"])) { } else if ((m = val.match(regex$1['single_key_value']))) {
var res = {}; var res = {};
res[m[1]] = processValue(m[2]); res[m[1]] = processValue(m[2]);
return res; return res
} else if(m = val.match(regex$1["array"])){ } else if ((m = val.match(regex$1['array']))) {
var count = 0, c = ' '; var count = 0,
c = ' ';
var res = []; var res = [];
var content = ""; var content = '';
var str = false; var str = false;
for (var j = 0, lenJ = m[1].length; j < lenJ; ++j) { for (var j = 0, lenJ = m[1].length; j < lenJ; ++j) {
c = m[1][j]; c = m[1][j];
if(c == '\'' || c == '"') { if (c == "'" || c == '"') {
if (str === false) { if (str === false) {
str = c; str = c;
content += c; content += c;
continue; continue
} else if((c == '\'' && str == '\'') || (c == '"' && str == '"')) { } else if ((c == "'" && str == "'") || (c == '"' && str == '"')) {
str = false; str = false;
content += c; content += c;
continue; continue
} }
} else if (str === false && (c == '[' || c == '{')) { } else if (str === false && (c == '[' || c == '{')) {
++count; ++count;
@ -198,32 +196,32 @@ function processValue(val) {
--count; --count;
} else if (str === false && count == 0 && c == ',') { } else if (str === false && count == 0 && c == ',') {
res.push(processValue(content)); res.push(processValue(content));
content = ""; content = '';
continue; continue
} }
content += c; content += c;
} }
if(content.length > 0) if (content.length > 0) { res.push(processValue(content)); }
{ res.push(processValue(content)); } return res
return res; } else if ((m = val.match(regex$1['map']))) {
} else if(m = val.match(regex$1["map"])){ var count = 0,
var count = 0, c = ' '; c = ' ';
var res = []; var res = [];
var content = ""; var content = '';
var str = false; var str = false;
for (var j = 0, lenJ = m[1].length; j < lenJ; ++j) { for (var j = 0, lenJ = m[1].length; j < lenJ; ++j) {
c = m[1][j]; c = m[1][j];
if(c == '\'' || c == '"') { if (c == "'" || c == '"') {
if (str === false) { if (str === false) {
str = c; str = c;
content += c; content += c;
continue; continue
} else if((c == '\'' && str == '\'') || (c == '"' && str == '"')) { } else if ((c == "'" && str == "'") || (c == '"' && str == '"')) {
str = false; str = false;
content += c; content += c;
continue; continue
} }
} else if (str === false && (c == '[' || c == '{')) { } else if (str === false && (c == '[' || c == '{')) {
++count; ++count;
@ -231,47 +229,45 @@ function processValue(val) {
--count; --count;
} else if (str === false && count == 0 && c == ',') { } else if (str === false && count == 0 && c == ',') {
res.push(content); res.push(content);
content = ""; content = '';
continue; continue
} }
content += c; content += c;
} }
if(content.length > 0) if (content.length > 0) { res.push(content); }
{ res.push(content); }
var newRes = {}; var newRes = {};
for (var j = 0, lenJ = res.length; j < lenJ; ++j) { for (var j = 0, lenJ = res.length; j < lenJ; ++j) {
if(m = res[j].match(regex$1["key_value"])) { if ((m = res[j].match(regex$1['key_value']))) {
newRes[m[1]] = processValue(m[2]); newRes[m[1]] = processValue(m[2]);
} }
} }
return newRes; return newRes
} else } else { return val }
{ return val; }
} }
function processFoldedBlock(block) { function processFoldedBlock(block) {
var lines = block.lines; var lines = block.lines;
var children = block.children; var children = block.children;
var str = lines.join(" "); var str = lines.join(' ');
var chunks = [str]; var chunks = [str];
for (var i = 0, len = children.length; i < len; ++i) { for (var i = 0, len = children.length; i < len; ++i) {
chunks.push(processFoldedBlock(children[i])); chunks.push(processFoldedBlock(children[i]));
} }
return chunks.join("\n"); return chunks.join('\n')
} }
function processLiteralBlock(block) { function processLiteralBlock(block) {
var lines = block.lines; var lines = block.lines;
var children = block.children; var children = block.children;
var str = lines.join("\n"); var str = lines.join('\n');
for (var i = 0, len = children.length; i < len; ++i) { for (var i = 0, len = children.length; i < len; ++i) {
str += processLiteralBlock(children[i]); str += processLiteralBlock(children[i]);
} }
return str; return str
} }
function processBlock(blocks) { function processBlock(blocks) {
@ -288,9 +284,7 @@ function processBlock(blocks) {
var isMap = true; var isMap = true;
for (var j = 0, lenJ = blocks.length; j < lenJ; ++j) { for (var j = 0, lenJ = blocks.length; j < lenJ; ++j) {
if (level != -1 && level != blocks[j].level) { continue }
if(level != -1 && level != blocks[j].level)
{ continue; }
processedBlocks.push(j); processedBlocks.push(j);
@ -302,14 +296,14 @@ function processBlock(blocks) {
for (var i = 0, len = lines.length; i < len; ++i) { for (var i = 0, len = lines.length; i < len; ++i) {
var line = lines[i]; var line = lines[i];
if(m = line.match(regex$1["key"])) { if ((m = line.match(regex$1['key']))) {
var key = m[1]; var key = m[1];
if (key[0] == '-') { if (key[0] == '-') {
key = key.replace(regex$1["item"], ""); key = key.replace(regex$1['item'], '');
if (isMap) { if (isMap) {
isMap = false; isMap = false;
if (typeof(res.length) === "undefined") { if (typeof res.length === 'undefined') {
res = []; res = [];
} }
} }
@ -318,21 +312,22 @@ function processBlock(blocks) {
isMap = true; isMap = true;
} }
if(typeof m[2] != "undefined") { if (typeof m[2] != 'undefined') {
var value = m[2].replace(regex$1["trim"], ""); var value = m[2].replace(regex$1['trim'], '');
if (value[0] == '&') { if (value[0] == '&') {
var nb = processBlock(children); var nb = processBlock(children);
if (currentObj != null) { currentObj[key] = nb; } if (currentObj != null) { currentObj[key] = nb; }
else { res[key] = nb; } else { res[key] = nb; }
reference_blocks[value.substr(1)] = nb; reference_blocks[value.substr(1)] = nb;
} else if (value[0] == '|') { } else if (value[0] == '|') {
if(currentObj != null) { currentObj[key] = processLiteralBlock(children.shift()); } if (currentObj != null)
{ currentObj[key] = processLiteralBlock(children.shift()); }
else { res[key] = processLiteralBlock(children.shift()); } else { res[key] = processLiteralBlock(children.shift()); }
} else if (value[0] == '*') { } else if (value[0] == '*') {
var v = value.substr(1); var v = value.substr(1);
var no = {}; var no = {};
if(typeof reference_blocks[v] == "undefined") { if (typeof reference_blocks[v] == 'undefined') {
errors.push("Reference '" + v + "' not found!"); errors.push("Reference '" + v + "' not found!");
} else { } else {
for (var k in reference_blocks[v]) { for (var k in reference_blocks[v]) {
@ -343,7 +338,8 @@ function processBlock(blocks) {
else { res[key] = no; } else { res[key] = no; }
} }
} else if (value[0] == '>') { } else if (value[0] == '>') {
if(currentObj != null) { currentObj[key] = processFoldedBlock(children.shift()); } if (currentObj != null)
{ currentObj[key] = processFoldedBlock(children.shift()); }
else { res[key] = processFoldedBlock(children.shift()); } else { res[key] = processFoldedBlock(children.shift()); }
} else { } else {
if (currentObj != null) { currentObj[key] = processValue(value); } if (currentObj != null) { currentObj[key] = processValue(value); }
@ -356,34 +352,33 @@ function processBlock(blocks) {
} else if (line.match(/^-\s*$/)) { } else if (line.match(/^-\s*$/)) {
if (isMap) { if (isMap) {
isMap = false; isMap = false;
if (typeof(res.length) === "undefined") { if (typeof res.length === 'undefined') {
res = []; res = [];
} }
} }
if (currentObj != null) { res.push(currentObj); } if (currentObj != null) { res.push(currentObj); }
currentObj = {}; currentObj = {};
isMap = true; isMap = true;
continue; continue
} else if(m = line.match(/^-\s*(.*)/)) { } else if ((m = line.match(/^-\s*(.*)/))) {
if(currentObj != null) if (currentObj != null) { currentObj.push(processValue(m[1])); }
{ currentObj.push(processValue(m[1])); }
else { else {
if (isMap) { if (isMap) {
isMap = false; isMap = false;
if (typeof(res.length) === "undefined") { if (typeof res.length === 'undefined') {
res = []; res = [];
} }
} }
res.push(processValue(m[1])); res.push(processValue(m[1]));
} }
continue; continue
} }
} }
if (currentObj != null) { if (currentObj != null) {
if (isMap) { if (isMap) {
isMap = false; isMap = false;
if (typeof(res.length) === "undefined") { if (typeof res.length === 'undefined') {
res = []; res = [];
} }
} }
@ -395,22 +390,22 @@ function processBlock(blocks) {
blocks.splice.call(blocks, processedBlocks[j], 1); blocks.splice.call(blocks, processedBlocks[j], 1);
} }
return res; return res
} }
function semanticAnalysis(blocks) { function semanticAnalysis(blocks) {
var res = processBlock(blocks.children); var res = processBlock(blocks.children);
return res; return res
} }
function preProcess(src) { function preProcess(src) {
var m; var m;
var lines = src.split("\n"); var lines = src.split('\n');
var r = regex$1["comment"]; var r = regex$1['comment'];
for (var i in lines) { for (var i in lines) {
if(m = lines[i].match(r)) { if ((m = lines[i].match(r))) {
/* var cmt = ""; /* var cmt = "";
if(typeof m[3] != "undefined") if(typeof m[3] != "undefined")
lines[i] = m[1]; lines[i] = m[1];
@ -419,25 +414,25 @@ function preProcess(src) {
else else
lines[i] = ""; lines[i] = "";
*/ */
if(typeof m[3] !== "undefined") { if (typeof m[3] !== 'undefined') {
lines[i] = m[0].substr(0, m[0].length - m[3].length); lines[i] = m[0].substr(0, m[0].length - m[3].length);
} }
} }
} }
return lines.join("\n"); return lines.join('\n')
} }
function load(str) { function load(str) {
errors = []; errors = [];
reference_blocks = []; reference_blocks = [];
processing_time = (new Date()).getTime(); processing_time = new Date().getTime();
var pre = preProcess(str); var pre = preProcess(str);
var doc = parser$1(pre); var doc = parser$1(pre);
var res = semanticAnalysis(doc); var res = semanticAnalysis(doc);
processing_time = (new Date()).getTime() - processing_time; processing_time = new Date().getTime() - processing_time;
return res; return res
} }
/** /**
@ -445,7 +440,8 @@ function load(str) {
*/ */
/* eslint-disable */ /* eslint-disable */
var optionalByteOrderMark = '\\ufeff?'; var optionalByteOrderMark = '\\ufeff?';
var pattern = '^(' + var pattern =
'^(' +
optionalByteOrderMark + optionalByteOrderMark +
'(= yaml =|---)' + '(= yaml =|---)' +
'$([\\s\\S]*?)' + '$([\\s\\S]*?)' +

View file

@ -11,7 +11,9 @@ function appendScript () {
function init (id) { function init (id) {
appendScript(); appendScript();
window.ga = window.ga || function () { window.ga =
window.ga ||
function () {
(window.ga.q = window.ga.q || []).push(arguments); (window.ga.q = window.ga.q || []).push(arguments);
}; };
window.ga.l = Number(new Date()); window.ga.l = Number(new Date());

View file

@ -215,8 +215,11 @@ function bindEvents () {
var timeId; var timeId;
// Prevent to Fold sidebar // Prevent to Fold sidebar
Docsify.dom.on($search, 'click', Docsify.dom.on(
function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); }); $search,
'click',
function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); }
);
Docsify.dom.on($input, 'input', function (e) { Docsify.dom.on($input, 'input', function (e) {
clearTimeout(timeId); clearTimeout(timeId);
timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100); timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100);

View file

@ -37,5 +37,5 @@
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ=" "integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
} }
}, },
"version": "4.3.6" "version": "4.3.7"
} }

View file

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