mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-11-30 02:58:37 +08:00
[build] 4.3.7
This commit is contained in:
parent
e307308a78
commit
7923608bc9
@ -1,6 +1,6 @@
|
||||
![logo](_media/icon.svg)
|
||||
|
||||
# docsify <small>4.3.6</small>
|
||||
# docsify <small>4.3.7</small>
|
||||
|
||||
> 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
|
||||
*/
|
||||
var merge = Object.assign || function (to) {
|
||||
var arguments$1 = arguments;
|
||||
var merge =
|
||||
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++) {
|
||||
var from = Object(arguments$1[i]);
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var from = Object(arguments$1[i]);
|
||||
|
||||
for (var key in from) {
|
||||
if (hasOwn.call(from, key)) {
|
||||
to[key] = from[key];
|
||||
for (var key in from) {
|
||||
if (hasOwn.call(from, key)) {
|
||||
to[key] = from[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return to
|
||||
};
|
||||
return to
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if value is primitive
|
||||
@ -59,33 +61,38 @@ function isFn (obj) {
|
||||
return typeof obj === 'function'
|
||||
}
|
||||
|
||||
var config = merge({
|
||||
el: '#app',
|
||||
repo: '',
|
||||
maxLevel: 6,
|
||||
subMaxLevel: 0,
|
||||
loadSidebar: null,
|
||||
loadNavbar: null,
|
||||
homepage: 'README.md',
|
||||
coverpage: '',
|
||||
basePath: '',
|
||||
auto2top: false,
|
||||
name: '',
|
||||
themeColor: '',
|
||||
nameLink: window.location.pathname,
|
||||
autoHeader: false,
|
||||
executeScript: null,
|
||||
noEmoji: false,
|
||||
ga: '',
|
||||
mergeNavbar: false,
|
||||
formatUpdated: '',
|
||||
externalLinkTarget: '_blank',
|
||||
routerMode: 'hash',
|
||||
noCompileLinks: []
|
||||
}, window.$docsify);
|
||||
var config = merge(
|
||||
{
|
||||
el: '#app',
|
||||
repo: '',
|
||||
maxLevel: 6,
|
||||
subMaxLevel: 0,
|
||||
loadSidebar: null,
|
||||
loadNavbar: null,
|
||||
homepage: 'README.md',
|
||||
coverpage: '',
|
||||
basePath: '',
|
||||
auto2top: false,
|
||||
name: '',
|
||||
themeColor: '',
|
||||
nameLink: window.location.pathname,
|
||||
autoHeader: false,
|
||||
executeScript: null,
|
||||
noEmoji: false,
|
||||
ga: '',
|
||||
mergeNavbar: false,
|
||||
formatUpdated: '',
|
||||
externalLinkTarget: '_blank',
|
||||
routerMode: 'hash',
|
||||
noCompileLinks: []
|
||||
},
|
||||
window.$docsify
|
||||
);
|
||||
|
||||
var script = document.currentScript ||
|
||||
[].slice.call(document.getElementsByTagName('script'))
|
||||
var script =
|
||||
document.currentScript ||
|
||||
[].slice
|
||||
.call(document.getElementsByTagName('script'))
|
||||
.filter(function (n) { return /docsify\./.test(n.src); })[0];
|
||||
|
||||
if (script) {
|
||||
@ -119,7 +126,7 @@ function initLifecycle (vm) {
|
||||
vm._hooks = {};
|
||||
vm._lifecycle = {};
|
||||
hooks.forEach(function (hook) {
|
||||
var arr = vm._hooks[hook] = [];
|
||||
var arr = (vm._hooks[hook] = []);
|
||||
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
|
||||
*/
|
||||
var supportsPushState = inBrowser && (function () {
|
||||
// Borrowed wholesale from https://github.com/defunkt/jquery-pjax
|
||||
return window.history &&
|
||||
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)/)
|
||||
})();
|
||||
var supportsPushState =
|
||||
inBrowser &&
|
||||
(function () {
|
||||
// Borrowed wholesale from https://github.com/defunkt/jquery-pjax
|
||||
return (
|
||||
window.history &&
|
||||
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
|
||||
@ -287,37 +300,40 @@ function corner (data) {
|
||||
data = data.replace(/^git\+/, '');
|
||||
|
||||
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">' +
|
||||
'<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="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="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="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>' +
|
||||
'</a>')
|
||||
'</a>'
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Render main content
|
||||
*/
|
||||
function main (config) {
|
||||
var aside = (
|
||||
var aside =
|
||||
'<button class="sidebar-toggle">' +
|
||||
'<div class="sidebar-toggle-button">' +
|
||||
'<span></span><span></span><span></span>' +
|
||||
'</div>' +
|
||||
'<div class="sidebar-toggle-button">' +
|
||||
'<span></span><span></span><span></span>' +
|
||||
'</div>' +
|
||||
'</button>' +
|
||||
'<aside class="sidebar">' +
|
||||
(config.name
|
||||
? ("<h1><a class=\"app-name-link\" data-nosearch>" + (config.name) + "</a></h1>")
|
||||
: '') +
|
||||
'<div class="sidebar-nav"><!--sidebar--></div>' +
|
||||
'</aside>');
|
||||
(config.name
|
||||
? ("<h1><a class=\"app-name-link\" data-nosearch>" + (config.name) + "</a></h1>")
|
||||
: '') +
|
||||
'<div class="sidebar-nav"><!--sidebar--></div>' +
|
||||
'</aside>';
|
||||
|
||||
return (isMobile ? (aside + "<main>") : ("<main>" + aside)) +
|
||||
'<section class="content">' +
|
||||
'<article class="markdown-section" id="main"><!--main--></article>' +
|
||||
'</section>' +
|
||||
return (
|
||||
(isMobile ? (aside + "<main>") : ("<main>" + aside)) +
|
||||
'<section class="content">' +
|
||||
'<article class="markdown-section" id="main"><!--main--></article>' +
|
||||
'</section>' +
|
||||
'</main>'
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -325,14 +341,17 @@ function main (config) {
|
||||
*/
|
||||
function cover () {
|
||||
var SL = ', 100%, 85%';
|
||||
var bgc = 'linear-gradient(to left bottom, ' +
|
||||
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 0%," +
|
||||
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 100%)";
|
||||
var bgc =
|
||||
'linear-gradient(to left bottom, ' +
|
||||
"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="mask"></div>' +
|
||||
'</section>'
|
||||
'</section>'
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -437,9 +456,12 @@ function get (url, hasBar) {
|
||||
if ( error === void 0 ) error = noop;
|
||||
|
||||
if (hasBar) {
|
||||
var id = setInterval(function (_) { return progressbar({
|
||||
step: Math.floor(Math.random() * 5 + 1)
|
||||
}); }, 500);
|
||||
var id = setInterval(
|
||||
function (_) { return progressbar({
|
||||
step: Math.floor(Math.random() * 5 + 1)
|
||||
}); },
|
||||
500
|
||||
);
|
||||
|
||||
on('progress', progressbar);
|
||||
on('loadend', function (evt) {
|
||||
@ -455,12 +477,12 @@ function get (url, hasBar) {
|
||||
if (target.status >= 400) {
|
||||
error(target);
|
||||
} else {
|
||||
var result = cache[url] = {
|
||||
var result = (cache[url] = {
|
||||
content: target.response,
|
||||
opt: {
|
||||
updatedAt: xhr.getResponseHeader('last-modified')
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
success(result.content, result.opt);
|
||||
}
|
||||
@ -471,15 +493,15 @@ function get (url, hasBar) {
|
||||
}
|
||||
|
||||
function replaceVar (block, color) {
|
||||
block.innerHTML = block.innerHTML
|
||||
.replace(/var\(\s*--theme-color.*?\)/g, color);
|
||||
block.innerHTML = block.innerHTML.replace(
|
||||
/var\(\s*--theme-color.*?\)/g,
|
||||
color
|
||||
);
|
||||
}
|
||||
|
||||
var cssVars = function (color) {
|
||||
// Variable support
|
||||
if (window.CSS &&
|
||||
window.CSS.supports &&
|
||||
window.CSS.supports('(--v:red)')) { return }
|
||||
if (window.CSS && window.CSS.supports && window.CSS.supports('(--v:red)')) { return }
|
||||
|
||||
var styleBlocks = findAll('style:not(.inserted),link');[].forEach.call(styleBlocks, function (block) {
|
||||
if (block.nodeName === 'STYLE') {
|
||||
@ -2675,7 +2697,10 @@ var re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g;
|
||||
function slugify (str) {
|
||||
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(re, '')
|
||||
.replace(/\s/g, '-')
|
||||
@ -2683,7 +2708,7 @@ function slugify (str) {
|
||||
.replace(/^(\d)/, '_$1');
|
||||
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;
|
||||
|
||||
if (count) {
|
||||
@ -2734,9 +2759,11 @@ function stringifyQuery (obj) {
|
||||
var qs = [];
|
||||
|
||||
for (var key in obj) {
|
||||
qs.push(obj[key]
|
||||
? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase()
|
||||
: encode(key));
|
||||
qs.push(
|
||||
obj[key]
|
||||
? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase()
|
||||
: encode(key)
|
||||
);
|
||||
}
|
||||
|
||||
return qs.length ? ("?" + (qs.join('&'))) : ''
|
||||
@ -2756,15 +2783,11 @@ var isAbsolutePath = cached(function (path) {
|
||||
var getParentPath = cached(function (path) {
|
||||
return /\/$/g.test(path)
|
||||
? path
|
||||
: (path = path.match(/(\S*\/)[^\/]+$/))
|
||||
? path[1]
|
||||
: ''
|
||||
: (path = path.match(/(\S*\/)[^\/]+$/)) ? path[1] : ''
|
||||
});
|
||||
|
||||
var cleanPath = cached(function (path) {
|
||||
return path
|
||||
.replace(/^\/+/, '/')
|
||||
.replace(/([^:])\/{2,}/g, '$1/')
|
||||
return path.replace(/^\/+/, '/').replace(/([^:])\/{2,}/g, '$1/')
|
||||
});
|
||||
|
||||
var cachedLinks = {};
|
||||
@ -2983,8 +3006,12 @@ function btn (el, router) {
|
||||
|
||||
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)); }
|
||||
);
|
||||
}
|
||||
@ -3016,19 +3043,17 @@ function getAndActive (router, el, isParent, autoTitle) {
|
||||
var hash = router.toURL(router.getCurrentPath());
|
||||
var target;
|
||||
|
||||
links
|
||||
.sort(function (a, b) { return b.href.length - a.href.length; })
|
||||
.forEach(function (a) {
|
||||
var href = a.getAttribute('href');
|
||||
var node = isParent ? a.parentNode : a;
|
||||
links.sort(function (a, b) { return b.href.length - a.href.length; }).forEach(function (a) {
|
||||
var href = a.getAttribute('href');
|
||||
var node = isParent ? a.parentNode : a;
|
||||
|
||||
if (hash.indexOf(href) === 0 && !target) {
|
||||
target = a;
|
||||
toggleClass(node, 'add', 'active');
|
||||
} else {
|
||||
toggleClass(node, 'remove', 'active');
|
||||
}
|
||||
});
|
||||
if (hash.indexOf(href) === 0 && !target) {
|
||||
target = a;
|
||||
toggleClass(node, 'add', 'active');
|
||||
} else {
|
||||
toggleClass(node, 'remove', 'active');
|
||||
}
|
||||
});
|
||||
|
||||
if (autoTitle) {
|
||||
$.title = target ? ((target.innerText) + " - " + title) : title;
|
||||
@ -3146,9 +3171,12 @@ function scrollTo (el) {
|
||||
end: el.getBoundingClientRect().top + window.scrollY,
|
||||
duration: 500
|
||||
})
|
||||
.on('tick', function (v) { return window.scrollTo(0, v); })
|
||||
.on('done', function () { enableScrollEvent = true; scroller = null; })
|
||||
.begin();
|
||||
.on('tick', function (v) { return window.scrollTo(0, v); })
|
||||
.on('done', function () {
|
||||
enableScrollEvent = true;
|
||||
scroller = null;
|
||||
})
|
||||
.begin();
|
||||
}
|
||||
|
||||
function highlight () {
|
||||
@ -3158,7 +3186,7 @@ function highlight () {
|
||||
var wrap = find(sidebar, '.sidebar-nav');
|
||||
var active = find(sidebar, 'li.active');
|
||||
var doc = document.documentElement;
|
||||
var top = (doc && doc.scrollTop || document.body.scrollTop) - coverHeight;
|
||||
var top = ((doc && doc.scrollTop) || document.body.scrollTop) - coverHeight;
|
||||
var last;
|
||||
|
||||
for (var i = 0, len = anchors.length; i < len; i += 1) {
|
||||
@ -3186,16 +3214,10 @@ function highlight () {
|
||||
var height = sidebar.clientHeight;
|
||||
var curOffset = 0;
|
||||
var cur = active.offsetTop + active.clientHeight + 40;
|
||||
var isInView = (
|
||||
active.offsetTop >= wrap.scrollTop &&
|
||||
cur <= wrap.scrollTop + height
|
||||
);
|
||||
var isInView =
|
||||
active.offsetTop >= wrap.scrollTop && cur <= wrap.scrollTop + height;
|
||||
var notThan = cur - curOffset < height;
|
||||
var top$1 = isInView
|
||||
? wrap.scrollTop
|
||||
: notThan
|
||||
? curOffset
|
||||
: cur - height;
|
||||
var top$1 = isInView ? wrap.scrollTop : notThan ? curOffset : cur - height;
|
||||
|
||||
sidebar.scrollTop = top$1;
|
||||
}
|
||||
@ -3225,8 +3247,12 @@ function scrollActiveSidebar (router) {
|
||||
|
||||
off('scroll', highlight);
|
||||
on('scroll', highlight);
|
||||
on(sidebar, 'mouseover', function () { hoverOver = true; });
|
||||
on(sidebar, 'mouseleave', function () { hoverOver = false; });
|
||||
on(sidebar, 'mouseover', function () {
|
||||
hoverOver = true;
|
||||
});
|
||||
on(sidebar, 'mouseleave', function () {
|
||||
hoverOver = false;
|
||||
});
|
||||
}
|
||||
|
||||
function scrollIntoView (id) {
|
||||
@ -3477,15 +3503,15 @@ function getAlias (path, alias, last) {
|
||||
return re.test(path) && path !== last
|
||||
})[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) {
|
||||
return /\.(md|html)$/g.test(path)
|
||||
? path
|
||||
: /\/$/g.test(path)
|
||||
? (path + "README.md")
|
||||
: (path + ".md")
|
||||
: /\/$/g.test(path) ? (path + "README.md") : (path + ".md")
|
||||
}
|
||||
|
||||
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 = 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);
|
||||
|
||||
if (isRelative) {
|
||||
@ -3531,9 +3557,7 @@ History.prototype.toURL = function toURL () {};
|
||||
|
||||
function replaceHash (path) {
|
||||
var i = location.href.indexOf('#');
|
||||
location.replace(
|
||||
location.href.slice(0, i >= 0 ? i : 0) + '#' + path
|
||||
);
|
||||
location.replace(location.href.slice(0, i >= 0 ? i : 0) + '#' + path);
|
||||
}
|
||||
|
||||
var replaceSlug = cached(function (path) {
|
||||
@ -3554,9 +3578,7 @@ var HashHistory = (function (History$$1) {
|
||||
var path = window.location.pathname || '';
|
||||
var base = this.config.basePath;
|
||||
|
||||
return /^(\/|https?:)/g.test(base)
|
||||
? base
|
||||
: cleanPath(path + '/' + base)
|
||||
return /^(\/|https?:)/g.test(base) ? base : cleanPath(path + '/' + base)
|
||||
};
|
||||
|
||||
HashHistory.prototype.getCurrentPath = function getCurrentPath () {
|
||||
@ -3651,9 +3673,7 @@ var HTML5History = (function (History$$1) {
|
||||
if ( cb === void 0 ) cb = noop;
|
||||
|
||||
on('click', function (e) {
|
||||
var el = e.target.tagName === 'A'
|
||||
? e.target
|
||||
: e.target.parentNode;
|
||||
var el = e.target.tagName === 'A' ? e.target : e.target.parentNode;
|
||||
|
||||
if (el.tagName === 'A' && !/_blank/.test(el.target)) {
|
||||
e.preventDefault();
|
||||
@ -3956,7 +3976,7 @@ initGlobalAPI();
|
||||
/**
|
||||
* Version
|
||||
*/
|
||||
Docsify.version = '4.3.6';
|
||||
Docsify.version = '4.3.7';
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
var errors = [];
|
||||
var reference_blocks = [];
|
||||
var processing_time = 0;
|
||||
var regex$1 =
|
||||
{
|
||||
"regLevel" : new RegExp("^([\\s\\-]+)"),
|
||||
"invalidLine" : new RegExp("^\\-\\-\\-|^\\.\\.\\.|^\\s*#.*|^\\s*$"),
|
||||
"dashesString" : new RegExp("^\\s*\\\"([^\\\"]*)\\\"\\s*$"),
|
||||
"quotesString" : new RegExp("^\\s*\\\'([^\\\']*)\\\'\\s*$"),
|
||||
"float" : new RegExp("^[+-]?[0-9]+\\.[0-9]+(e[+-]?[0-9]+(\\.[0-9]+)?)?$"),
|
||||
"integer" : new RegExp("^[+-]?[0-9]+$"),
|
||||
"array" : new RegExp("\\[\\s*(.*)\\s*\\]"),
|
||||
"map" : new RegExp("\\{\\s*(.*)\\s*\\}"),
|
||||
"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"),
|
||||
"item" : new RegExp("^-\\s+"),
|
||||
"trim" : new RegExp("^\\s+|\\s+$"),
|
||||
"comment" : new RegExp("([^\\\'\\\"#]+([\\\'\\\"][^\\\'\\\"]*[\\\'\\\"])*)*(#.*)?")
|
||||
};
|
||||
var regex$1 = {
|
||||
regLevel: new RegExp('^([\\s\\-]+)'),
|
||||
invalidLine: new RegExp('^\\-\\-\\-|^\\.\\.\\.|^\\s*#.*|^\\s*$'),
|
||||
dashesString: new RegExp('^\\s*\\"([^\\"]*)\\"\\s*$'),
|
||||
quotesString: new RegExp("^\\s*\\'([^\\']*)\\'\\s*$"),
|
||||
float: new RegExp('^[+-]?[0-9]+\\.[0-9]+(e[+-]?[0-9]+(\\.[0-9]+)?)?$'),
|
||||
integer: new RegExp('^[+-]?[0-9]+$'),
|
||||
array: new RegExp('\\[\\s*(.*)\\s*\\]'),
|
||||
map: new RegExp('\\{\\s*(.*)\\s*\\}'),
|
||||
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'),
|
||||
item: new RegExp('^-\\s+'),
|
||||
trim: new RegExp('^\\s+|\\s+$'),
|
||||
comment: new RegExp('([^\\\'\\"#]+([\\\'\\"][^\\\'\\"]*[\\\'\\"])*)*(#.*)?')
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* @class A block of lines of a given level.
|
||||
* @param {int} lvl The block's level.
|
||||
* @private
|
||||
*/
|
||||
function Block(lvl) {
|
||||
return {
|
||||
/* The block's parent */
|
||||
parent: null,
|
||||
/* Number of children */
|
||||
length: 0,
|
||||
/* Block's level */
|
||||
level: lvl,
|
||||
/* Lines of code to process */
|
||||
lines: [],
|
||||
/* Blocks with greater level */
|
||||
children : [],
|
||||
/* Add a block to the children collection */
|
||||
addChild : function(obj) {
|
||||
this.children.push(obj);
|
||||
obj.parent = this;
|
||||
++this.length;
|
||||
}
|
||||
};
|
||||
return {
|
||||
/* The block's parent */
|
||||
parent: null,
|
||||
/* Number of children */
|
||||
length: 0,
|
||||
/* Block's level */
|
||||
level: lvl,
|
||||
/* Lines of code to process */
|
||||
lines: [],
|
||||
/* Blocks with greater level */
|
||||
children: [],
|
||||
/* Add a block to the children collection */
|
||||
addChild: function(obj) {
|
||||
this.children.push(obj);
|
||||
obj.parent = this;
|
||||
++this.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parser$1(str) {
|
||||
var regLevel = regex$1["regLevel"];
|
||||
var invalidLine = regex$1["invalidLine"];
|
||||
var lines = str.split("\n");
|
||||
var m;
|
||||
var level = 0, curLevel = 0;
|
||||
var regLevel = regex$1['regLevel'];
|
||||
var invalidLine = regex$1['invalidLine'];
|
||||
var lines = str.split('\n');
|
||||
var m;
|
||||
var level = 0,
|
||||
curLevel = 0;
|
||||
|
||||
var blocks = [];
|
||||
var blocks = [];
|
||||
|
||||
var result = new Block(-1);
|
||||
var currentBlock = new Block(0);
|
||||
result.addChild(currentBlock);
|
||||
var levels = [];
|
||||
var line = "";
|
||||
var result = new Block(-1);
|
||||
var currentBlock = new Block(0);
|
||||
result.addChild(currentBlock);
|
||||
var levels = [];
|
||||
var line = '';
|
||||
|
||||
blocks.push(currentBlock);
|
||||
levels.push(level);
|
||||
blocks.push(currentBlock);
|
||||
levels.push(level);
|
||||
|
||||
for(var i = 0, len = lines.length; i < len; ++i) {
|
||||
line = lines[i];
|
||||
for (var i = 0, len = lines.length; i < len; ++i) {
|
||||
line = lines[i];
|
||||
|
||||
if(line.match(invalidLine)) {
|
||||
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;
|
||||
if (line.match(invalidLine)) {
|
||||
continue
|
||||
}
|
||||
|
||||
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) {
|
||||
val = val.replace(regex$1["trim"], "");
|
||||
var m = null;
|
||||
val = val.replace(regex$1['trim'], '');
|
||||
var m = null;
|
||||
|
||||
if(val == 'true') {
|
||||
return true;
|
||||
} else if(val == 'false') {
|
||||
return false;
|
||||
} else if(val == '.NaN') {
|
||||
return Number.NaN;
|
||||
} else if(val == 'null') {
|
||||
return null;
|
||||
} else if(val == '.inf') {
|
||||
return Number.POSITIVE_INFINITY;
|
||||
} else if(val == '-.inf') {
|
||||
return Number.NEGATIVE_INFINITY;
|
||||
} else if(m = val.match(regex$1["dashesString"])) {
|
||||
return m[1];
|
||||
} else if(m = val.match(regex$1["quotesString"])) {
|
||||
return m[1];
|
||||
} else if(m = val.match(regex$1["float"])) {
|
||||
return parseFloat(m[0]);
|
||||
} else if(m = val.match(regex$1["integer"])) {
|
||||
return parseInt(m[0]);
|
||||
} else if( !isNaN(m = Date.parse(val))) {
|
||||
return new Date(m);
|
||||
} else if(m = val.match(regex$1["single_key_value"])) {
|
||||
var res = {};
|
||||
res[m[1]] = processValue(m[2]);
|
||||
return res;
|
||||
} else if(m = val.match(regex$1["array"])){
|
||||
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(processValue(content));
|
||||
content = "";
|
||||
continue;
|
||||
}
|
||||
|
||||
content += c;
|
||||
if (val == 'true') {
|
||||
return true
|
||||
} else if (val == 'false') {
|
||||
return false
|
||||
} else if (val == '.NaN') {
|
||||
return Number.NaN
|
||||
} else if (val == 'null') {
|
||||
return null
|
||||
} else if (val == '.inf') {
|
||||
return Number.POSITIVE_INFINITY
|
||||
} else if (val == '-.inf') {
|
||||
return Number.NEGATIVE_INFINITY
|
||||
} else if ((m = val.match(regex$1['dashesString']))) {
|
||||
return m[1]
|
||||
} else if ((m = val.match(regex$1['quotesString']))) {
|
||||
return m[1]
|
||||
} else if ((m = val.match(regex$1['float']))) {
|
||||
return parseFloat(m[0])
|
||||
} else if ((m = val.match(regex$1['integer']))) {
|
||||
return parseInt(m[0])
|
||||
} else if (!isNaN((m = Date.parse(val)))) {
|
||||
return new Date(m)
|
||||
} else if ((m = val.match(regex$1['single_key_value']))) {
|
||||
var res = {};
|
||||
res[m[1]] = processValue(m[2]);
|
||||
return res
|
||||
} else if ((m = val.match(regex$1['array']))) {
|
||||
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(processValue(content));
|
||||
content = '';
|
||||
continue
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
content += c;
|
||||
}
|
||||
|
||||
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)
|
||||
{ res.push(content); }
|
||||
content += c;
|
||||
}
|
||||
|
||||
var newRes = {};
|
||||
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]);
|
||||
}
|
||||
}
|
||||
if (content.length > 0) { res.push(content); }
|
||||
|
||||
return newRes;
|
||||
} else
|
||||
{ return val; }
|
||||
var newRes = {};
|
||||
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
|
||||
} else { return val }
|
||||
}
|
||||
|
||||
function processFoldedBlock(block) {
|
||||
var lines = block.lines;
|
||||
var children = block.children;
|
||||
var str = lines.join(" ");
|
||||
var chunks = [str];
|
||||
for(var i = 0, len = children.length; i < len; ++i) {
|
||||
chunks.push(processFoldedBlock(children[i]));
|
||||
}
|
||||
return chunks.join("\n");
|
||||
var lines = block.lines;
|
||||
var children = block.children;
|
||||
var str = lines.join(' ');
|
||||
var chunks = [str];
|
||||
for (var i = 0, len = children.length; i < len; ++i) {
|
||||
chunks.push(processFoldedBlock(children[i]));
|
||||
}
|
||||
return chunks.join('\n')
|
||||
}
|
||||
|
||||
function processLiteralBlock(block) {
|
||||
var lines = block.lines;
|
||||
var children = block.children;
|
||||
var str = lines.join("\n");
|
||||
for(var i = 0, len = children.length; i < len; ++i) {
|
||||
str += processLiteralBlock(children[i]);
|
||||
}
|
||||
return str;
|
||||
var lines = block.lines;
|
||||
var children = block.children;
|
||||
var str = lines.join('\n');
|
||||
for (var i = 0, len = children.length; i < len; ++i) {
|
||||
str += processLiteralBlock(children[i]);
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
function processBlock(blocks) {
|
||||
var m = null;
|
||||
var res = {};
|
||||
var lines = null;
|
||||
var children = null;
|
||||
var currentObj = null;
|
||||
var m = null;
|
||||
var res = {};
|
||||
var lines = null;
|
||||
var children = 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)
|
||||
{ continue; }
|
||||
processedBlocks.push(j);
|
||||
|
||||
processedBlocks.push(j);
|
||||
level = blocks[j].level;
|
||||
lines = blocks[j].lines;
|
||||
children = blocks[j].children;
|
||||
currentObj = null;
|
||||
|
||||
level = blocks[j].level;
|
||||
lines = blocks[j].lines;
|
||||
children = blocks[j].children;
|
||||
currentObj = null;
|
||||
for (var i = 0, len = lines.length; i < len; ++i) {
|
||||
var line = lines[i];
|
||||
|
||||
for(var i = 0, len = lines.length; i < len; ++i) {
|
||||
var line = lines[i];
|
||||
if ((m = line.match(regex$1['key']))) {
|
||||
var key = m[1];
|
||||
|
||||
if(m = line.match(regex$1["key"])) {
|
||||
var key = m[1];
|
||||
|
||||
if(key[0] == '-') {
|
||||
key = key.replace(regex$1["item"], "");
|
||||
if (isMap) {
|
||||
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 (key[0] == '-') {
|
||||
key = key.replace(regex$1['item'], '');
|
||||
if (isMap) {
|
||||
isMap = false;
|
||||
if (typeof res.length === 'undefined') {
|
||||
res = [];
|
||||
}
|
||||
}
|
||||
if (currentObj != null) { res.push(currentObj); }
|
||||
currentObj = {};
|
||||
isMap = true;
|
||||
}
|
||||
|
||||
if(currentObj != null) {
|
||||
if (isMap) {
|
||||
isMap = false;
|
||||
if (typeof(res.length) === "undefined") {
|
||||
res = [];
|
||||
}
|
||||
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; }
|
||||
}
|
||||
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) {
|
||||
blocks.splice.call(blocks, processedBlocks[j], 1);
|
||||
if (currentObj != null) {
|
||||
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) {
|
||||
var res = processBlock(blocks.children);
|
||||
return res;
|
||||
var res = processBlock(blocks.children);
|
||||
return res
|
||||
}
|
||||
|
||||
function preProcess(src) {
|
||||
var m;
|
||||
var lines = src.split("\n");
|
||||
var m;
|
||||
var lines = src.split('\n');
|
||||
|
||||
var r = regex$1["comment"];
|
||||
var r = regex$1['comment'];
|
||||
|
||||
for(var i in lines) {
|
||||
if(m = lines[i].match(r)) {
|
||||
/* var cmt = "";
|
||||
for (var i in lines) {
|
||||
if ((m = lines[i].match(r))) {
|
||||
/* var cmt = "";
|
||||
if(typeof m[3] != "undefined")
|
||||
lines[i] = m[1];
|
||||
else if(typeof m[3] != "undefined")
|
||||
@ -419,25 +414,25 @@ function preProcess(src) {
|
||||
else
|
||||
lines[i] = "";
|
||||
*/
|
||||
if(typeof m[3] !== "undefined") {
|
||||
lines[i] = m[0].substr(0, m[0].length - m[3].length);
|
||||
}
|
||||
}
|
||||
if (typeof m[3] !== 'undefined') {
|
||||
lines[i] = m[0].substr(0, m[0].length - m[3].length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
function load(str) {
|
||||
errors = [];
|
||||
reference_blocks = [];
|
||||
processing_time = (new Date()).getTime();
|
||||
var pre = preProcess(str);
|
||||
var doc = parser$1(pre);
|
||||
var res = semanticAnalysis(doc);
|
||||
processing_time = (new Date()).getTime() - processing_time;
|
||||
errors = [];
|
||||
reference_blocks = [];
|
||||
processing_time = new Date().getTime();
|
||||
var pre = preProcess(str);
|
||||
var doc = parser$1(pre);
|
||||
var res = semanticAnalysis(doc);
|
||||
processing_time = new Date().getTime() - processing_time;
|
||||
|
||||
return res;
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
@ -445,7 +440,8 @@ function load(str) {
|
||||
*/
|
||||
/* eslint-disable */
|
||||
var optionalByteOrderMark = '\\ufeff?';
|
||||
var pattern = '^(' +
|
||||
var pattern =
|
||||
'^(' +
|
||||
optionalByteOrderMark +
|
||||
'(= yaml =|---)' +
|
||||
'$([\\s\\S]*?)' +
|
||||
@ -457,7 +453,7 @@ var pattern = '^(' +
|
||||
// need to be moved down into the functions that use it.
|
||||
var regex = new RegExp(pattern, 'm');
|
||||
|
||||
function extractor (string) {
|
||||
function extractor(string) {
|
||||
string = string || '';
|
||||
|
||||
var lines = string.split(/(\r?\n)/);
|
||||
@ -468,7 +464,7 @@ function extractor (string) {
|
||||
}
|
||||
}
|
||||
|
||||
function parse (string) {
|
||||
function parse(string) {
|
||||
var match = regex.exec(string);
|
||||
|
||||
if (!match) {
|
||||
|
@ -11,9 +11,11 @@ function appendScript () {
|
||||
|
||||
function init (id) {
|
||||
appendScript();
|
||||
window.ga = window.ga || function () {
|
||||
(window.ga.q = window.ga.q || []).push(arguments);
|
||||
};
|
||||
window.ga =
|
||||
window.ga ||
|
||||
function () {
|
||||
(window.ga.q = window.ga.q || []).push(arguments);
|
||||
};
|
||||
window.ga.l = Number(new Date());
|
||||
window.ga('create', id, 'auto');
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ function tpl (opts, defaultValue) {
|
||||
|
||||
var html =
|
||||
"<input type=\"search\" value=\"" + defaultValue + "\" />" +
|
||||
'<div class="results-panel"></div>' +
|
||||
'<div class="results-panel"></div>' +
|
||||
'</div>';
|
||||
var el = Docsify.dom.create('div', html);
|
||||
var aside = Docsify.dom.find('aside');
|
||||
@ -215,8 +215,11 @@ function bindEvents () {
|
||||
|
||||
var timeId;
|
||||
// Prevent to Fold sidebar
|
||||
Docsify.dom.on($search, 'click',
|
||||
function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); });
|
||||
Docsify.dom.on(
|
||||
$search,
|
||||
'click',
|
||||
function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); }
|
||||
);
|
||||
Docsify.dom.on($input, 'input', function (e) {
|
||||
clearTimeout(timeId);
|
||||
timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100);
|
||||
|
@ -37,5 +37,5 @@
|
||||
"integrity": "sha1-6DWIAbhrg7F1YNTjw4LXrvIQCUQ="
|
||||
}
|
||||
},
|
||||
"version": "4.3.6"
|
||||
"version": "4.3.7"
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "docsify-server-renderer",
|
||||
"version": "4.3.6",
|
||||
"version": "4.3.7",
|
||||
"description": "docsify server renderer",
|
||||
"author": {
|
||||
"name": "qingwei-li",
|
||||
|
Loading…
Reference in New Issue
Block a user