- '+v(e.children)+"
diff --git a/docs/_coverpage.md b/docs/_coverpage.md index 0a84e863..74b8f328 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,6 +1,6 @@  -# docsify 2.2.1 +# docsify 2.3.0 > A magical documentation site generator. diff --git a/lib/docsify.js b/lib/docsify.js index 74e094ee..cacdf375 100644 --- a/lib/docsify.js +++ b/lib/docsify.js @@ -176,7 +176,6 @@ function emojify (text) { } - var utils = Object.freeze({ load: load, genTree: genTree, @@ -208,7 +207,9 @@ function scrollActiveSidebar () { for (var i = 0, len = lis.length; i < len; i += 1) { var li = lis[i]; - var href = li.querySelector('a').getAttribute('href'); + var a = li.querySelector('a'); + if (!a) { continue } + var href = a.getAttribute('href'); if (href !== '/') { var match = href.match('#([^#]+)$'); @@ -322,10 +323,12 @@ function bindToggle (dom) { } } +var scrollingElement = document.scrollingElement || document.documentElement; + function scroll2Top (offset) { if ( offset === void 0 ) offset = 0; - document.body.scrollTop = offset === true ? 0 : Number(offset); + scrollingElement.scrollTop = offset === true ? 0 : Number(offset); } function sticky () { @@ -2543,6 +2546,7 @@ function cssVars () { var markdown = marked; var toc = []; var CACHE = {}; +var originTitle = document.title; var renderTo = function (dom, content) { dom = typeof dom === 'object' ? dom : document.querySelector(dom); @@ -2579,10 +2583,9 @@ function init () { return ("
" + hl + "")
};
renderer.link = function (href, title, text) {
- if (!/:/.test(href)) {
+ if (!/:|(\/{2})/.test(href)) {
href = ("#/" + href).replace(/\/+/g, '/');
}
-
return ("" + text + "")
};
renderer.paragraph = function (text) {
@@ -2593,11 +2596,19 @@ function init () {
}
return ("" + text + "
") }; + renderer.image = function (href, title, text) { + var url = /:|(\/{2})/.test(href) ? href : ($docsify.basePath + href).replace(/\/+/g, '/'); + var titleHTML = title ? (" title=\"" + title + "\"") : ''; + + return ("'+t.slice(5).trim()+"
"}function w(e){return""}function x(e){e.innerHTML=e.innerHTML.replace(/var\(\s*--theme-color.*?\)/g,$docsify.themeColor)}function L(){if(!(window.CSS&&window.CSS.supports&&window.CSS.supports("(--foo: red)"))){var t=document.querySelectorAll("style:not(.inserted),link");[].forEach.call(t,function(t){if("STYLE"===t.nodeName)x(t);else if("LINK"===t.nodeName){var n=t.getAttribute("href");if(!/\.css$/.test(n))return;e(n).then(function(e){var t=document.createElement("style");t.innerHTML=e,document.head.appendChild(t),x(t)})}})}}function S(){var e=new F.Renderer;e.heading=function(e,t){var n=o(e),r="";return r="#/"+i(),H.push({level:t,slug:r+"#"+encodeURIComponent(n),title:e}),"'+n+""},e.link=function(e,t,n){return/:/.test(e)||(e=("#/"+e).replace(/\/+/g,"/")),''+n+""},e.paragraph=function(e){return/^!>/.test(e)?k("tip",e):/^\?>/.test(e)?k("warn",e):""+e+"
"},"function"==typeof $docsify.markdown?(z.setOptions({renderer:e}),z=$docsify.markdown.call(this,z)):z.setOptions(O({renderer:e},$docsify.markdown));var t=z;z=function(e){return s(t(e))},window.Docsify.utils.marked=function(e){var t=z(e);return H=[],t}}function $(e,t){var n=document.querySelector("nav")||document.createElement("nav"),r=document.body,i=document.head;if($docsify.repo||n.classList.add("no-badge"),e[t?"outerHTML":"innerHTML"]=f($docsify.repo)+($docsify.coverpage?y():"")+m(),r.insertBefore(n,r.children[0]),$docsify.themeColor&&(i.innerHTML+=w($docsify.themeColor),L()),$docsify.name){var o=document.querySelector(".sidebar");o.innerHTML='([^<]*?)
"+a(e.message+"",!0)+"";throw e}}var p={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:l,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:l,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:l,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};p.bullet=/(?:[*+-]|\d+\.)/,p.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,p.item=s(p.item,"gm")(/bull/g,p.bullet)(),p.list=s(p.list)(/bull/g,p.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+p.def.source+")")(),p.blockquote=s(p.blockquote)("def",p.def)(),p._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",p.html=s(p.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/
'+(n?e:a(e,!0))+"\n\n":""+(n?e:a(e,!0))+"\n"},r.prototype.blockquote=function(e){return"\n"+e+"\n"},r.prototype.html=function(e){return e},r.prototype.heading=function(e,t,n){return"
"+e+"
\n"},r.prototype.table=function(e,t){return""+e+""},r.prototype.br=function(){return this.options.xhtml?"'+n+""},e.link=function(e,t,n){return/:|(\/{2})/.test(e)||(e=("#/"+e).replace(/\/+/g,"/")),''+n+""},e.paragraph=function(e){return/^!>/.test(e)?k("tip",e):/^\?>/.test(e)?k("warn",e):""+e+"
"},e.image=function(e,t,n){var r=/:|(\/{2})/.test(e)?e:($docsify.basePath+e).replace(/\/+/g,"/"),i=t?' title="'+t+'"':"";return'([^<]*?)
"+o(e.message+"",!0)+"";throw e}}var d={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:l,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:l,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:l,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};d.bullet=/(?:[*+-]|\d+\.)/,d.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,d.item=s(d.item,"gm")(/bull/g,d.bullet)(),d.list=s(d.list)(/bull/g,d.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+d.def.source+")")(),d.blockquote=s(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=s(d.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/
1&&s.length>1||(e=o.slice(u+1).join("\n")+e,u=p-1)),i=r||/\n\n(?!\s*$)/.test(l),u!==p-1&&(r="\n"===l.charAt(l.length-1),i||(i=r)),h.tokens.push({type:i?"loose_item_start":"list_item_start"}),h.token(l,!1,n),h.tokens.push({type:"list_item_end"});h.tokens.push({type:"list_end"})}else if(o=h.rules.html.exec(e))e=e.substring(o[0].length),h.tokens.push({type:h.options.sanitize?"paragraph":"html",pre:!h.options.sanitizer&&("pre"===o[1]||"script"===o[1]||"style"===o[1]),text:o[0]});else if(!n&&t&&(o=h.rules.def.exec(e)))e=e.substring(o[0].length),h.tokens.links[o[1].toLowerCase()]={href:o[2],title:o[3]};else if(t&&(o=h.rules.table.exec(e))){for(e=e.substring(o[0].length),l={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/(?: *\| *)?\n$/,"").split("\n")},u=0;u "+e+"
\n":"'+(n?e:o(e,!0))+"\n
"},r.prototype.blockquote=function(e){return""+(n?e:o(e,!0))+"\n\n"+e+"
\n"},r.prototype.html=function(e){return e},r.prototype.heading=function(e,t,n){return"
\n":"
\n"},r.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+""+n+">\n"},r.prototype.listitem=function(e){return"\n\n"+e+"\n\n"+t+"\n
\n"},r.prototype.tablerow=function(e){return"\n"+e+" \n"},r.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"},r.prototype.strong=function(e){return""+e+""},r.prototype.em=function(e){return""+e+""},r.prototype.codespan=function(e){return""+e+""},r.prototype.br=function(){return this.options.xhtml?"
":"
"},r.prototype.del=function(e){return""+e+""},r.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(a(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(e){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var i='"+n+""},r.prototype.image=function(e,t,n){var r='":">"},r.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 n(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var r="";this.next();)r+=t.tok();return r},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,i,o,a="",s="";for(r="",t=0;t