- '+y(e.children)+"
diff --git a/docs/_coverpage.md b/docs/_coverpage.md
index de2b7ebf..8088b43f 100644
--- a/docs/_coverpage.md
+++ b/docs/_coverpage.md
@@ -1,6 +1,6 @@

-# docsify 1.4.3
+# docsify 1.5.0
> A magical documentation site generator.
diff --git a/lib/docsify.js b/lib/docsify.js
index 1883f764..1fed88d0 100644
--- a/lib/docsify.js
+++ b/lib/docsify.js
@@ -118,6 +118,7 @@ function slugify (string) {
var re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g;
var maintainCase = false;
var replacement = '-';
+
slugify.occurrences = slugify.occurrences || {};
if (typeof string !== 'string') { return '' }
@@ -143,6 +144,27 @@ function slugify (string) {
return slug
}
+slugify.clear = function () {
+ slugify.occurrences = {};
+};
+
+var hasOwnProperty = Object.prototype.hasOwnProperty;
+var merge = Object.assign || function (to) {
+ var arguments$1 = arguments;
+
+ for (var i = 1; i < arguments.length; i++) {
+ var from = Object(arguments$1[i]);
+
+ for (var key in from) {
+ if (hasOwnProperty.call(from, key)) {
+ to[key] = from[key];
+ }
+ }
+ }
+
+ return to
+};
+
/**
* Active sidebar when scroll
* @link https://buble.surge.sh/
@@ -2411,50 +2433,66 @@ function tree (toc, tpl) {
}
var OPTIONS$1 = {};
+var markdown = marked;
+var toc = [];
var CACHE = {};
var renderTo = function (dom, content) {
dom = typeof dom === 'object' ? dom : document.querySelector(dom);
dom.innerHTML = content;
+ slugify.clear();
return dom
};
-var toc = [];
-var renderer = new marked.Renderer();
/**
- * render anchor tag
- * @link https://github.com/chjj/marked#overriding-renderer-methods
+ * init render
+ * @param {Object} options
*/
-renderer.heading = function (text, level) {
- var slug = slugify(text);
- var route = '';
+function init (options) {
+ OPTIONS$1 = options;
- if (OPTIONS$1.router) {
- route = "#/" + (getRoute());
+ var renderer = new marked.Renderer();
+ /**
+ * render anchor tag
+ * @link https://github.com/chjj/marked#overriding-renderer-methods
+ */
+ renderer.heading = function (text, level) {
+ var slug = slugify(text);
+ var route = '';
+
+ if (OPTIONS$1.router) {
+ route = "#/" + (getRoute());
+ }
+
+ toc.push({ level: level, slug: (route + "#" + (encodeURIComponent(slug))), title: text });
+
+ return ("
" + hl + "")
+ };
+ renderer.link = function (href, title, text) {
+ if (OPTIONS$1.router && !/:/.test(href)) {
+ href = ("#/" + href).replace(/\/\//g, '/');
+ }
+
+ return ("" + text + "")
+ };
+
+ if (typeof OPTIONS$1.markdown === 'function') {
+ markdown.setOptions({ renderer: renderer });
+ markdown = OPTIONS$1.markdown.call(this, markdown);
+ } else {
+ markdown.setOptions(merge({ renderer: renderer }, OPTIONS$1.markdown));
}
-
- toc.push({ level: level, slug: (route + "#" + (encodeURIComponent(slug))), title: text });
-
- return ("" + hl + "")
-};
-renderer.link = function (href, title, text) {
- if (OPTIONS$1.router && !/:/.test(href)) {
- href = ("#/" + href).replace(/\/\//g, '/');
- }
-
- return ("" + text + "")
-};
-marked.setOptions({ renderer: renderer });
+}
/**
* App
@@ -2483,7 +2521,7 @@ function renderApp (dom, replace) {
* article
*/
function renderArticle (content) {
- renderTo('article', content ? marked(content) : 'not found');
+ renderTo('article', content ? markdown(content) : 'not found');
if (!OPTIONS$1.sidebar && !OPTIONS$1.loadSidebar) { renderSidebar(); }
if (content && typeof Vue !== 'undefined' && typeof Vuep !== 'undefined') {
@@ -2500,7 +2538,7 @@ function renderNavbar (content) {
if (CACHE.navbar && CACHE.navbar === content) { return }
CACHE.navbar = content;
- if (content) { renderTo('nav', marked(content)); }
+ if (content) { renderTo('nav', markdown(content)); }
activeLink('nav');
}
@@ -2511,7 +2549,7 @@ function renderSidebar (content) {
var html;
if (content) {
- html = marked(content);
+ html = markdown(content);
} else if (OPTIONS$1.sidebar) {
html = tree(OPTIONS$1.sidebar, '"+s(e.message+"",!0)+"";throw e}}var d={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:u,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:u,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:u,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};d.bullet=/(?:[*+-]|\d+\.)/,d.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,d.item=l(d.item,"gm")(/bull/g,d.bullet)(),d.list=l(d.list)(/bull/g,d.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+d.def.source+")")(),d.blockquote=l(d.blockquote)("def",d.def)(),d._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",d.html=l(d.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/
1&&o.length>1||(e=i.slice(c+1).join("\n")+e,c=p-1)),a=r||/\n\n(?!\s*$)/.test(l),c!==p-1&&(r="\n"===l.charAt(l.length-1),a||(a=r)),g.tokens.push({type:a?"loose_item_start":"list_item_start"}),g.token(l,!1,n),g.tokens.push({type:"list_item_end"});g.tokens.push({type:"list_end"})}else if(i=g.rules.html.exec(e))e=e.substring(i[0].length),g.tokens.push({type:g.options.sanitize?"paragraph":"html",pre:!g.options.sanitizer&&("pre"===i[1]||"script"===i[1]||"style"===i[1]),text:i[0]});else if(!n&&t&&(i=g.rules.def.exec(e)))e=e.substring(i[0].length),g.tokens.links[i[1].toLowerCase()]={href:i[2],title:i[3]};else if(t&&(i=g.rules.table.exec(e))){for(e=e.substring(i[0].length),l={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/(?: *\| *)?\n$/,"").split("\n")},c=0;c "+e+"
\n":"'+(n?e:s(e,!0))+"\n
"},a.prototype.blockquote=function(e){return""+(n?e:s(e,!0))+"\n\n"+e+"
\n"},a.prototype.html=function(e){return e},a.prototype.heading=function(e,t,n){return"
\n":"
\n"},a.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+""+n+">\n"},a.prototype.listitem=function(e){return"\n\n"+e+"\n\n"+t+"\n
\n"},a.prototype.tablerow=function(e){return"\n"+e+" \n"},a.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+""+n+">\n"},a.prototype.strong=function(e){return""+e+""},a.prototype.em=function(e){return""+e+""},a.prototype.codespan=function(e){return""+e+""},a.prototype.br=function(){return this.options.xhtml?"
":"
"},a.prototype.del=function(e){return""+e+""},a.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(o(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var a='"+n+""},a.prototype.image=function(e,t,n){var r='":">"},a.prototype.text=function(e){return e},i.parse=function(e,t,n){var r=new i(t,n);return r.parse(e)},i.prototype.parse=function(e){var t=this;this.inline=new r(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var n="";this.next();)n+=t.tok();return n},i.prototype.next=function(){return this.token=this.tokens.pop()},i.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},i.prototype.parseText=function(){for(var e=this,t=this.token.text;"text"===this.peek().type;)t+="\n"+e.next().text;return this.inline.output(t)},i.prototype.tok=function(){var e=this;switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var t,n,r,a,i,s="",o="";for(r="",t=0;t