[build] 4.2.0

This commit is contained in:
qingwei.li 2017-07-10 22:40:38 +08:00
parent b430993f4f
commit 4dabae3bf2
No known key found for this signature in database
GPG Key ID: B6DDC2F7AE80B2F4
5 changed files with 61 additions and 19 deletions

View File

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

View File

@ -80,7 +80,8 @@ var config = merge({
mergeNavbar: false,
formatUpdated: '',
externalLinkTarget: '_blank',
routerModel: 'hash'
routerModel: 'hash',
noCompileLinks: []
}, window.$docsify);
var script = document.currentScript ||
@ -2717,8 +2718,9 @@ function parseQuery (query) {
query.split('&').forEach(function (param) {
var parts = param.replace(/\+/g, ' ').split('=');
res[parts[0]] = decode(parts[1]);
res[parts[0]] = parts[1] && decode(parts[1]);
});
return res
}
@ -2726,7 +2728,9 @@ function stringifyQuery (obj) {
var qs = [];
for (var key in obj) {
qs.push(((encode(key)) + "=" + (encode(obj[key]))).toLowerCase());
qs.push(obj[key]
? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase()
: encode(key));
}
return qs.length ? ("?" + (qs.join('&'))) : ''
@ -2757,6 +2761,8 @@ var cleanPath = cached(function (path) {
.replace(/([^:])\/{2,}/g, '$1/')
});
var cachedLinks = {};
var Compiler = function Compiler (config, router) {
this.config = config;
this.router = router;
@ -2791,6 +2797,19 @@ var Compiler = function Compiler (config, router) {
});
};
Compiler.prototype.matchNotCompileLink = function matchNotCompileLink (link) {
var links = this.config.noCompileLinks;
for (var i = 0; i < links.length; i++) {
var n = links[i];
var re = cachedLinks[n] || (cachedLinks[n] = new RegExp(("^" + n + "$")));
if (re.test(link)) {
return link
}
}
};
Compiler.prototype._initRenderer = function _initRenderer () {
var renderer = new marked.Renderer();
var ref = this;
@ -2834,11 +2853,16 @@ Compiler.prototype._initRenderer = function _initRenderer () {
};
renderer.link = function (href, title, text) {
var blank = '';
if (!/:|(\/{2})/.test(href)) {
if (!/:|(\/{2})/.test(href) &&
!_self.matchNotCompileLink(href) &&
!/(\s?:ignore)(\s\S+)?$/.test(title)) {
href = router.toURL(href, null, router.getCurrentPath());
} else {
blank = " target=\"" + linkTarget + "\"";
title = title && title.replace(/:ignore/g, '').trim();
}
if (title) {
title = " title=\"" + title + "\"";
}
@ -3200,6 +3224,10 @@ function renderMixin (proto) {
var this$1 = this;
if ( opt === void 0 ) opt = {};
if (!text) {
return renderMain.call(this, text)
}
callHook(this, 'beforeEach', text, function (result) {
var html = this$1.isHTML ? result : this$1.compiler.compile(result);
if (opt.updatedAt) {
@ -3298,8 +3326,15 @@ function initRender (vm) {
toggleClass(body, 'ready');
}
function getAlias (path, alias) {
return alias[path] ? getAlias(alias[path], alias) : path
var cached$1 = {};
function getAlias (path, alias, last) {
var match = Object.keys(alias).filter(function (key) {
var re = cached$1[key] || (cached$1[key] = new RegExp(("^" + key + "$")));
return re.test(path) && path !== last
})[0];
return match ? getAlias(path.replace(cached$1[match], alias[match]), alias, path) : path
}
function getFileName (path) {
@ -3623,17 +3658,24 @@ function fetchMixin (proto) {
// Current page is html
this.isHTML = /\.html$/g.test(path);
// Load main content
last.then(function (text, opt) {
this$1._renderMain(text, opt);
var loadSideAndNav = function () {
if (!loadSidebar) { return cb() }
var fn = function (result) { this$1._renderSidebar(result); cb(); };
// Load sidebar
loadNested(path, loadSidebar, fn, this$1, true);
};
// Load main content
last.then(function (text, opt) {
this$1._renderMain(text, opt);
loadSideAndNav();
},
function (_) { return this$1._renderMain(null); });
function (_) {
this$1._renderMain(null);
loadSideAndNav();
});
// Load nav
loadNavbar &&
@ -3758,7 +3800,7 @@ initGlobalAPI();
/**
* Version
*/
Docsify.version = '4.1.14';
Docsify.version = '4.2.0';
/**
* Run Docsify

4
lib/docsify.min.js vendored

File diff suppressed because one or more lines are too long

View File

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

View File

@ -44,7 +44,7 @@ export class Compiler {
})
}
matchNotCompileLink(link) {
matchNotCompileLink (link) {
const links = this.config.noCompileLinks
for (var i = 0; i < links.length; i++) {
@ -96,9 +96,9 @@ export class Compiler {
renderer.link = function (href, title, text) {
let blank = ''
if (!/:|(\/{2})/.test(href)
&& !_self.matchNotCompileLink(href)
&& !/(\s?:ignore)(\s\S+)?$/.test(title)) {
if (!/:|(\/{2})/.test(href) &&
!_self.matchNotCompileLink(href) &&
!/(\s?:ignore)(\s\S+)?$/.test(title)) {
href = router.toURL(href, null, router.getCurrentPath())
} else {
blank = ` target="${linkTarget}"`