mirror of
https://github.com/zhigang1992/docsify.git
synced 2026-04-28 09:26:26 +08:00
[build] 4.3.7
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||

|

|
||||||
|
|
||||||
# docsify <small>4.3.6</small>
|
# docsify <small>4.3.7</small>
|
||||||
|
|
||||||
> A magical documentation site generator.
|
> A magical documentation site generator.
|
||||||
|
|
||||||
|
|||||||
288
lib/docsify.js
288
lib/docsify.js
@@ -22,23 +22,25 @@ var hyphenate = cached(function (str) {
|
|||||||
/**
|
/**
|
||||||
* Simple Object.assign polyfill
|
* Simple Object.assign polyfill
|
||||||
*/
|
*/
|
||||||
var merge = Object.assign || function (to) {
|
var merge =
|
||||||
var arguments$1 = arguments;
|
Object.assign ||
|
||||||
|
function (to) {
|
||||||
|
var arguments$1 = arguments;
|
||||||
|
|
||||||
var hasOwn = Object.prototype.hasOwnProperty;
|
var hasOwn = Object.prototype.hasOwnProperty;
|
||||||
|
|
||||||
for (var i = 1; i < arguments.length; i++) {
|
for (var i = 1; i < arguments.length; i++) {
|
||||||
var from = Object(arguments$1[i]);
|
var from = Object(arguments$1[i]);
|
||||||
|
|
||||||
for (var key in from) {
|
for (var key in from) {
|
||||||
if (hasOwn.call(from, key)) {
|
if (hasOwn.call(from, key)) {
|
||||||
to[key] = from[key];
|
to[key] = from[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return to
|
return to
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if value is primitive
|
* Check if value is primitive
|
||||||
@@ -59,33 +61,38 @@ function isFn (obj) {
|
|||||||
return typeof obj === 'function'
|
return typeof obj === 'function'
|
||||||
}
|
}
|
||||||
|
|
||||||
var config = merge({
|
var config = merge(
|
||||||
el: '#app',
|
{
|
||||||
repo: '',
|
el: '#app',
|
||||||
maxLevel: 6,
|
repo: '',
|
||||||
subMaxLevel: 0,
|
maxLevel: 6,
|
||||||
loadSidebar: null,
|
subMaxLevel: 0,
|
||||||
loadNavbar: null,
|
loadSidebar: null,
|
||||||
homepage: 'README.md',
|
loadNavbar: null,
|
||||||
coverpage: '',
|
homepage: 'README.md',
|
||||||
basePath: '',
|
coverpage: '',
|
||||||
auto2top: false,
|
basePath: '',
|
||||||
name: '',
|
auto2top: false,
|
||||||
themeColor: '',
|
name: '',
|
||||||
nameLink: window.location.pathname,
|
themeColor: '',
|
||||||
autoHeader: false,
|
nameLink: window.location.pathname,
|
||||||
executeScript: null,
|
autoHeader: false,
|
||||||
noEmoji: false,
|
executeScript: null,
|
||||||
ga: '',
|
noEmoji: false,
|
||||||
mergeNavbar: false,
|
ga: '',
|
||||||
formatUpdated: '',
|
mergeNavbar: false,
|
||||||
externalLinkTarget: '_blank',
|
formatUpdated: '',
|
||||||
routerMode: 'hash',
|
externalLinkTarget: '_blank',
|
||||||
noCompileLinks: []
|
routerMode: 'hash',
|
||||||
}, window.$docsify);
|
noCompileLinks: []
|
||||||
|
},
|
||||||
|
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,14 +274,20 @@ 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 =
|
||||||
// Borrowed wholesale from https://github.com/defunkt/jquery-pjax
|
inBrowser &&
|
||||||
return window.history &&
|
(function () {
|
||||||
window.history.pushState &&
|
// Borrowed wholesale from https://github.com/defunkt/jquery-pjax
|
||||||
window.history.replaceState &&
|
return (
|
||||||
// pushState isn’t reliable on iOS until 5.
|
window.history &&
|
||||||
!navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/)
|
window.history.pushState &&
|
||||||
})();
|
window.history.replaceState &&
|
||||||
|
// pushState isn’t reliable on iOS until 5.
|
||||||
|
!navigator.userAgent.match(
|
||||||
|
/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/
|
||||||
|
)
|
||||||
|
)
|
||||||
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render github corner
|
* Render github corner
|
||||||
@@ -287,37 +300,40 @@ function corner (data) {
|
|||||||
data = data.replace(/^git\+/, '');
|
data = data.replace(/^git\+/, '');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
"<a href=\"" + data + "\" class=\"github-corner\" aria-label=\"View source on Github\">" +
|
"<a href=\"" + data + "\" class=\"github-corner\" aria-label=\"View source on Github\">" +
|
||||||
'<svg viewBox="0 0 250 250" aria-hidden="true">' +
|
'<svg viewBox="0 0 250 250" aria-hidden="true">' +
|
||||||
'<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>' +
|
'<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></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="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>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</button>' +
|
'</button>' +
|
||||||
'<aside class="sidebar">' +
|
'<aside class="sidebar">' +
|
||||||
(config.name
|
(config.name
|
||||||
? ("<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 (
|
||||||
'<section class="content">' +
|
(isMobile ? (aside + "<main>") : ("<main>" + aside)) +
|
||||||
'<article class="markdown-section" id="main"><!--main--></article>' +
|
'<section class="content">' +
|
||||||
'</section>' +
|
'<article class="markdown-section" id="main"><!--main--></article>' +
|
||||||
|
'</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 =
|
||||||
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 0%," +
|
'linear-gradient(to left bottom, ' +
|
||||||
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 100%)";
|
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 0%," +
|
||||||
|
"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(
|
||||||
step: Math.floor(Math.random() * 5 + 1)
|
function (_) { return progressbar({
|
||||||
}); }, 500);
|
step: Math.floor(Math.random() * 5 + 1)
|
||||||
|
}); },
|
||||||
|
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(
|
||||||
? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase()
|
obj[key]
|
||||||
: encode(key));
|
? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase()
|
||||||
|
: 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,8 +3006,12 @@ 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,19 +3043,17 @@ 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; })
|
var href = a.getAttribute('href');
|
||||||
.forEach(function (a) {
|
var node = isParent ? a.parentNode : a;
|
||||||
var href = a.getAttribute('href');
|
|
||||||
var node = isParent ? a.parentNode : a;
|
|
||||||
|
|
||||||
if (hash.indexOf(href) === 0 && !target) {
|
if (hash.indexOf(href) === 0 && !target) {
|
||||||
target = a;
|
target = a;
|
||||||
toggleClass(node, 'add', 'active');
|
toggleClass(node, 'add', 'active');
|
||||||
} else {
|
} else {
|
||||||
toggleClass(node, 'remove', 'active');
|
toggleClass(node, 'remove', 'active');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (autoTitle) {
|
if (autoTitle) {
|
||||||
$.title = target ? ((target.innerText) + " - " + title) : title;
|
$.title = target ? ((target.innerText) + " - " + title) : title;
|
||||||
@@ -3146,9 +3171,12 @@ function scrollTo (el) {
|
|||||||
end: el.getBoundingClientRect().top + window.scrollY,
|
end: el.getBoundingClientRect().top + window.scrollY,
|
||||||
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 () {
|
||||||
.begin();
|
enableScrollEvent = true;
|
||||||
|
scroller = null;
|
||||||
|
})
|
||||||
|
.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
function highlight () {
|
function highlight () {
|
||||||
@@ -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
4
lib/docsify.min.js
vendored
File diff suppressed because one or more lines are too long
1039
lib/plugins/emoji.js
1039
lib/plugins/emoji.js
File diff suppressed because it is too large
Load Diff
@@ -32,386 +32,381 @@ 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("([^\\\'\\\"#]+([\\\'\\\"][^\\\'\\\"]*[\\\'\\\"])*)*(#.*)?")
|
};
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class A block of lines of a given level.
|
* @class A block of lines of a given level.
|
||||||
* @param {int} lvl The block's level.
|
* @param {int} lvl The block's level.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function Block(lvl) {
|
function Block(lvl) {
|
||||||
return {
|
return {
|
||||||
/* The block's parent */
|
/* The block's parent */
|
||||||
parent: null,
|
parent: null,
|
||||||
/* Number of children */
|
/* Number of children */
|
||||||
length: 0,
|
length: 0,
|
||||||
/* Block's level */
|
/* Block's level */
|
||||||
level: lvl,
|
level: lvl,
|
||||||
/* Lines of code to process */
|
/* Lines of code to process */
|
||||||
lines: [],
|
lines: [],
|
||||||
/* Blocks with greater level */
|
/* Blocks with greater level */
|
||||||
children : [],
|
children: [],
|
||||||
/* Add a block to the children collection */
|
/* Add a block to the children collection */
|
||||||
addChild : function(obj) {
|
addChild: function(obj) {
|
||||||
this.children.push(obj);
|
this.children.push(obj);
|
||||||
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 = [];
|
||||||
|
|
||||||
var result = new Block(-1);
|
var result = new Block(-1);
|
||||||
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);
|
||||||
|
|
||||||
for(var i = 0, len = lines.length; i < len; ++i) {
|
for (var i = 0, len = lines.length; i < len; ++i) {
|
||||||
line = lines[i];
|
line = lines[i];
|
||||||
|
|
||||||
if(line.match(invalidLine)) {
|
if (line.match(invalidLine)) {
|
||||||
continue;
|
continue
|
||||||
}
|
|
||||||
|
|
||||||
if(m = regLevel.exec(line)) {
|
|
||||||
level = m[1].length;
|
|
||||||
} else
|
|
||||||
{ level = 0; }
|
|
||||||
|
|
||||||
if(level > curLevel) {
|
|
||||||
var oldBlock = currentBlock;
|
|
||||||
currentBlock = new Block(level);
|
|
||||||
oldBlock.addChild(currentBlock);
|
|
||||||
blocks.push(currentBlock);
|
|
||||||
levels.push(level);
|
|
||||||
} else if(level < curLevel) {
|
|
||||||
var added = false;
|
|
||||||
|
|
||||||
var k = levels.length - 1;
|
|
||||||
for(; k >= 0; --k) {
|
|
||||||
if(levels[k] == level) {
|
|
||||||
currentBlock = new Block(level);
|
|
||||||
blocks.push(currentBlock);
|
|
||||||
levels.push(level);
|
|
||||||
if(blocks[k].parent!= null)
|
|
||||||
{ blocks[k].parent.addChild(currentBlock); }
|
|
||||||
added = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!added) {
|
|
||||||
errors.push("Error: Invalid indentation at line " + i + ": " + line);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
currentBlock.lines.push(line.replace(regex$1["trim"], ""));
|
|
||||||
curLevel = level;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
if ((m = regLevel.exec(line))) {
|
||||||
|
level = m[1].length;
|
||||||
|
} else { level = 0; }
|
||||||
|
|
||||||
|
if (level > curLevel) {
|
||||||
|
var oldBlock = currentBlock;
|
||||||
|
currentBlock = new Block(level);
|
||||||
|
oldBlock.addChild(currentBlock);
|
||||||
|
blocks.push(currentBlock);
|
||||||
|
levels.push(level);
|
||||||
|
} else if (level < curLevel) {
|
||||||
|
var added = false;
|
||||||
|
|
||||||
|
var k = levels.length - 1;
|
||||||
|
for (; k >= 0; --k) {
|
||||||
|
if (levels[k] == level) {
|
||||||
|
currentBlock = new Block(level);
|
||||||
|
blocks.push(currentBlock);
|
||||||
|
levels.push(level);
|
||||||
|
if (blocks[k].parent != null) { blocks[k].parent.addChild(currentBlock); }
|
||||||
|
added = true;
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!added) {
|
||||||
|
errors.push('Error: Invalid indentation at line ' + i + ': ' + line);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentBlock.lines.push(line.replace(regex$1['trim'], ''));
|
||||||
|
curLevel = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
var res = [];
|
c = ' ';
|
||||||
var content = "";
|
var res = [];
|
||||||
var str = false;
|
var content = '';
|
||||||
for(var j = 0, lenJ = m[1].length; j < lenJ; ++j) {
|
var str = false;
|
||||||
c = m[1][j];
|
for (var j = 0, lenJ = m[1].length; j < lenJ; ++j) {
|
||||||
if(c == '\'' || c == '"') {
|
c = m[1][j];
|
||||||
if(str === false) {
|
if (c == "'" || c == '"') {
|
||||||
str = c;
|
if (str === false) {
|
||||||
content += c;
|
str = c;
|
||||||
continue;
|
content += c;
|
||||||
} else if((c == '\'' && str == '\'') || (c == '"' && str == '"')) {
|
continue
|
||||||
str = false;
|
} else if ((c == "'" && str == "'") || (c == '"' && str == '"')) {
|
||||||
content += c;
|
str = false;
|
||||||
continue;
|
content += c;
|
||||||
}
|
continue
|
||||||
} else if(str === false && (c == '[' || c == '{')) {
|
|
||||||
++count;
|
|
||||||
} else if(str === false && (c == ']' || c == '}')) {
|
|
||||||
--count;
|
|
||||||
} else if(str === false && count == 0 && c == ',') {
|
|
||||||
res.push(processValue(content));
|
|
||||||
content = "";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
content += c;
|
|
||||||
}
|
}
|
||||||
|
} else if (str === false && (c == '[' || c == '{')) {
|
||||||
|
++count;
|
||||||
|
} else if (str === false && (c == ']' || c == '}')) {
|
||||||
|
--count;
|
||||||
|
} else if (str === false && count == 0 && c == ',') {
|
||||||
|
res.push(processValue(content));
|
||||||
|
content = '';
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if(content.length > 0)
|
content += c;
|
||||||
{ res.push(processValue(content)); }
|
}
|
||||||
return res;
|
|
||||||
} else if(m = val.match(regex$1["map"])){
|
|
||||||
var count = 0, c = ' ';
|
|
||||||
var res = [];
|
|
||||||
var content = "";
|
|
||||||
var str = false;
|
|
||||||
for(var j = 0, lenJ = m[1].length; j < lenJ; ++j) {
|
|
||||||
c = m[1][j];
|
|
||||||
if(c == '\'' || c == '"') {
|
|
||||||
if(str === false) {
|
|
||||||
str = c;
|
|
||||||
content += c;
|
|
||||||
continue;
|
|
||||||
} else if((c == '\'' && str == '\'') || (c == '"' && str == '"')) {
|
|
||||||
str = false;
|
|
||||||
content += c;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else if(str === false && (c == '[' || c == '{')) {
|
|
||||||
++count;
|
|
||||||
} else if(str === false && (c == ']' || c == '}')) {
|
|
||||||
--count;
|
|
||||||
} else if(str === false && count == 0 && c == ',') {
|
|
||||||
res.push(content);
|
|
||||||
content = "";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
content += c;
|
if (content.length > 0) { res.push(processValue(content)); }
|
||||||
|
return res
|
||||||
|
} else if ((m = val.match(regex$1['map']))) {
|
||||||
|
var count = 0,
|
||||||
|
c = ' ';
|
||||||
|
var res = [];
|
||||||
|
var content = '';
|
||||||
|
var str = false;
|
||||||
|
for (var j = 0, lenJ = m[1].length; j < lenJ; ++j) {
|
||||||
|
c = m[1][j];
|
||||||
|
if (c == "'" || c == '"') {
|
||||||
|
if (str === false) {
|
||||||
|
str = c;
|
||||||
|
content += c;
|
||||||
|
continue
|
||||||
|
} else if ((c == "'" && str == "'") || (c == '"' && str == '"')) {
|
||||||
|
str = false;
|
||||||
|
content += c;
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
} else if (str === false && (c == '[' || c == '{')) {
|
||||||
|
++count;
|
||||||
|
} else if (str === false && (c == ']' || c == '}')) {
|
||||||
|
--count;
|
||||||
|
} else if (str === false && count == 0 && c == ',') {
|
||||||
|
res.push(content);
|
||||||
|
content = '';
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if(content.length > 0)
|
content += c;
|
||||||
{ res.push(content); }
|
}
|
||||||
|
|
||||||
var newRes = {};
|
if (content.length > 0) { res.push(content); }
|
||||||
for(var j = 0, lenJ = res.length; j < lenJ; ++j) {
|
|
||||||
if(m = res[j].match(regex$1["key_value"])) {
|
|
||||||
newRes[m[1]] = processValue(m[2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return newRes;
|
var newRes = {};
|
||||||
} else
|
for (var j = 0, lenJ = res.length; j < lenJ; ++j) {
|
||||||
{ return val; }
|
if ((m = res[j].match(regex$1['key_value']))) {
|
||||||
|
newRes[m[1]] = processValue(m[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return newRes
|
||||||
|
} else { 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) {
|
||||||
var m = null;
|
var m = null;
|
||||||
var res = {};
|
var res = {};
|
||||||
var lines = null;
|
var lines = null;
|
||||||
var children = null;
|
var children = null;
|
||||||
var currentObj = null;
|
var currentObj = null;
|
||||||
|
|
||||||
var level = -1;
|
var level = -1;
|
||||||
|
|
||||||
var processedBlocks = [];
|
var processedBlocks = [];
|
||||||
|
|
||||||
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)
|
processedBlocks.push(j);
|
||||||
{ continue; }
|
|
||||||
|
|
||||||
processedBlocks.push(j);
|
level = blocks[j].level;
|
||||||
|
lines = blocks[j].lines;
|
||||||
|
children = blocks[j].children;
|
||||||
|
currentObj = null;
|
||||||
|
|
||||||
level = blocks[j].level;
|
for (var i = 0, len = lines.length; i < len; ++i) {
|
||||||
lines = blocks[j].lines;
|
var line = lines[i];
|
||||||
children = blocks[j].children;
|
|
||||||
currentObj = null;
|
|
||||||
|
|
||||||
for(var i = 0, len = lines.length; i < len; ++i) {
|
if ((m = line.match(regex$1['key']))) {
|
||||||
var line = lines[i];
|
var key = m[1];
|
||||||
|
|
||||||
if(m = line.match(regex$1["key"])) {
|
if (key[0] == '-') {
|
||||||
var key = m[1];
|
key = key.replace(regex$1['item'], '');
|
||||||
|
if (isMap) {
|
||||||
if(key[0] == '-') {
|
isMap = false;
|
||||||
key = key.replace(regex$1["item"], "");
|
if (typeof res.length === 'undefined') {
|
||||||
if (isMap) {
|
res = [];
|
||||||
isMap = false;
|
|
||||||
if (typeof(res.length) === "undefined") {
|
|
||||||
res = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(currentObj != null) { res.push(currentObj); }
|
|
||||||
currentObj = {};
|
|
||||||
isMap = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(typeof m[2] != "undefined") {
|
|
||||||
var value = m[2].replace(regex$1["trim"], "");
|
|
||||||
if(value[0] == '&') {
|
|
||||||
var nb = processBlock(children);
|
|
||||||
if(currentObj != null) { currentObj[key] = nb; }
|
|
||||||
else { res[key] = nb; }
|
|
||||||
reference_blocks[value.substr(1)] = nb;
|
|
||||||
} else if(value[0] == '|') {
|
|
||||||
if(currentObj != null) { currentObj[key] = processLiteralBlock(children.shift()); }
|
|
||||||
else { res[key] = processLiteralBlock(children.shift()); }
|
|
||||||
} else if(value[0] == '*') {
|
|
||||||
var v = value.substr(1);
|
|
||||||
var no = {};
|
|
||||||
|
|
||||||
if(typeof reference_blocks[v] == "undefined") {
|
|
||||||
errors.push("Reference '" + v + "' not found!");
|
|
||||||
} else {
|
|
||||||
for(var k in reference_blocks[v]) {
|
|
||||||
no[k] = reference_blocks[v][k];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(currentObj != null) { currentObj[key] = no; }
|
|
||||||
else { res[key] = no; }
|
|
||||||
}
|
|
||||||
} else if(value[0] == '>') {
|
|
||||||
if(currentObj != null) { currentObj[key] = processFoldedBlock(children.shift()); }
|
|
||||||
else { res[key] = processFoldedBlock(children.shift()); }
|
|
||||||
} else {
|
|
||||||
if(currentObj != null) { currentObj[key] = processValue(value); }
|
|
||||||
else { res[key] = processValue(value); }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(currentObj != null) { currentObj[key] = processBlock(children); }
|
|
||||||
else { res[key] = processBlock(children); }
|
|
||||||
}
|
|
||||||
} else if(line.match(/^-\s*$/)) {
|
|
||||||
if (isMap) {
|
|
||||||
isMap = false;
|
|
||||||
if (typeof(res.length) === "undefined") {
|
|
||||||
res = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(currentObj != null) { res.push(currentObj); }
|
|
||||||
currentObj = {};
|
|
||||||
isMap = true;
|
|
||||||
continue;
|
|
||||||
} else if(m = line.match(/^-\s*(.*)/)) {
|
|
||||||
if(currentObj != null)
|
|
||||||
{ currentObj.push(processValue(m[1])); }
|
|
||||||
else {
|
|
||||||
if (isMap) {
|
|
||||||
isMap = false;
|
|
||||||
if (typeof(res.length) === "undefined") {
|
|
||||||
res = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res.push(processValue(m[1]));
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (currentObj != null) { res.push(currentObj); }
|
||||||
|
currentObj = {};
|
||||||
|
isMap = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentObj != null) {
|
if (typeof m[2] != 'undefined') {
|
||||||
if (isMap) {
|
var value = m[2].replace(regex$1['trim'], '');
|
||||||
isMap = false;
|
if (value[0] == '&') {
|
||||||
if (typeof(res.length) === "undefined") {
|
var nb = processBlock(children);
|
||||||
res = [];
|
if (currentObj != null) { currentObj[key] = nb; }
|
||||||
}
|
else { res[key] = nb; }
|
||||||
|
reference_blocks[value.substr(1)] = nb;
|
||||||
|
} else if (value[0] == '|') {
|
||||||
|
if (currentObj != null)
|
||||||
|
{ currentObj[key] = processLiteralBlock(children.shift()); }
|
||||||
|
else { res[key] = processLiteralBlock(children.shift()); }
|
||||||
|
} else if (value[0] == '*') {
|
||||||
|
var v = value.substr(1);
|
||||||
|
var no = {};
|
||||||
|
|
||||||
|
if (typeof reference_blocks[v] == 'undefined') {
|
||||||
|
errors.push("Reference '" + v + "' not found!");
|
||||||
|
} else {
|
||||||
|
for (var k in reference_blocks[v]) {
|
||||||
|
no[k] = reference_blocks[v][k];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentObj != null) { currentObj[key] = no; }
|
||||||
|
else { res[key] = no; }
|
||||||
}
|
}
|
||||||
res.push(currentObj);
|
} else if (value[0] == '>') {
|
||||||
|
if (currentObj != null)
|
||||||
|
{ currentObj[key] = processFoldedBlock(children.shift()); }
|
||||||
|
else { res[key] = processFoldedBlock(children.shift()); }
|
||||||
|
} else {
|
||||||
|
if (currentObj != null) { currentObj[key] = processValue(value); }
|
||||||
|
else { res[key] = processValue(value); }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (currentObj != null) { currentObj[key] = processBlock(children); }
|
||||||
|
else { res[key] = processBlock(children); }
|
||||||
}
|
}
|
||||||
|
} else if (line.match(/^-\s*$/)) {
|
||||||
|
if (isMap) {
|
||||||
|
isMap = false;
|
||||||
|
if (typeof res.length === 'undefined') {
|
||||||
|
res = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currentObj != null) { res.push(currentObj); }
|
||||||
|
currentObj = {};
|
||||||
|
isMap = true;
|
||||||
|
continue
|
||||||
|
} else if ((m = line.match(/^-\s*(.*)/))) {
|
||||||
|
if (currentObj != null) { currentObj.push(processValue(m[1])); }
|
||||||
|
else {
|
||||||
|
if (isMap) {
|
||||||
|
isMap = false;
|
||||||
|
if (typeof res.length === 'undefined') {
|
||||||
|
res = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.push(processValue(m[1]));
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var j = processedBlocks.length - 1; j >= 0; --j) {
|
if (currentObj != null) {
|
||||||
blocks.splice.call(blocks, processedBlocks[j], 1);
|
if (isMap) {
|
||||||
|
isMap = false;
|
||||||
|
if (typeof res.length === 'undefined') {
|
||||||
|
res = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.push(currentObj);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
for (var j = processedBlocks.length - 1; j >= 0; --j) {
|
||||||
|
blocks.splice.call(blocks, processedBlocks[j], 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
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];
|
||||||
else if(typeof m[3] != "undefined")
|
else if(typeof m[3] != "undefined")
|
||||||
@@ -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]*?)' +
|
||||||
@@ -457,7 +453,7 @@ var pattern = '^(' +
|
|||||||
// need to be moved down into the functions that use it.
|
// need to be moved down into the functions that use it.
|
||||||
var regex = new RegExp(pattern, 'm');
|
var regex = new RegExp(pattern, 'm');
|
||||||
|
|
||||||
function extractor (string) {
|
function extractor(string) {
|
||||||
string = string || '';
|
string = string || '';
|
||||||
|
|
||||||
var lines = string.split(/(\r?\n)/);
|
var lines = string.split(/(\r?\n)/);
|
||||||
@@ -468,7 +464,7 @@ function extractor (string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse (string) {
|
function parse(string) {
|
||||||
var match = regex.exec(string);
|
var match = regex.exec(string);
|
||||||
|
|
||||||
if (!match) {
|
if (!match) {
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ function appendScript () {
|
|||||||
|
|
||||||
function init (id) {
|
function init (id) {
|
||||||
appendScript();
|
appendScript();
|
||||||
window.ga = window.ga || function () {
|
window.ga =
|
||||||
(window.ga.q = window.ga.q || []).push(arguments);
|
window.ga ||
|
||||||
};
|
function () {
|
||||||
|
(window.ga.q = window.ga.q || []).push(arguments);
|
||||||
|
};
|
||||||
window.ga.l = Number(new Date());
|
window.ga.l = Number(new Date());
|
||||||
window.ga('create', id, 'auto');
|
window.ga('create', id, 'auto');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ function tpl (opts, defaultValue) {
|
|||||||
|
|
||||||
var html =
|
var html =
|
||||||
"<input type=\"search\" value=\"" + defaultValue + "\" />" +
|
"<input type=\"search\" value=\"" + defaultValue + "\" />" +
|
||||||
'<div class="results-panel"></div>' +
|
'<div class="results-panel"></div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
var el = Docsify.dom.create('div', html);
|
var el = Docsify.dom.create('div', html);
|
||||||
var aside = Docsify.dom.find('aside');
|
var aside = Docsify.dom.find('aside');
|
||||||
@@ -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);
|
||||||
|
|||||||
@@ -37,5 +37,5 @@
|
|||||||
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
|
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version": "4.3.6"
|
"version": "4.3.7"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user