Skip to content

Commit 4dabae3

Browse files
committed
[build] 4.2.0
1 parent b430993 commit 4dabae3

File tree

5 files changed

+61
-19
lines changed

5 files changed

+61
-19
lines changed

docs/_coverpage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![logo](_media/icon.svg)
22

3-
# docsify <small>4.1.14</small>
3+
# docsify <small>4.2.0</small>
44

55
> A magical documentation site generator.
66

lib/docsify.js

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ var config = merge({
8080
mergeNavbar: false,
8181
formatUpdated: '',
8282
externalLinkTarget: '_blank',
83-
routerModel: 'hash'
83+
routerModel: 'hash',
84+
noCompileLinks: []
8485
}, window.$docsify);
8586

8687
var script = document.currentScript ||
@@ -2717,16 +2718,19 @@ function parseQuery (query) {
27172718
query.split('&').forEach(function (param) {
27182719
var parts = param.replace(/\+/g, ' ').split('=');
27192720

2720-
res[parts[0]] = decode(parts[1]);
2721+
res[parts[0]] = parts[1] && decode(parts[1]);
27212722
});
2723+
27222724
return res
27232725
}
27242726

27252727
function stringifyQuery (obj) {
27262728
var qs = [];
27272729

27282730
for (var key in obj) {
2729-
qs.push(((encode(key)) + "=" + (encode(obj[key]))).toLowerCase());
2731+
qs.push(obj[key]
2732+
? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase()
2733+
: encode(key));
27302734
}
27312735

27322736
return qs.length ? ("?" + (qs.join('&'))) : ''
@@ -2757,6 +2761,8 @@ var cleanPath = cached(function (path) {
27572761
.replace(/([^:])\/{2,}/g, '$1/')
27582762
});
27592763

2764+
var cachedLinks = {};
2765+
27602766
var Compiler = function Compiler (config, router) {
27612767
this.config = config;
27622768
this.router = router;
@@ -2791,6 +2797,19 @@ var Compiler = function Compiler (config, router) {
27912797
});
27922798
};
27932799

2800+
Compiler.prototype.matchNotCompileLink = function matchNotCompileLink (link) {
2801+
var links = this.config.noCompileLinks;
2802+
2803+
for (var i = 0; i < links.length; i++) {
2804+
var n = links[i];
2805+
var re = cachedLinks[n] || (cachedLinks[n] = new RegExp(("^" + n + "$")));
2806+
2807+
if (re.test(link)) {
2808+
return link
2809+
}
2810+
}
2811+
};
2812+
27942813
Compiler.prototype._initRenderer = function _initRenderer () {
27952814
var renderer = new marked.Renderer();
27962815
var ref = this;
@@ -2834,11 +2853,16 @@ Compiler.prototype._initRenderer = function _initRenderer () {
28342853
};
28352854
renderer.link = function (href, title, text) {
28362855
var blank = '';
2837-
if (!/:|(\/{2})/.test(href)) {
2856+
2857+
if (!/:|(\/{2})/.test(href) &&
2858+
!_self.matchNotCompileLink(href) &&
2859+
!/(\s?:ignore)(\s\S+)?$/.test(title)) {
28382860
href = router.toURL(href, null, router.getCurrentPath());
28392861
} else {
28402862
blank = " target=\"" + linkTarget + "\"";
2863+
title = title && title.replace(/:ignore/g, '').trim();
28412864
}
2865+
28422866
if (title) {
28432867
title = " title=\"" + title + "\"";
28442868
}
@@ -3200,6 +3224,10 @@ function renderMixin (proto) {
32003224
var this$1 = this;
32013225
if ( opt === void 0 ) opt = {};
32023226

3227+
if (!text) {
3228+
return renderMain.call(this, text)
3229+
}
3230+
32033231
callHook(this, 'beforeEach', text, function (result) {
32043232
var html = this$1.isHTML ? result : this$1.compiler.compile(result);
32053233
if (opt.updatedAt) {
@@ -3298,8 +3326,15 @@ function initRender (vm) {
32983326
toggleClass(body, 'ready');
32993327
}
33003328

3301-
function getAlias (path, alias) {
3302-
return alias[path] ? getAlias(alias[path], alias) : path
3329+
var cached$1 = {};
3330+
3331+
function getAlias (path, alias, last) {
3332+
var match = Object.keys(alias).filter(function (key) {
3333+
var re = cached$1[key] || (cached$1[key] = new RegExp(("^" + key + "$")));
3334+
return re.test(path) && path !== last
3335+
})[0];
3336+
3337+
return match ? getAlias(path.replace(cached$1[match], alias[match]), alias, path) : path
33033338
}
33043339

33053340
function getFileName (path) {
@@ -3623,17 +3658,24 @@ function fetchMixin (proto) {
36233658
// Current page is html
36243659
this.isHTML = /\.html$/g.test(path);
36253660

3626-
// Load main content
3627-
last.then(function (text, opt) {
3628-
this$1._renderMain(text, opt);
3661+
var loadSideAndNav = function () {
36293662
if (!loadSidebar) { return cb() }
36303663

36313664
var fn = function (result) { this$1._renderSidebar(result); cb(); };
36323665

36333666
// Load sidebar
36343667
loadNested(path, loadSidebar, fn, this$1, true);
3668+
};
3669+
3670+
// Load main content
3671+
last.then(function (text, opt) {
3672+
this$1._renderMain(text, opt);
3673+
loadSideAndNav();
36353674
},
3636-
function (_) { return this$1._renderMain(null); });
3675+
function (_) {
3676+
this$1._renderMain(null);
3677+
loadSideAndNav();
3678+
});
36373679

36383680
// Load nav
36393681
loadNavbar &&
@@ -3758,7 +3800,7 @@ initGlobalAPI();
37583800
/**
37593801
* Version
37603802
*/
3761-
Docsify.version = '4.1.14';
3803+
Docsify.version = '4.2.0';
37623804

37633805
/**
37643806
* Run Docsify

lib/docsify.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/docsify-server-renderer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "docsify-server-renderer",
3-
"version": "4.1.14",
3+
"version": "4.2.0",
44
"description": "docsify server renderer",
55
"author": {
66
"name": "qingwei-li",

src/core/render/compiler.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class Compiler {
4444
})
4545
}
4646

47-
matchNotCompileLink(link) {
47+
matchNotCompileLink (link) {
4848
const links = this.config.noCompileLinks
4949

5050
for (var i = 0; i < links.length; i++) {
@@ -96,9 +96,9 @@ export class Compiler {
9696
renderer.link = function (href, title, text) {
9797
let blank = ''
9898

99-
if (!/:|(\/{2})/.test(href)
100-
&& !_self.matchNotCompileLink(href)
101-
&& !/(\s?:ignore)(\s\S+)?$/.test(title)) {
99+
if (!/:|(\/{2})/.test(href) &&
100+
!_self.matchNotCompileLink(href) &&
101+
!/(\s?:ignore)(\s\S+)?$/.test(title)) {
102102
href = router.toURL(href, null, router.getCurrentPath())
103103
} else {
104104
blank = ` target="${linkTarget}"`

0 commit comments

Comments
 (0)