From c6f760275cb703a5d2ab024bdc8abef9c468769a Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Mon, 13 Feb 2017 23:06:30 +0800 Subject: [PATCH 001/746] feat(hook): add doneEach --- CHANGELOG.md | 9 +++++++++ docs/plugins.md | 9 +++++++-- docs/zh-cn/plugins.md | 9 +++++++-- src/hook.js | 5 +++++ src/index.js | 1 + src/plugins/search.js | 2 +- 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0365bbf..f8381b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +### 2.4.0 + +> 2017-02-13 + +#### Features + +- feat(hook): add `doneEach` + + ### 2.3.0 > 2017-02-13 diff --git a/docs/plugins.md b/docs/plugins.md index 402588f..2dd75e9 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -67,7 +67,7 @@ window.$docsify = { plugins: [ function (hook) { hook.init(function() { - // Called when the script starts running, only trigger once. + // Called when the script starts running, only trigger once, no arguments, }) hook.beforeEach(function(content) { @@ -84,8 +84,13 @@ window.$docsify = { next(html) }) + hook.doneEach(function() { + // Invoked each time after the data is fully loaded, no arguments, + // ... + }) + hook.ready(function() { - // Called after initialization is complete. Only trigger once. + // Called after initialization is complete. Only trigger once, no arguments. }) } ] diff --git a/docs/zh-cn/plugins.md b/docs/zh-cn/plugins.md index 30bcdd5..9fd249b 100644 --- a/docs/zh-cn/plugins.md +++ b/docs/zh-cn/plugins.md @@ -63,7 +63,7 @@ window.$docsify = { plugins: [ function (hook) { hook.init(function() { - // 初始化时调用,只调用一次 + // 初始化时调用,只调用一次,没有参数。 }) hook.beforeEach(function(content) { @@ -79,8 +79,13 @@ window.$docsify = { next(html) }) + hook.doneEach(function() { + // 每次路由切换时数据全部加载完成后调用,没有参数。 + // ... + }) + hook.ready(function() { - // docsify 初始化完成后调用,只调用一次 + // 初始化完成后调用,只调用一次,没有参数。 }) } ] diff --git a/src/hook.js b/src/hook.js index 311103d..401765a 100644 --- a/src/hook.js +++ b/src/hook.js @@ -4,6 +4,7 @@ export default class Hook { this.afterHooks = [] this.initHooks = [] this.readyHooks = [] + this.doneEachHooks = [] } beforeEach (fn) { @@ -14,6 +15,10 @@ export default class Hook { this.afterHooks.push(fn) } + doneEach (fn) { + this.doneEachHooks.push(fn) + } + init (fn) { this.initHooks.push(fn) } diff --git a/src/index.js b/src/index.js index 066d094..75243a6 100644 --- a/src/index.js +++ b/src/index.js @@ -130,6 +130,7 @@ const Docsify = function () { mainRender(_ => { scrollIntoView() activeLink('nav') + window.Docsify.hook.emit('doneEach') }) } diff --git a/src/plugins/search.js b/src/plugins/search.js index b76e1d0..0f0e762 100644 --- a/src/plugins/search.js +++ b/src/plugins/search.js @@ -342,7 +342,7 @@ const install = function () { new SearchComponent() !isAuto && searchPlugin() }) - isAuto && hook.beforeEach(searchPlugin) + isAuto && hook.doneEach(searchPlugin) }, window.$docsify.plugins) } From 44d7257691db8b036317d9e43a572f6de348a6df Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Mon, 13 Feb 2017 23:07:54 +0800 Subject: [PATCH 002/746] bump: 2.4.0 --- lib/docsify.js | 6 ++++++ lib/docsify.min.js | 4 ++-- lib/plugins/search.js | 2 +- lib/plugins/search.min.js | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/docsify.js b/lib/docsify.js index cacdf37..dd41db4 100644 --- a/lib/docsify.js +++ b/lib/docsify.js @@ -2818,6 +2818,7 @@ var Hook = function Hook () { this.afterHooks = []; this.initHooks = []; this.readyHooks = []; + this.doneEachHooks = []; }; Hook.prototype.beforeEach = function beforeEach (fn) { @@ -2828,6 +2829,10 @@ Hook.prototype.afterEach = function afterEach (fn) { this.afterHooks.push(fn); }; +Hook.prototype.doneEach = function doneEach (fn) { + this.doneEachHooks.push(fn); +}; + Hook.prototype.init = function init (fn) { this.initHooks.push(fn); }; @@ -2991,6 +2996,7 @@ var Docsify = function () { mainRender(function (_) { scrollIntoView(); activeLink('nav'); + window.Docsify.hook.emit('doneEach'); }); }; diff --git a/lib/docsify.min.js b/lib/docsify.min.js index 01d5c58..821df19 100644 --- a/lib/docsify.min.js +++ b/lib/docsify.min.js @@ -1,2 +1,2 @@ -var D=function(){"use strict";function e(e,t,n){void 0===t&&(t="GET");var r=new XMLHttpRequest;return r.open(t,e),r.send(),{then:function(e,t){if(void 0===t&&(t=function(){}),n){var i=setInterval(function(e){return n({step:Math.floor(5*Math.random()+1)})},500);r.addEventListener("progress",n),r.addEventListener("loadend",function(e){n(e),clearInterval(i)})}r.addEventListener("error",t),r.addEventListener("load",function(n){var r=n.target;r.status>=400?t(r):e(r.response)})},abort:function(){return 4!==r.readyState&&r.abort()}}}function t(e,t){var n=[],r={};return e.forEach(function(e){var i=e.level||1,o=i-1;i>t||(r[o]?(r[o].children=r[o].children||[],r[o].children.push(e)):n.push(e),r[i]=e)}),n}function n(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}function r(e){return null===e||void 0===e}function i(){var e=window.location;if(M===e.hash&&!r(j))return j;var t=e.hash.replace(/%23/g,"#").match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,j=t,M=e.hash,t}function o(){return document.body.clientWidth<=600}function a(e){var t=/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g,n=!1,r="-";if(a.occurrences=a.occurrences||{},"string"!=typeof e)return"";n||(e=e.toLowerCase());var i=e.trim().replace(/<[^>\d]+>/g,"").replace(t,"").replace(/\s/g,r).replace(/-+/g,r).replace(/^(\d)/,"_$1"),o=a.occurrences[i];return a.occurrences.hasOwnProperty(i)?o++:o=0,a.occurrences[i]=o,o&&(i=i+"-"+o),i}function s(e){return e.replace(/<(pre|template)[^>]*?>([\s\S]+)<\/(pre|template)>/g,function(e){return e.replace(/:/g,"__colon__")}).replace(/:(\w*?):/gi,'$1').replace(/__colon__/g,":")}function l(){function e(){for(var e,o=document.body.scrollTop,l=0,u=n.length;lo){e||(e=d);break}e=d}if(e){var p=s[e.getAttribute("data-id")];if(p&&p!==c&&(c&&c.classList.remove("active"),p.classList.add("active"),c=p,!t&&!h.noSticky)){var g=0,f=c.offsetTop+c.clientHeight+40,m=c.offsetTop>=i.scrollTop&&f<=i.scrollTop+a,y=f-g=e||h.dom.classList.contains("hidden")?(document.body.classList.add("sticky"),h.noSticky=!1):(document.body.classList.remove("sticky"),h.noSticky=!0)}()}function g(e,t){return t={exports:{}},e(t,t.exports),t.exports}function f(e){return e?(/\/\//.test(e)||(e="https://github.com/"+e),e=e.replace(/^git\+/,""),'\n \n \n '):""}function m(){var e=b()+'';return(o()?e+"
":"
"+e)+'
\n
\n
\n
'}function y(){var e=", 100%, 85%",t="linear-gradient(to left bottom, hsl("+(Math.floor(255*Math.random())+e)+") 0%, hsl("+(Math.floor(255*Math.random())+e)+") 100%)";return'
\n
\n
\n
'}function b(){return''}function v(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='
  • '+e.title+"
  • ",e.children&&(t+='
    • '+v(e.children)+"
    ")}),t):""}function k(e,t){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=a(e),r="";return r="#/"+i(),D.push({level:t,slug:r+"#"+encodeURIComponent(n),title:e}),"'+e+""},e.code=function(e,t){void 0===t&&(t="");var n=W.highlight(e,W.languages[t]||W.languages.markup);return'
    '+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''+n+'"},"function"==typeof $docsify.markdown?z=$docsify.markdown.call(this,z,e):($docsify.markdown&&$docsify.markdown.renderer&&($docsify.markdown.renderer=O(e,$docsify.markdown.renderer)),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 D=[],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 a=document.querySelector(".sidebar");a.innerHTML='

    '+$docsify.name+"

    "+a.innerHTML}d("button.sidebar-toggle"),$docsify.coverpage?!o()&&window.addEventListener("scroll",h):r.classList.add("sticky")}function _(e){var t=window.Docsify.hook,n=function(e){if(G("article",e),$docsify.loadSidebar||E(),e&&"undefined"!=typeof Vue){R.vm&&R.vm.$destroy();var t=[].slice.call(document.body.querySelectorAll("article>script")).filter(function(e){return!/template/.test(e.type)})[0],n=t?t.innerText.trim():null;t&&t.remove(),R.vm=n?new Function("return "+n)():new Vue({el:"main"}),R.vm&&R.vm.$nextTick(function(e){return l()})}$docsify.auto2top&&setTimeout(function(){return p($docsify.auto2top)},0)};t.emit("before",e,function(e){var r=e?z(e):"";t.emit("after",r,function(e){return n(e||"not found")})})}function C(e){R.navbar&&R.navbar===e||(R.navbar=e,e&&G("nav",z(e)),u("nav"))}function E(e){var n;e?(n=z(e),n=n.match(/]*>([\s\S]+)<\/ul>/g)[0]):n=v(t(D,$docsify.maxLevel),"
      "),G(".sidebar-nav",n),D[0]&&1===D[0].level&&(document.title=""+D[0].title+(B?" - "+B:""));var r=u(".sidebar-nav",!0);r&&A(r),D=[],l()}function A(e){$docsify.subMaxLevel&&(D[0]&&1===D[0].level&&D.shift(),e.parentNode.innerHTML+=v(t(D,$docsify.subMaxLevel),"
        "))}function T(e){if(T.dom=T.dom||document.querySelector("section.cover"),!e)return void T.dom.classList.remove("show");if(T.dom.classList.add("show"),T.rendered)return h();var t=D.slice(),n=z(e),r=n.trim().match('

        ([^<]*?)

        $');if(D=t.slice(),r){var i=document.querySelector("section.cover");"color"===r[2]?i.style.background=r[1]+(r[3]||""):(i.classList.add("has-mask"),i.style.backgroundImage="url("+r[1]+")"),n=n.replace(r[0],"")}G(".cover-main",n),T.rendered=!0,h()}function q(e){var t,n=e.loaded,r=e.total,i=e.step;if(!R.loading){var o=document.createElement("div");o.classList.add("progress"),document.body.appendChild(o),R.loading=o}i?(t=parseInt(R.loading.style.width,10)+i,t=t>80?80:t):t=Math.floor(n/r*100),R.loading.style.opacity=1,R.loading.style.width=t>=95?"100%":t+"%",t>=95&&(clearTimeout(q.cacheTimeout),q.cacheTimeout=setTimeout(function(e){R.loading.style.opacity=0,R.loading.style.width="0%"},200))}var j=null,M=null;a.clear=function(){a.occurrences={}};var N=Object.prototype.hasOwnProperty,O=Object.assign||function(e){for(var t=arguments,n=1;n/g,">").replace(/"/g,""").replace(/'/g,"'")}function a(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function s(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function l(){}function c(e){for(var t,n,r=arguments,i=1;iAn error occured:

        "+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:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\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",/])*?>/)(/tag/g,d._tag)(),d.paragraph=s(d.paragraph)("hr",d.hr)("heading",d.heading)("lheading",d.lheading)("blockquote",d.blockquote)("tag","<"+d._tag)("def",d.def)(),d.normal=c({},d),d.gfm=c({},d.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),d.gfm.paragraph=s(d.paragraph)("(?!","(?!"+d.gfm.fences.source.replace("\\1","\\2")+"|"+d.list.source.replace("\\1","\\3")+"|")(),d.tables=c({},d.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=d,t.lex=function(e,n){var r=new t(n);return r.lex(e)},t.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},t.prototype.token=function(e,t,n){for(var r,i,o,a,s,l,c,u,p,h=this,e=e.replace(/^ +$/gm,"");e;)if((o=h.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&h.tokens.push({type:"space"})),o=h.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),h.tokens.push({type:"code",text:h.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=h.rules.fences.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"code",lang:o[2],text:o[3]||""});else if(o=h.rules.heading.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=h.rules.nptable.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 ?/gm,""),h.token(o,t,!0),h.tokens.push({type:"blockquote_end"});else if(o=h.rules.list.exec(e)){for(e=e.substring(o[0].length),a=o[2],h.tokens.push({type:"list_start",ordered:a.length>1}),o=o[0].match(h.rules.item),r=!1,p=o.length,u=0;u1&&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])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:l,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:l,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,p.link=s(p.link)("inside",p._inside)("href",p._href)(),p.reflink=s(p.reflink)("inside",p._inside)(),p.normal=c({},p),p.pedantic=c({},p.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),p.gfm=c({},p.normal,{escape:s(p.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:s(p.text)("]|","~]|")("|","|https?://|")()}),p.breaks=c({},p.gfm,{br:s(p.br)("{2,}","*")(),text:s(p.gfm.text)("{2,}","*")()}),n.rules=p,n.output=function(e,t,r){var i=new n(t,r);return i.output(e)},n.prototype.output=function(e){for(var t,n,r,i,a=this,s="";e;)if(i=a.rules.escape.exec(e))e=e.substring(i[0].length),s+=i[1];else if(i=a.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=":"===i[1].charAt(6)?a.mangle(i[1].substring(7)):a.mangle(i[1]),r=a.mangle("mailto:")+n):(n=o(i[1]),r=n),s+=a.renderer.link(r,null,n);else if(a.inLink||!(i=a.rules.url.exec(e))){if(i=a.rules.tag.exec(e))!a.inLink&&/^/i.test(i[0])&&(a.inLink=!1),e=e.substring(i[0].length),s+=a.options.sanitize?a.options.sanitizer?a.options.sanitizer(i[0]):o(i[0]):i[0];else if(i=a.rules.link.exec(e))e=e.substring(i[0].length),a.inLink=!0,s+=a.outputLink(i,{href:i[2],title:i[3]}),a.inLink=!1;else if((i=a.rules.reflink.exec(e))||(i=a.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=a.links[t.toLowerCase()],!t||!t.href){s+=i[0].charAt(0),e=i[0].substring(1)+e;continue}a.inLink=!0,s+=a.outputLink(i,t),a.inLink=!1}else if(i=a.rules.strong.exec(e))e=e.substring(i[0].length),s+=a.renderer.strong(a.output(i[2]||i[1]));else if(i=a.rules.em.exec(e))e=e.substring(i[0].length),s+=a.renderer.em(a.output(i[2]||i[1]));else if(i=a.rules.code.exec(e))e=e.substring(i[0].length),s+=a.renderer.codespan(o(i[2],!0));else if(i=a.rules.br.exec(e))e=e.substring(i[0].length),s+=a.renderer.br();else if(i=a.rules.del.exec(e))e=e.substring(i[0].length),s+=a.renderer.del(a.output(i[1]));else if(i=a.rules.text.exec(e))e=e.substring(i[0].length),s+=a.renderer.text(o(a.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=o(i[1]),r=n,s+=a.renderer.link(r,null,n);return s},n.prototype.outputLink=function(e,t){var n=o(t.href),r=t.title?o(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,o(e[1]))},n.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},n.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;i.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},r.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'
        '+(n?e:o(e,!0))+"\n
        \n":"
        "+(n?e:o(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.hr=function(){return this.options.xhtml?"
        \n":"
        \n"},r.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},r.prototype.listitem=function(e){return"
      • "+e+"
      • \n"},r.prototype.paragraph=function(e){return"

        "+e+"

        \n"},r.prototype.table=function(e,t){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"},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='
        "},r.prototype.image=function(e,t,n){var r=''+n+'":">"},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;te.length)break e;if(!(v instanceof i)){u.lastIndex=0;var k=u.exec(v),w=1;if(!k&&h&&y!=o.length-1){if(u.lastIndex=b,k=u.exec(e),!k)break;for(var x=k.index+(p?k[1].length:0),L=k.index+k[0].length,S=y,$=b,_=o.length;S<_&&$=$&&(++y,b=$);if(o[y]instanceof i||o[S-1].greedy)continue;w=S-y,v=e.slice(b,$),k.index-=b}if(k){p&&(g=k[1].length);var x=k.index+g,k=k[0].slice(g),L=x+k.length,C=v.slice(0,x),E=v.slice(L),A=[y,w];C&&A.push(C);var T=new i(s,d?r.tokenize(k,d):k,f,k,h);A.push(T),E&&A.push(E),Array.prototype.splice.apply(o,A)}}}}}return o},hooks:{all:{},add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=r.hooks.all[e];if(n&&n.length)for(var i,o=0;i=n[o++];)i(t)}}},i=r.Token=function(e,t,n,r,i){this.type=e,this.content=t,this.alias=n,this.length=0|(r||"").length,this.greedy=!!i};if(i.stringify=function(e,t,n){if("string"==typeof e)return e;if("Array"===r.util.type(e))return e.map(function(n){return i.stringify(n,t,e)}).join("");var o={type:e.type,content:i.stringify(e.content,t,n),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:n};if("comment"==o.type&&(o.attributes.spellcheck="true"),e.alias){var a="Array"===r.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(o.classes,a)}r.hooks.run("wrap",o);var s=Object.keys(o.attributes).map(function(e){return e+'="'+(o.attributes[e]||"").replace(/"/g,""")+'"'}).join(" ");return"<"+o.tag+' class="'+o.classes.join(" ")+'"'+(s?" "+s:"")+">"+o.content+""},!t.document)return t.addEventListener?(t.addEventListener("message",function(e){var n=JSON.parse(e.data),i=n.language,o=n.code,a=n.immediateClose; -t.postMessage(r.highlight(o,r.languages[i],i)),a&&t.close()},!1),t.Prism):t.Prism;var o=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return o&&(r.filename=o.src,document.addEventListener&&!o.hasAttribute("data-manual")&&("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(r.highlightAll):window.setTimeout(r.highlightAll,16):document.addEventListener("DOMContentLoaded",r.highlightAll))),t.Prism}();e.exports&&(e.exports=n),"undefined"!=typeof I&&(I.Prism=n),n.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},n.hooks.add("wrap",function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))}),n.languages.xml=n.languages.markup,n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:{pattern:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},n.languages.css.atrule.inside.rest=n.util.clone(n.languages.css),n.languages.markup&&(n.languages.insertBefore("markup","tag",{style:{pattern:/()[\w\W]*?(?=<\/style>)/i,lookbehind:!0,inside:n.languages.css,alias:"language-css"}}),n.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:n.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:n.languages.css}},alias:"language-css"}},n.languages.markup.tag)),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:{pattern:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(true|false)\b/,function:/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,function:/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/}),n.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0,greedy:!0}}),n.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\\\|\\?[^\\])*?`/,greedy:!0,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}}}),n.languages.markup&&n.languages.insertBefore("markup","tag",{script:{pattern:/()[\w\W]*?(?=<\/script>)/i,lookbehind:!0,inside:n.languages.javascript,alias:"language-javascript"}}),n.languages.js=n.languages.javascript,function(){"undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.forEach&&Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var r,i=t.getAttribute("data-src"),o=t,a=/\blang(?:uage)?-(?!\*)(\w+)\b/i;o&&!a.test(o.className);)o=o.parentNode;if(o&&(r=(t.className.match(a)||[,""])[1]),!r){var s=(i.match(/\.(\w+)$/)||[,""])[1];r=e[s]||s}var l=document.createElement("code");l.className="language-"+r,t.textContent="",l.textContent="Loading…",t.appendChild(l);var c=new XMLHttpRequest;c.open("GET",i,!0),c.onreadystatechange=function(){4==c.readyState&&(c.status<400&&c.responseText?(l.textContent=c.responseText,n.highlightElement(l)):c.status>=400?l.textContent="✖ Error "+c.status+" while fetching file: "+c.statusText:l.textContent="✖ Error: File does not exist or is empty")},c.send(null)})},document.addEventListener("DOMContentLoaded",self.Prism.fileHighlight))}()}),z=F,D=[],R={},B=document.title,G=function(e,t){return e="object"==typeof e?e:document.querySelector(e),e.innerHTML=t,a.clear(),e},Z=function(){this.beforeHooks=[],this.afterHooks=[],this.initHooks=[],this.readyHooks=[]};Z.prototype.beforeEach=function(e){this.beforeHooks.push(e)},Z.prototype.afterEach=function(e){this.afterHooks.push(e)},Z.prototype.init=function(e){this.initHooks.push(e)},Z.prototype.ready=function(e){this.readyHooks.push(e)},Z.prototype.emit=function(e,t,n){var r=t,i=this[e+"Hooks"],o=function(e){var a=i[e];if(e>=i.length)n&&n(r);else if("function"==typeof a)if(2===a.length)a(t,function(t){r=t,o(e+1)});else{var s=a(t);r=void 0!==s?s:r,o(e+1)}else o(e+1)};o(0)};var U=O({el:"#app",repo:"",maxLevel:6,subMaxLevel:0,loadSidebar:null,loadNavbar:null,homepage:"README.md",coverpage:"",basePath:"",auto2top:!1,name:"",themeColor:"",nameLink:window.location.pathname,ga:""},window.$docsify),V=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();if(V){for(var Y in U){var J=V.getAttribute("data-"+n(Y));U[Y]=r(J)?U[Y]:J||!0}U.loadSidebar===!0&&(U.loadSidebar="_sidebar.md"),U.loadNavbar===!0&&(U.loadNavbar="_navbar.md"),U.coverpage===!0&&(U.coverpage="_coverpage.md"),U.repo===!0&&(U.repo=""),U.name===!0&&(U.name="")}var X=new Z;window.$docsify=U,window.Docsify={installed:!0,utils:O({},P),hook:X},S();var K=null,Q=null,ee=function(e){return U.alias[e]?ee(U.alias[e]):e},te=function(t){var n,r=i();if(K===r)return t();var o=K=U.basePath+r;/\//.test(o)?o&&!/\/$/.test(o)&&(o=o.match(/(\S*\/)[^\/]+$/)[1]):o="",r="/"+r,r=U.alias&&U.alias[r]?ee(r):(U.basePath+r).replace(/\/+/,"/"),n=r?/\.md$/.test(r)?r:/\/$/.test(r)?r+"README.md":r+".md":U.homepage||"README.md",U.coverpage&&n===U.homepage&&e(U.coverpage).then(T),Q&&Q.abort&&Q.abort(),Q=e(n,"GET",q),Q.then(function(r){if(_(r),U.coverpage&&n!==U.homepage&&T(),U.loadSidebar){var i=function(e){E(e),t()};e(o+U.loadSidebar).then(i,function(t){return e(U.loadSidebar).then(i)})}else t()},function(e){return _(null)}),U.loadNavbar&&e(o+U.loadNavbar).then(C,function(t){return e(U.loadNavbar).then(C)})},ne=function(){setTimeout(function(e){[].concat(U.plugins).forEach(function(e){return"function"==typeof e&&e(X)}),window.Docsify.hook.emit("init");var t=document.querySelector(U.el)||document.body,n=t!==document.body,r=function(){te(function(e){c(),u("nav")})};$(t,n),r(),/^#\//.test(window.location.hash)||(window.location.hash="#/"),window.addEventListener("hashchange",r),window.Docsify.hook.emit("ready")},0)},re=ne();return re}(); +var D=function(){"use strict";function e(e,t,n){void 0===t&&(t="GET");var r=new XMLHttpRequest;return r.open(t,e),r.send(),{then:function(e,t){if(void 0===t&&(t=function(){}),n){var i=setInterval(function(e){return n({step:Math.floor(5*Math.random()+1)})},500);r.addEventListener("progress",n),r.addEventListener("loadend",function(e){n(e),clearInterval(i)})}r.addEventListener("error",t),r.addEventListener("load",function(n){var r=n.target;r.status>=400?t(r):e(r.response)})},abort:function(){return 4!==r.readyState&&r.abort()}}}function t(e,t){var n=[],r={};return e.forEach(function(e){var i=e.level||1,o=i-1;i>t||(r[o]?(r[o].children=r[o].children||[],r[o].children.push(e)):n.push(e),r[i]=e)}),n}function n(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}function r(e){return null===e||void 0===e}function i(){var e=window.location;if(M===e.hash&&!r(j))return j;var t=e.hash.replace(/%23/g,"#").match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,j=t,M=e.hash,t}function o(){return document.body.clientWidth<=600}function a(e){var t=/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g,n=!1,r="-";if(a.occurrences=a.occurrences||{},"string"!=typeof e)return"";n||(e=e.toLowerCase());var i=e.trim().replace(/<[^>\d]+>/g,"").replace(t,"").replace(/\s/g,r).replace(/-+/g,r).replace(/^(\d)/,"_$1"),o=a.occurrences[i];return a.occurrences.hasOwnProperty(i)?o++:o=0,a.occurrences[i]=o,o&&(i=i+"-"+o),i}function s(e){return e.replace(/<(pre|template)[^>]*?>([\s\S]+)<\/(pre|template)>/g,function(e){return e.replace(/:/g,"__colon__")}).replace(/:(\w*?):/gi,'$1').replace(/__colon__/g,":")}function l(){function e(){for(var e,o=document.body.scrollTop,l=0,u=n.length;lo){e||(e=d);break}e=d}if(e){var p=s[e.getAttribute("data-id")];if(p&&p!==c&&(c&&c.classList.remove("active"),p.classList.add("active"),c=p,!t&&!h.noSticky)){var g=0,f=c.offsetTop+c.clientHeight+40,m=c.offsetTop>=i.scrollTop&&f<=i.scrollTop+a,y=f-g=e||h.dom.classList.contains("hidden")?(document.body.classList.add("sticky"),h.noSticky=!1):(document.body.classList.remove("sticky"),h.noSticky=!0)}()}function g(e,t){return t={exports:{}},e(t,t.exports),t.exports}function f(e){return e?(/\/\//.test(e)||(e="https://github.com/"+e),e=e.replace(/^git\+/,""),'\n \n \n '):""}function m(){var e=b()+'';return(o()?e+"
        ":"
        "+e)+'
        \n
        \n
        \n
        '}function y(){var e=", 100%, 85%",t="linear-gradient(to left bottom, hsl("+(Math.floor(255*Math.random())+e)+") 0%, hsl("+(Math.floor(255*Math.random())+e)+") 100%)";return'
        \n
        \n
        \n
        '}function b(){return''}function v(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='
      • '+e.title+"
      • ",e.children&&(t+='
        • '+v(e.children)+"
        ")}),t):""}function k(e,t){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=a(e),r="";return r="#/"+i(),D.push({level:t,slug:r+"#"+encodeURIComponent(n),title:e}),"'+e+""},e.code=function(e,t){void 0===t&&(t="");var n=W.highlight(e,W.languages[t]||W.languages.markup);return'
        '+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''+n+'"},"function"==typeof $docsify.markdown?z=$docsify.markdown.call(this,z,e):($docsify.markdown&&$docsify.markdown.renderer&&($docsify.markdown.renderer=O(e,$docsify.markdown.renderer)),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 D=[],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 a=document.querySelector(".sidebar");a.innerHTML='

        '+$docsify.name+"

        "+a.innerHTML}d("button.sidebar-toggle"),$docsify.coverpage?!o()&&window.addEventListener("scroll",h):r.classList.add("sticky")}function _(e){var t=window.Docsify.hook,n=function(e){if(G("article",e),$docsify.loadSidebar||E(),e&&"undefined"!=typeof Vue){R.vm&&R.vm.$destroy();var t=[].slice.call(document.body.querySelectorAll("article>script")).filter(function(e){return!/template/.test(e.type)})[0],n=t?t.innerText.trim():null;t&&t.remove(),R.vm=n?new Function("return "+n)():new Vue({el:"main"}),R.vm&&R.vm.$nextTick(function(e){return l()})}$docsify.auto2top&&setTimeout(function(){return p($docsify.auto2top)},0)};t.emit("before",e,function(e){var r=e?z(e):"";t.emit("after",r,function(e){return n(e||"not found")})})}function C(e){R.navbar&&R.navbar===e||(R.navbar=e,e&&G("nav",z(e)),u("nav"))}function E(e){var n;e?(n=z(e),n=n.match(/]*>([\s\S]+)<\/ul>/g)[0]):n=v(t(D,$docsify.maxLevel),"
          "),G(".sidebar-nav",n),D[0]&&1===D[0].level&&(document.title=""+D[0].title+(B?" - "+B:""));var r=u(".sidebar-nav",!0);r&&A(r),D=[],l()}function A(e){$docsify.subMaxLevel&&(D[0]&&1===D[0].level&&D.shift(),e.parentNode.innerHTML+=v(t(D,$docsify.subMaxLevel),"
            "))}function T(e){if(T.dom=T.dom||document.querySelector("section.cover"),!e)return void T.dom.classList.remove("show");if(T.dom.classList.add("show"),T.rendered)return h();var t=D.slice(),n=z(e),r=n.trim().match('

            ([^<]*?)

            $');if(D=t.slice(),r){var i=document.querySelector("section.cover");"color"===r[2]?i.style.background=r[1]+(r[3]||""):(i.classList.add("has-mask"),i.style.backgroundImage="url("+r[1]+")"),n=n.replace(r[0],"")}G(".cover-main",n),T.rendered=!0,h()}function q(e){var t,n=e.loaded,r=e.total,i=e.step;if(!R.loading){var o=document.createElement("div");o.classList.add("progress"),document.body.appendChild(o),R.loading=o}i?(t=parseInt(R.loading.style.width,10)+i,t=t>80?80:t):t=Math.floor(n/r*100),R.loading.style.opacity=1,R.loading.style.width=t>=95?"100%":t+"%",t>=95&&(clearTimeout(q.cacheTimeout),q.cacheTimeout=setTimeout(function(e){R.loading.style.opacity=0,R.loading.style.width="0%"},200))}var j=null,M=null;a.clear=function(){a.occurrences={}};var N=Object.prototype.hasOwnProperty,O=Object.assign||function(e){for(var t=arguments,n=1;n/g,">").replace(/"/g,""").replace(/'/g,"'")}function a(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function s(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function l(){}function c(e){for(var t,n,r=arguments,i=1;iAn error occured:

            "+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:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\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",/])*?>/)(/tag/g,d._tag)(),d.paragraph=s(d.paragraph)("hr",d.hr)("heading",d.heading)("lheading",d.lheading)("blockquote",d.blockquote)("tag","<"+d._tag)("def",d.def)(),d.normal=c({},d),d.gfm=c({},d.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),d.gfm.paragraph=s(d.paragraph)("(?!","(?!"+d.gfm.fences.source.replace("\\1","\\2")+"|"+d.list.source.replace("\\1","\\3")+"|")(),d.tables=c({},d.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=d,t.lex=function(e,n){var r=new t(n);return r.lex(e)},t.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},t.prototype.token=function(e,t,n){for(var r,i,o,a,s,l,c,u,p,h=this,e=e.replace(/^ +$/gm,"");e;)if((o=h.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&h.tokens.push({type:"space"})),o=h.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),h.tokens.push({type:"code",text:h.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=h.rules.fences.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"code",lang:o[2],text:o[3]||""});else if(o=h.rules.heading.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=h.rules.nptable.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 ?/gm,""),h.token(o,t,!0),h.tokens.push({type:"blockquote_end"});else if(o=h.rules.list.exec(e)){for(e=e.substring(o[0].length),a=o[2],h.tokens.push({type:"list_start",ordered:a.length>1}),o=o[0].match(h.rules.item),r=!1,p=o.length,u=0;u1&&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])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:l,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:l,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,p.link=s(p.link)("inside",p._inside)("href",p._href)(),p.reflink=s(p.reflink)("inside",p._inside)(),p.normal=c({},p),p.pedantic=c({},p.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),p.gfm=c({},p.normal,{escape:s(p.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:s(p.text)("]|","~]|")("|","|https?://|")()}),p.breaks=c({},p.gfm,{br:s(p.br)("{2,}","*")(),text:s(p.gfm.text)("{2,}","*")()}),n.rules=p,n.output=function(e,t,r){var i=new n(t,r);return i.output(e)},n.prototype.output=function(e){for(var t,n,r,i,a=this,s="";e;)if(i=a.rules.escape.exec(e))e=e.substring(i[0].length),s+=i[1];else if(i=a.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=":"===i[1].charAt(6)?a.mangle(i[1].substring(7)):a.mangle(i[1]),r=a.mangle("mailto:")+n):(n=o(i[1]),r=n),s+=a.renderer.link(r,null,n);else if(a.inLink||!(i=a.rules.url.exec(e))){if(i=a.rules.tag.exec(e))!a.inLink&&/^/i.test(i[0])&&(a.inLink=!1),e=e.substring(i[0].length),s+=a.options.sanitize?a.options.sanitizer?a.options.sanitizer(i[0]):o(i[0]):i[0];else if(i=a.rules.link.exec(e))e=e.substring(i[0].length),a.inLink=!0,s+=a.outputLink(i,{href:i[2],title:i[3]}),a.inLink=!1;else if((i=a.rules.reflink.exec(e))||(i=a.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=a.links[t.toLowerCase()],!t||!t.href){s+=i[0].charAt(0),e=i[0].substring(1)+e;continue}a.inLink=!0,s+=a.outputLink(i,t),a.inLink=!1}else if(i=a.rules.strong.exec(e))e=e.substring(i[0].length),s+=a.renderer.strong(a.output(i[2]||i[1]));else if(i=a.rules.em.exec(e))e=e.substring(i[0].length),s+=a.renderer.em(a.output(i[2]||i[1]));else if(i=a.rules.code.exec(e))e=e.substring(i[0].length),s+=a.renderer.codespan(o(i[2],!0));else if(i=a.rules.br.exec(e))e=e.substring(i[0].length),s+=a.renderer.br();else if(i=a.rules.del.exec(e))e=e.substring(i[0].length),s+=a.renderer.del(a.output(i[1]));else if(i=a.rules.text.exec(e))e=e.substring(i[0].length),s+=a.renderer.text(o(a.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=o(i[1]),r=n,s+=a.renderer.link(r,null,n);return s},n.prototype.outputLink=function(e,t){var n=o(t.href),r=t.title?o(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,o(e[1]))},n.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},n.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;i.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},r.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'
            '+(n?e:o(e,!0))+"\n
            \n":"
            "+(n?e:o(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.hr=function(){return this.options.xhtml?"
            \n":"
            \n"},r.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},r.prototype.listitem=function(e){return"
          • "+e+"
          • \n"},r.prototype.paragraph=function(e){return"

            "+e+"

            \n"},r.prototype.table=function(e,t){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"},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='
            "},r.prototype.image=function(e,t,n){var r=''+n+'":">"},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;te.length)break e;if(!(v instanceof i)){u.lastIndex=0;var k=u.exec(v),w=1;if(!k&&h&&y!=o.length-1){if(u.lastIndex=b,k=u.exec(e),!k)break;for(var x=k.index+(p?k[1].length:0),L=k.index+k[0].length,S=y,$=b,_=o.length;S<_&&$=$&&(++y,b=$);if(o[y]instanceof i||o[S-1].greedy)continue;w=S-y,v=e.slice(b,$),k.index-=b}if(k){p&&(g=k[1].length);var x=k.index+g,k=k[0].slice(g),L=x+k.length,C=v.slice(0,x),E=v.slice(L),A=[y,w];C&&A.push(C);var T=new i(s,d?r.tokenize(k,d):k,f,k,h);A.push(T),E&&A.push(E),Array.prototype.splice.apply(o,A)}}}}}return o},hooks:{all:{},add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=r.hooks.all[e];if(n&&n.length)for(var i,o=0;i=n[o++];)i(t)}}},i=r.Token=function(e,t,n,r,i){this.type=e,this.content=t,this.alias=n,this.length=0|(r||"").length,this.greedy=!!i};if(i.stringify=function(e,t,n){if("string"==typeof e)return e;if("Array"===r.util.type(e))return e.map(function(n){return i.stringify(n,t,e)}).join("");var o={type:e.type,content:i.stringify(e.content,t,n),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:n};if("comment"==o.type&&(o.attributes.spellcheck="true"),e.alias){var a="Array"===r.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(o.classes,a)}r.hooks.run("wrap",o);var s=Object.keys(o.attributes).map(function(e){return e+'="'+(o.attributes[e]||"").replace(/"/g,""")+'"'}).join(" ");return"<"+o.tag+' class="'+o.classes.join(" ")+'"'+(s?" "+s:"")+">"+o.content+""},!t.document)return t.addEventListener?(t.addEventListener("message",function(e){var n=JSON.parse(e.data),i=n.language,o=n.code,a=n.immediateClose; +t.postMessage(r.highlight(o,r.languages[i],i)),a&&t.close()},!1),t.Prism):t.Prism;var o=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return o&&(r.filename=o.src,document.addEventListener&&!o.hasAttribute("data-manual")&&("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(r.highlightAll):window.setTimeout(r.highlightAll,16):document.addEventListener("DOMContentLoaded",r.highlightAll))),t.Prism}();e.exports&&(e.exports=n),"undefined"!=typeof I&&(I.Prism=n),n.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},n.hooks.add("wrap",function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))}),n.languages.xml=n.languages.markup,n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:{pattern:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},n.languages.css.atrule.inside.rest=n.util.clone(n.languages.css),n.languages.markup&&(n.languages.insertBefore("markup","tag",{style:{pattern:/()[\w\W]*?(?=<\/style>)/i,lookbehind:!0,inside:n.languages.css,alias:"language-css"}}),n.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:n.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:n.languages.css}},alias:"language-css"}},n.languages.markup.tag)),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:{pattern:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(true|false)\b/,function:/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,function:/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/}),n.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0,greedy:!0}}),n.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\\\|\\?[^\\])*?`/,greedy:!0,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}}}),n.languages.markup&&n.languages.insertBefore("markup","tag",{script:{pattern:/()[\w\W]*?(?=<\/script>)/i,lookbehind:!0,inside:n.languages.javascript,alias:"language-javascript"}}),n.languages.js=n.languages.javascript,function(){"undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.forEach&&Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var r,i=t.getAttribute("data-src"),o=t,a=/\blang(?:uage)?-(?!\*)(\w+)\b/i;o&&!a.test(o.className);)o=o.parentNode;if(o&&(r=(t.className.match(a)||[,""])[1]),!r){var s=(i.match(/\.(\w+)$/)||[,""])[1];r=e[s]||s}var l=document.createElement("code");l.className="language-"+r,t.textContent="",l.textContent="Loading…",t.appendChild(l);var c=new XMLHttpRequest;c.open("GET",i,!0),c.onreadystatechange=function(){4==c.readyState&&(c.status<400&&c.responseText?(l.textContent=c.responseText,n.highlightElement(l)):c.status>=400?l.textContent="✖ Error "+c.status+" while fetching file: "+c.statusText:l.textContent="✖ Error: File does not exist or is empty")},c.send(null)})},document.addEventListener("DOMContentLoaded",self.Prism.fileHighlight))}()}),z=F,D=[],R={},B=document.title,G=function(e,t){return e="object"==typeof e?e:document.querySelector(e),e.innerHTML=t,a.clear(),e},Z=function(){this.beforeHooks=[],this.afterHooks=[],this.initHooks=[],this.readyHooks=[],this.doneEachHooks=[]};Z.prototype.beforeEach=function(e){this.beforeHooks.push(e)},Z.prototype.afterEach=function(e){this.afterHooks.push(e)},Z.prototype.doneEach=function(e){this.doneEachHooks.push(e)},Z.prototype.init=function(e){this.initHooks.push(e)},Z.prototype.ready=function(e){this.readyHooks.push(e)},Z.prototype.emit=function(e,t,n){var r=t,i=this[e+"Hooks"],o=function(e){var a=i[e];if(e>=i.length)n&&n(r);else if("function"==typeof a)if(2===a.length)a(t,function(t){r=t,o(e+1)});else{var s=a(t);r=void 0!==s?s:r,o(e+1)}else o(e+1)};o(0)};var U=O({el:"#app",repo:"",maxLevel:6,subMaxLevel:0,loadSidebar:null,loadNavbar:null,homepage:"README.md",coverpage:"",basePath:"",auto2top:!1,name:"",themeColor:"",nameLink:window.location.pathname,ga:""},window.$docsify),V=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();if(V){for(var Y in U){var J=V.getAttribute("data-"+n(Y));U[Y]=r(J)?U[Y]:J||!0}U.loadSidebar===!0&&(U.loadSidebar="_sidebar.md"),U.loadNavbar===!0&&(U.loadNavbar="_navbar.md"),U.coverpage===!0&&(U.coverpage="_coverpage.md"),U.repo===!0&&(U.repo=""),U.name===!0&&(U.name="")}var X=new Z;window.$docsify=U,window.Docsify={installed:!0,utils:O({},H),hook:X},S();var K=null,Q=null,ee=function(e){return U.alias[e]?ee(U.alias[e]):e},te=function(t){var n,r=i();if(K===r)return t();var o=K=U.basePath+r;/\//.test(o)?o&&!/\/$/.test(o)&&(o=o.match(/(\S*\/)[^\/]+$/)[1]):o="",r="/"+r,r=U.alias&&U.alias[r]?ee(r):(U.basePath+r).replace(/\/+/,"/"),n=r?/\.md$/.test(r)?r:/\/$/.test(r)?r+"README.md":r+".md":U.homepage||"README.md",U.coverpage&&n===U.homepage&&e(U.coverpage).then(T),Q&&Q.abort&&Q.abort(),Q=e(n,"GET",q),Q.then(function(r){if(_(r),U.coverpage&&n!==U.homepage&&T(),U.loadSidebar){var i=function(e){E(e),t()};e(o+U.loadSidebar).then(i,function(t){return e(U.loadSidebar).then(i)})}else t()},function(e){return _(null)}),U.loadNavbar&&e(o+U.loadNavbar).then(C,function(t){return e(U.loadNavbar).then(C)})},ne=function(){setTimeout(function(e){[].concat(U.plugins).forEach(function(e){return"function"==typeof e&&e(X)}),window.Docsify.hook.emit("init");var t=document.querySelector(U.el)||document.body,n=t!==document.body,r=function(){te(function(e){c(),u("nav"),window.Docsify.hook.emit("doneEach")})};$(t,n),r(),/^#\//.test(window.location.hash)||(window.location.hash="#/"),window.addEventListener("hashchange",r),window.Docsify.hook.emit("ready")},0)},re=ne();return re}(); diff --git a/lib/plugins/search.js b/lib/plugins/search.js index 0886e52..d524f4d 100644 --- a/lib/plugins/search.js +++ b/lib/plugins/search.js @@ -290,7 +290,7 @@ var install = function () { new SearchComponent(); !isAuto && searchPlugin(); }); - isAuto && hook.beforeEach(searchPlugin); + isAuto && hook.doneEach(searchPlugin); }, window.$docsify.plugins); }; diff --git a/lib/plugins/search.min.js b/lib/plugins/search.min.js index 932ee34..214806c 100644 --- a/lib/plugins/search.min.js +++ b/lib/plugins/search.min.js @@ -1 +1 @@ -this.D=this.D||{},this.D.Search=function(){"use strict";var e={},n={placeholder:"Type to search",paths:"auto",maxAge:864e5},t=function(e){return"[object Object]"===Object.prototype.toString.call(e)},r=function(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})},a=function(){var e=[];return[].slice.call(document.querySelectorAll("a")).map(function(n){var t=n.href;if(/#\/[^#]*?$/.test(t)){var r=t.replace(/^[^#]+#/,"");e.indexOf(r)<=0&&e.push(r)}}),e},i=function(e,n){void 0===n&&(n=window.$docsify.basePath);var t=/\/$/.test(e)?e+"README.md":e+".md";return t=n+t,t.replace(/\/+/g,"/")},o=function(n,t){void 0===t&&(t=""),e[n]={slug:"",title:"",body:""};var r;t.replace(/]*?>[\s\S]+?<\/template>/g,"").replace(/<(\w+)([^>]*?)>([\s\S]+?)<\//g,function(t,a,i,o){var s=o.replace(/<[^>]+>/g,"");if(/^h\d$/.test(a)){var c=i.match(/id="(\S+)"/)[1];r=("#/"+n+"#"+c).replace(/\/+/,"/"),e[r]={slug:r,title:s,body:""}}else{if(!r)return;e[r]?e[r].body&&e[r].body.length?e[r].body+="\n"+s:e[r].body=s:e[r]={}}})},s=function(){if(!this.rendered){this.style();var e=document.createElement("div"),n=document.querySelector("aside");e.classList.add("search"),n.insertBefore(e,n.children[0]),this.render(e),this.rendered=!0,this.bindEvent()}};s.prototype.style=function e(){var n="\n .sidebar {\n padding-top: 0;\n }\n\n .search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n }\n\n .search .results-panel {\n display: none;\n }\n\n .search .results-panel.show {\n display: block;\n }\n\n .search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n }\n\n .search h2 {\n font-size: 17px;\n margin: 10px 0;\n }\n\n .search a {\n text-decoration: none;\n color: inherit;\n }\n\n .search .matching-post {\n border-bottom: 1px solid #eee;\n }\n\n .search .matching-post:last-child {\n border-bottom: 0;\n }\n\n .search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n }\n\n .search p.empty {\n text-align: center;\n }\n ",e=document.createElement("style");e.innerHTML=n,document.head.appendChild(e)},s.prototype.render=function(e){e.innerHTML='
            '},s.prototype.bindEvent=function(){var e=this,n=document.querySelector(".search"),t=n.querySelector(".search input"),r=n.querySelector(".results-panel");n.addEventListener("click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),t.addEventListener("input",function(n){var t=n.target;if(""!==t.value.trim()){var a=e.search(t.value),i="";a.forEach(function(e,n){i+='\n
            \n

            '+e.title+"

            \n

            "+e.content+"

            \n
            \n "}),r.classList.contains("results-panel")&&(r.classList.add("show"),r.innerHTML=i||'

            No Results!

            ')}else r.classList.contains("results-panel")&&(r.classList.remove("show"),r.innerHTML="")})},s.prototype.search=function(n){var t=[],a=Object.keys(e).map(function(n){return e[n]});n=n.trim().split(/[\s\-\,\\\/]+/);for(var i=function(e){var i=a[e],o=!1,s="",c=i.title&&i.title.trim(),l=i.body&&i.body.trim(),d=i.slug||"";if(""!==c&&""!==l&&(n.forEach(function(e,n){var t=new RegExp(e,"gi"),r=-1,a=-1;if(r=c.search(t),a=l.search(t),r<0&&a<0)o=!1;else{o=!0,a<0&&(a=0);var i=0,d=0;i=a<11?0:a-10,d=0===i?70:a+e.length+60,d>l.length&&(d=l.length);var p="..."+l.substring(i,d).replace(t,''+e+"")+"...";s+=p}}),o)){var p={title:r(c),content:s,url:d};t.push(p)}},o=0;o":">",'"':""","'":"'","/":"/"};return String(e).replace(/[&<>"'\/]/g,function(e){return n[e]})},a=function(){var e=[];return[].slice.call(document.querySelectorAll("a")).map(function(n){var t=n.href;if(/#\/[^#]*?$/.test(t)){var r=t.replace(/^[^#]+#/,"");e.indexOf(r)<=0&&e.push(r)}}),e},i=function(e,n){void 0===n&&(n=window.$docsify.basePath);var t=/\/$/.test(e)?e+"README.md":e+".md";return t=n+t,t.replace(/\/+/g,"/")},o=function(n,t){void 0===t&&(t=""),e[n]={slug:"",title:"",body:""};var r;t.replace(/]*?>[\s\S]+?<\/template>/g,"").replace(/<(\w+)([^>]*?)>([\s\S]+?)<\//g,function(t,a,i,o){var s=o.replace(/<[^>]+>/g,"");if(/^h\d$/.test(a)){var c=i.match(/id="(\S+)"/)[1];r=("#/"+n+"#"+c).replace(/\/+/,"/"),e[r]={slug:r,title:s,body:""}}else{if(!r)return;e[r]?e[r].body&&e[r].body.length?e[r].body+="\n"+s:e[r].body=s:e[r]={}}})},s=function(){if(!this.rendered){this.style();var e=document.createElement("div"),n=document.querySelector("aside");e.classList.add("search"),n.insertBefore(e,n.children[0]),this.render(e),this.rendered=!0,this.bindEvent()}};s.prototype.style=function e(){var n="\n .sidebar {\n padding-top: 0;\n }\n\n .search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n }\n\n .search .results-panel {\n display: none;\n }\n\n .search .results-panel.show {\n display: block;\n }\n\n .search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n }\n\n .search h2 {\n font-size: 17px;\n margin: 10px 0;\n }\n\n .search a {\n text-decoration: none;\n color: inherit;\n }\n\n .search .matching-post {\n border-bottom: 1px solid #eee;\n }\n\n .search .matching-post:last-child {\n border-bottom: 0;\n }\n\n .search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n }\n\n .search p.empty {\n text-align: center;\n }\n ",e=document.createElement("style");e.innerHTML=n,document.head.appendChild(e)},s.prototype.render=function(e){e.innerHTML='
            '},s.prototype.bindEvent=function(){var e=this,n=document.querySelector(".search"),t=n.querySelector(".search input"),r=n.querySelector(".results-panel");n.addEventListener("click",function(e){return"A"!==e.target.tagName&&e.stopPropagation()}),t.addEventListener("input",function(n){var t=n.target;if(""!==t.value.trim()){var a=e.search(t.value),i="";a.forEach(function(e,n){i+='\n
            \n

            '+e.title+"

            \n

            "+e.content+"

            \n
            \n "}),r.classList.contains("results-panel")&&(r.classList.add("show"),r.innerHTML=i||'

            No Results!

            ')}else r.classList.contains("results-panel")&&(r.classList.remove("show"),r.innerHTML="")})},s.prototype.search=function(n){var t=[],a=Object.keys(e).map(function(n){return e[n]});n=n.trim().split(/[\s\-\,\\\/]+/);for(var i=function(e){var i=a[e],o=!1,s="",c=i.title&&i.title.trim(),l=i.body&&i.body.trim(),d=i.slug||"";if(""!==c&&""!==l&&(n.forEach(function(e,n){var t=new RegExp(e,"gi"),r=-1,a=-1;if(r=c.search(t),a=l.search(t),r<0&&a<0)o=!1;else{o=!0,a<0&&(a=0);var i=0,d=0;i=a<11?0:a-10,d=0===i?70:a+e.length+60,d>l.length&&(d=l.length);var p="..."+l.substring(i,d).replace(t,''+e+"")+"...";s+=p}}),o)){var p={title:r(c),content:s,url:d};t.push(p)}},o=0;o Date: Mon, 13 Feb 2017 23:08:02 +0800 Subject: [PATCH 003/746] -> v2.4.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b7f71c1..20d45d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docsify", - "version": "2.3.0", + "version": "2.4.0", "description": "A magical documentation generator.", "main": "lib/docsify.js", "files": [ From dd0c84bb40b1956310611b005d7cfd77d2cba459 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Mon, 13 Feb 2017 23:21:27 +0800 Subject: [PATCH 004/746] fix(index): cover page --- CHANGELOG.md | 7 +++++++ src/index.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8381b1..da5e780 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### 2.4.1 + +> 2017-02-13 + +#### Bug fixes +- fix(index): cover page. + ### 2.4.0 > 2017-02-13 diff --git a/src/index.js b/src/index.js index 75243a6..1a9ee33 100644 --- a/src/index.js +++ b/src/index.js @@ -90,7 +90,7 @@ const mainRender = function (cb) { } // Render Cover page - if (OPTIONS.coverpage && page === OPTIONS.homepage) { + if (OPTIONS.coverpage && page === ('/' + OPTIONS.homepage).replace(/\/+/, '/')) { utils.load(OPTIONS.coverpage).then(render.renderCover) } From d62da2034f3e205381254125d2abc9c7f43dcc86 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Mon, 13 Feb 2017 23:23:13 +0800 Subject: [PATCH 005/746] bump: 2.4.1 --- CHANGELOG.md | 2 +- docs/_coverpage.md | 2 +- lib/docsify.js | 2 +- lib/docsify.min.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da5e780..651f786 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ > 2017-02-13 #### Bug fixes -- fix(index): cover page. +- fix(index): cover page ### 2.4.0 diff --git a/docs/_coverpage.md b/docs/_coverpage.md index 74b8f32..e1ec333 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,6 +1,6 @@ ![logo](_media/icon.svg) -# docsify 2.3.0 +# docsify 2.4.1 > A magical documentation site generator. diff --git a/lib/docsify.js b/lib/docsify.js index dd41db4..c5bb41d 100644 --- a/lib/docsify.js +++ b/lib/docsify.js @@ -2956,7 +2956,7 @@ var mainRender = function (cb) { } // Render Cover page - if (OPTIONS.coverpage && page === OPTIONS.homepage) { + if (OPTIONS.coverpage && page === ('/' + OPTIONS.homepage).replace(/\/+/, '/')) { load(OPTIONS.coverpage).then(renderCover); } diff --git a/lib/docsify.min.js b/lib/docsify.min.js index 821df19..6712bf6 100644 --- a/lib/docsify.min.js +++ b/lib/docsify.min.js @@ -1,2 +1,2 @@ var D=function(){"use strict";function e(e,t,n){void 0===t&&(t="GET");var r=new XMLHttpRequest;return r.open(t,e),r.send(),{then:function(e,t){if(void 0===t&&(t=function(){}),n){var i=setInterval(function(e){return n({step:Math.floor(5*Math.random()+1)})},500);r.addEventListener("progress",n),r.addEventListener("loadend",function(e){n(e),clearInterval(i)})}r.addEventListener("error",t),r.addEventListener("load",function(n){var r=n.target;r.status>=400?t(r):e(r.response)})},abort:function(){return 4!==r.readyState&&r.abort()}}}function t(e,t){var n=[],r={};return e.forEach(function(e){var i=e.level||1,o=i-1;i>t||(r[o]?(r[o].children=r[o].children||[],r[o].children.push(e)):n.push(e),r[i]=e)}),n}function n(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}function r(e){return null===e||void 0===e}function i(){var e=window.location;if(M===e.hash&&!r(j))return j;var t=e.hash.replace(/%23/g,"#").match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,j=t,M=e.hash,t}function o(){return document.body.clientWidth<=600}function a(e){var t=/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g,n=!1,r="-";if(a.occurrences=a.occurrences||{},"string"!=typeof e)return"";n||(e=e.toLowerCase());var i=e.trim().replace(/<[^>\d]+>/g,"").replace(t,"").replace(/\s/g,r).replace(/-+/g,r).replace(/^(\d)/,"_$1"),o=a.occurrences[i];return a.occurrences.hasOwnProperty(i)?o++:o=0,a.occurrences[i]=o,o&&(i=i+"-"+o),i}function s(e){return e.replace(/<(pre|template)[^>]*?>([\s\S]+)<\/(pre|template)>/g,function(e){return e.replace(/:/g,"__colon__")}).replace(/:(\w*?):/gi,'$1').replace(/__colon__/g,":")}function l(){function e(){for(var e,o=document.body.scrollTop,l=0,u=n.length;lo){e||(e=d);break}e=d}if(e){var p=s[e.getAttribute("data-id")];if(p&&p!==c&&(c&&c.classList.remove("active"),p.classList.add("active"),c=p,!t&&!h.noSticky)){var g=0,f=c.offsetTop+c.clientHeight+40,m=c.offsetTop>=i.scrollTop&&f<=i.scrollTop+a,y=f-g=e||h.dom.classList.contains("hidden")?(document.body.classList.add("sticky"),h.noSticky=!1):(document.body.classList.remove("sticky"),h.noSticky=!0)}()}function g(e,t){return t={exports:{}},e(t,t.exports),t.exports}function f(e){return e?(/\/\//.test(e)||(e="https://github.com/"+e),e=e.replace(/^git\+/,""),'\n \n \n '):""}function m(){var e=b()+'';return(o()?e+"
            ":"
            "+e)+'
            \n
            \n
            \n
            '}function y(){var e=", 100%, 85%",t="linear-gradient(to left bottom, hsl("+(Math.floor(255*Math.random())+e)+") 0%, hsl("+(Math.floor(255*Math.random())+e)+") 100%)";return'
            \n
            \n
            \n
            '}function b(){return''}function v(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='
          • '+e.title+"
          • ",e.children&&(t+='
            • '+v(e.children)+"
            ")}),t):""}function k(e,t){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=a(e),r="";return r="#/"+i(),D.push({level:t,slug:r+"#"+encodeURIComponent(n),title:e}),"'+e+""},e.code=function(e,t){void 0===t&&(t="");var n=W.highlight(e,W.languages[t]||W.languages.markup);return'
            '+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''+n+'"},"function"==typeof $docsify.markdown?z=$docsify.markdown.call(this,z,e):($docsify.markdown&&$docsify.markdown.renderer&&($docsify.markdown.renderer=O(e,$docsify.markdown.renderer)),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 D=[],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 a=document.querySelector(".sidebar");a.innerHTML='

            '+$docsify.name+"

            "+a.innerHTML}d("button.sidebar-toggle"),$docsify.coverpage?!o()&&window.addEventListener("scroll",h):r.classList.add("sticky")}function _(e){var t=window.Docsify.hook,n=function(e){if(G("article",e),$docsify.loadSidebar||E(),e&&"undefined"!=typeof Vue){R.vm&&R.vm.$destroy();var t=[].slice.call(document.body.querySelectorAll("article>script")).filter(function(e){return!/template/.test(e.type)})[0],n=t?t.innerText.trim():null;t&&t.remove(),R.vm=n?new Function("return "+n)():new Vue({el:"main"}),R.vm&&R.vm.$nextTick(function(e){return l()})}$docsify.auto2top&&setTimeout(function(){return p($docsify.auto2top)},0)};t.emit("before",e,function(e){var r=e?z(e):"";t.emit("after",r,function(e){return n(e||"not found")})})}function C(e){R.navbar&&R.navbar===e||(R.navbar=e,e&&G("nav",z(e)),u("nav"))}function E(e){var n;e?(n=z(e),n=n.match(/]*>([\s\S]+)<\/ul>/g)[0]):n=v(t(D,$docsify.maxLevel),"
              "),G(".sidebar-nav",n),D[0]&&1===D[0].level&&(document.title=""+D[0].title+(B?" - "+B:""));var r=u(".sidebar-nav",!0);r&&A(r),D=[],l()}function A(e){$docsify.subMaxLevel&&(D[0]&&1===D[0].level&&D.shift(),e.parentNode.innerHTML+=v(t(D,$docsify.subMaxLevel),"
                "))}function T(e){if(T.dom=T.dom||document.querySelector("section.cover"),!e)return void T.dom.classList.remove("show");if(T.dom.classList.add("show"),T.rendered)return h();var t=D.slice(),n=z(e),r=n.trim().match('

                ([^<]*?)

                $');if(D=t.slice(),r){var i=document.querySelector("section.cover");"color"===r[2]?i.style.background=r[1]+(r[3]||""):(i.classList.add("has-mask"),i.style.backgroundImage="url("+r[1]+")"),n=n.replace(r[0],"")}G(".cover-main",n),T.rendered=!0,h()}function q(e){var t,n=e.loaded,r=e.total,i=e.step;if(!R.loading){var o=document.createElement("div");o.classList.add("progress"),document.body.appendChild(o),R.loading=o}i?(t=parseInt(R.loading.style.width,10)+i,t=t>80?80:t):t=Math.floor(n/r*100),R.loading.style.opacity=1,R.loading.style.width=t>=95?"100%":t+"%",t>=95&&(clearTimeout(q.cacheTimeout),q.cacheTimeout=setTimeout(function(e){R.loading.style.opacity=0,R.loading.style.width="0%"},200))}var j=null,M=null;a.clear=function(){a.occurrences={}};var N=Object.prototype.hasOwnProperty,O=Object.assign||function(e){for(var t=arguments,n=1;n/g,">").replace(/"/g,""").replace(/'/g,"'")}function a(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function s(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function l(){}function c(e){for(var t,n,r=arguments,i=1;iAn error occured:

                "+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:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\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",/])*?>/)(/tag/g,d._tag)(),d.paragraph=s(d.paragraph)("hr",d.hr)("heading",d.heading)("lheading",d.lheading)("blockquote",d.blockquote)("tag","<"+d._tag)("def",d.def)(),d.normal=c({},d),d.gfm=c({},d.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),d.gfm.paragraph=s(d.paragraph)("(?!","(?!"+d.gfm.fences.source.replace("\\1","\\2")+"|"+d.list.source.replace("\\1","\\3")+"|")(),d.tables=c({},d.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=d,t.lex=function(e,n){var r=new t(n);return r.lex(e)},t.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},t.prototype.token=function(e,t,n){for(var r,i,o,a,s,l,c,u,p,h=this,e=e.replace(/^ +$/gm,"");e;)if((o=h.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&h.tokens.push({type:"space"})),o=h.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),h.tokens.push({type:"code",text:h.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=h.rules.fences.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"code",lang:o[2],text:o[3]||""});else if(o=h.rules.heading.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=h.rules.nptable.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 ?/gm,""),h.token(o,t,!0),h.tokens.push({type:"blockquote_end"});else if(o=h.rules.list.exec(e)){for(e=e.substring(o[0].length),a=o[2],h.tokens.push({type:"list_start",ordered:a.length>1}),o=o[0].match(h.rules.item),r=!1,p=o.length,u=0;u1&&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])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:l,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:l,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,p.link=s(p.link)("inside",p._inside)("href",p._href)(),p.reflink=s(p.reflink)("inside",p._inside)(),p.normal=c({},p),p.pedantic=c({},p.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),p.gfm=c({},p.normal,{escape:s(p.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:s(p.text)("]|","~]|")("|","|https?://|")()}),p.breaks=c({},p.gfm,{br:s(p.br)("{2,}","*")(),text:s(p.gfm.text)("{2,}","*")()}),n.rules=p,n.output=function(e,t,r){var i=new n(t,r);return i.output(e)},n.prototype.output=function(e){for(var t,n,r,i,a=this,s="";e;)if(i=a.rules.escape.exec(e))e=e.substring(i[0].length),s+=i[1];else if(i=a.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=":"===i[1].charAt(6)?a.mangle(i[1].substring(7)):a.mangle(i[1]),r=a.mangle("mailto:")+n):(n=o(i[1]),r=n),s+=a.renderer.link(r,null,n);else if(a.inLink||!(i=a.rules.url.exec(e))){if(i=a.rules.tag.exec(e))!a.inLink&&/^/i.test(i[0])&&(a.inLink=!1),e=e.substring(i[0].length),s+=a.options.sanitize?a.options.sanitizer?a.options.sanitizer(i[0]):o(i[0]):i[0];else if(i=a.rules.link.exec(e))e=e.substring(i[0].length),a.inLink=!0,s+=a.outputLink(i,{href:i[2],title:i[3]}),a.inLink=!1;else if((i=a.rules.reflink.exec(e))||(i=a.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=a.links[t.toLowerCase()],!t||!t.href){s+=i[0].charAt(0),e=i[0].substring(1)+e;continue}a.inLink=!0,s+=a.outputLink(i,t),a.inLink=!1}else if(i=a.rules.strong.exec(e))e=e.substring(i[0].length),s+=a.renderer.strong(a.output(i[2]||i[1]));else if(i=a.rules.em.exec(e))e=e.substring(i[0].length),s+=a.renderer.em(a.output(i[2]||i[1]));else if(i=a.rules.code.exec(e))e=e.substring(i[0].length),s+=a.renderer.codespan(o(i[2],!0));else if(i=a.rules.br.exec(e))e=e.substring(i[0].length),s+=a.renderer.br();else if(i=a.rules.del.exec(e))e=e.substring(i[0].length),s+=a.renderer.del(a.output(i[1]));else if(i=a.rules.text.exec(e))e=e.substring(i[0].length),s+=a.renderer.text(o(a.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=o(i[1]),r=n,s+=a.renderer.link(r,null,n);return s},n.prototype.outputLink=function(e,t){var n=o(t.href),r=t.title?o(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,o(e[1]))},n.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},n.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;i.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},r.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'
                '+(n?e:o(e,!0))+"\n
                \n":"
                "+(n?e:o(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.hr=function(){return this.options.xhtml?"
                \n":"
                \n"},r.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},r.prototype.listitem=function(e){return"
              • "+e+"
              • \n"},r.prototype.paragraph=function(e){return"

                "+e+"

                \n"},r.prototype.table=function(e,t){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"},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='
                "},r.prototype.image=function(e,t,n){var r=''+n+'":">"},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;te.length)break e;if(!(v instanceof i)){u.lastIndex=0;var k=u.exec(v),w=1;if(!k&&h&&y!=o.length-1){if(u.lastIndex=b,k=u.exec(e),!k)break;for(var x=k.index+(p?k[1].length:0),L=k.index+k[0].length,S=y,$=b,_=o.length;S<_&&$=$&&(++y,b=$);if(o[y]instanceof i||o[S-1].greedy)continue;w=S-y,v=e.slice(b,$),k.index-=b}if(k){p&&(g=k[1].length);var x=k.index+g,k=k[0].slice(g),L=x+k.length,C=v.slice(0,x),E=v.slice(L),A=[y,w];C&&A.push(C);var T=new i(s,d?r.tokenize(k,d):k,f,k,h);A.push(T),E&&A.push(E),Array.prototype.splice.apply(o,A)}}}}}return o},hooks:{all:{},add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=r.hooks.all[e];if(n&&n.length)for(var i,o=0;i=n[o++];)i(t)}}},i=r.Token=function(e,t,n,r,i){this.type=e,this.content=t,this.alias=n,this.length=0|(r||"").length,this.greedy=!!i};if(i.stringify=function(e,t,n){if("string"==typeof e)return e;if("Array"===r.util.type(e))return e.map(function(n){return i.stringify(n,t,e)}).join("");var o={type:e.type,content:i.stringify(e.content,t,n),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:n};if("comment"==o.type&&(o.attributes.spellcheck="true"),e.alias){var a="Array"===r.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(o.classes,a)}r.hooks.run("wrap",o);var s=Object.keys(o.attributes).map(function(e){return e+'="'+(o.attributes[e]||"").replace(/"/g,""")+'"'}).join(" ");return"<"+o.tag+' class="'+o.classes.join(" ")+'"'+(s?" "+s:"")+">"+o.content+""},!t.document)return t.addEventListener?(t.addEventListener("message",function(e){var n=JSON.parse(e.data),i=n.language,o=n.code,a=n.immediateClose; -t.postMessage(r.highlight(o,r.languages[i],i)),a&&t.close()},!1),t.Prism):t.Prism;var o=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return o&&(r.filename=o.src,document.addEventListener&&!o.hasAttribute("data-manual")&&("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(r.highlightAll):window.setTimeout(r.highlightAll,16):document.addEventListener("DOMContentLoaded",r.highlightAll))),t.Prism}();e.exports&&(e.exports=n),"undefined"!=typeof I&&(I.Prism=n),n.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},n.hooks.add("wrap",function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))}),n.languages.xml=n.languages.markup,n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:{pattern:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},n.languages.css.atrule.inside.rest=n.util.clone(n.languages.css),n.languages.markup&&(n.languages.insertBefore("markup","tag",{style:{pattern:/()[\w\W]*?(?=<\/style>)/i,lookbehind:!0,inside:n.languages.css,alias:"language-css"}}),n.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:n.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:n.languages.css}},alias:"language-css"}},n.languages.markup.tag)),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:{pattern:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(true|false)\b/,function:/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,function:/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/}),n.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0,greedy:!0}}),n.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\\\|\\?[^\\])*?`/,greedy:!0,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}}}),n.languages.markup&&n.languages.insertBefore("markup","tag",{script:{pattern:/()[\w\W]*?(?=<\/script>)/i,lookbehind:!0,inside:n.languages.javascript,alias:"language-javascript"}}),n.languages.js=n.languages.javascript,function(){"undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.forEach&&Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var r,i=t.getAttribute("data-src"),o=t,a=/\blang(?:uage)?-(?!\*)(\w+)\b/i;o&&!a.test(o.className);)o=o.parentNode;if(o&&(r=(t.className.match(a)||[,""])[1]),!r){var s=(i.match(/\.(\w+)$/)||[,""])[1];r=e[s]||s}var l=document.createElement("code");l.className="language-"+r,t.textContent="",l.textContent="Loading…",t.appendChild(l);var c=new XMLHttpRequest;c.open("GET",i,!0),c.onreadystatechange=function(){4==c.readyState&&(c.status<400&&c.responseText?(l.textContent=c.responseText,n.highlightElement(l)):c.status>=400?l.textContent="✖ Error "+c.status+" while fetching file: "+c.statusText:l.textContent="✖ Error: File does not exist or is empty")},c.send(null)})},document.addEventListener("DOMContentLoaded",self.Prism.fileHighlight))}()}),z=F,D=[],R={},B=document.title,G=function(e,t){return e="object"==typeof e?e:document.querySelector(e),e.innerHTML=t,a.clear(),e},Z=function(){this.beforeHooks=[],this.afterHooks=[],this.initHooks=[],this.readyHooks=[],this.doneEachHooks=[]};Z.prototype.beforeEach=function(e){this.beforeHooks.push(e)},Z.prototype.afterEach=function(e){this.afterHooks.push(e)},Z.prototype.doneEach=function(e){this.doneEachHooks.push(e)},Z.prototype.init=function(e){this.initHooks.push(e)},Z.prototype.ready=function(e){this.readyHooks.push(e)},Z.prototype.emit=function(e,t,n){var r=t,i=this[e+"Hooks"],o=function(e){var a=i[e];if(e>=i.length)n&&n(r);else if("function"==typeof a)if(2===a.length)a(t,function(t){r=t,o(e+1)});else{var s=a(t);r=void 0!==s?s:r,o(e+1)}else o(e+1)};o(0)};var U=O({el:"#app",repo:"",maxLevel:6,subMaxLevel:0,loadSidebar:null,loadNavbar:null,homepage:"README.md",coverpage:"",basePath:"",auto2top:!1,name:"",themeColor:"",nameLink:window.location.pathname,ga:""},window.$docsify),V=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();if(V){for(var Y in U){var J=V.getAttribute("data-"+n(Y));U[Y]=r(J)?U[Y]:J||!0}U.loadSidebar===!0&&(U.loadSidebar="_sidebar.md"),U.loadNavbar===!0&&(U.loadNavbar="_navbar.md"),U.coverpage===!0&&(U.coverpage="_coverpage.md"),U.repo===!0&&(U.repo=""),U.name===!0&&(U.name="")}var X=new Z;window.$docsify=U,window.Docsify={installed:!0,utils:O({},H),hook:X},S();var K=null,Q=null,ee=function(e){return U.alias[e]?ee(U.alias[e]):e},te=function(t){var n,r=i();if(K===r)return t();var o=K=U.basePath+r;/\//.test(o)?o&&!/\/$/.test(o)&&(o=o.match(/(\S*\/)[^\/]+$/)[1]):o="",r="/"+r,r=U.alias&&U.alias[r]?ee(r):(U.basePath+r).replace(/\/+/,"/"),n=r?/\.md$/.test(r)?r:/\/$/.test(r)?r+"README.md":r+".md":U.homepage||"README.md",U.coverpage&&n===U.homepage&&e(U.coverpage).then(T),Q&&Q.abort&&Q.abort(),Q=e(n,"GET",q),Q.then(function(r){if(_(r),U.coverpage&&n!==U.homepage&&T(),U.loadSidebar){var i=function(e){E(e),t()};e(o+U.loadSidebar).then(i,function(t){return e(U.loadSidebar).then(i)})}else t()},function(e){return _(null)}),U.loadNavbar&&e(o+U.loadNavbar).then(C,function(t){return e(U.loadNavbar).then(C)})},ne=function(){setTimeout(function(e){[].concat(U.plugins).forEach(function(e){return"function"==typeof e&&e(X)}),window.Docsify.hook.emit("init");var t=document.querySelector(U.el)||document.body,n=t!==document.body,r=function(){te(function(e){c(),u("nav"),window.Docsify.hook.emit("doneEach")})};$(t,n),r(),/^#\//.test(window.location.hash)||(window.location.hash="#/"),window.addEventListener("hashchange",r),window.Docsify.hook.emit("ready")},0)},re=ne();return re}(); +t.postMessage(r.highlight(o,r.languages[i],i)),a&&t.close()},!1),t.Prism):t.Prism;var o=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return o&&(r.filename=o.src,document.addEventListener&&!o.hasAttribute("data-manual")&&("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(r.highlightAll):window.setTimeout(r.highlightAll,16):document.addEventListener("DOMContentLoaded",r.highlightAll))),t.Prism}();e.exports&&(e.exports=n),"undefined"!=typeof I&&(I.Prism=n),n.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},n.hooks.add("wrap",function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))}),n.languages.xml=n.languages.markup,n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:{pattern:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},n.languages.css.atrule.inside.rest=n.util.clone(n.languages.css),n.languages.markup&&(n.languages.insertBefore("markup","tag",{style:{pattern:/()[\w\W]*?(?=<\/style>)/i,lookbehind:!0,inside:n.languages.css,alias:"language-css"}}),n.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:n.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:n.languages.css}},alias:"language-css"}},n.languages.markup.tag)),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:{pattern:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(true|false)\b/,function:/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,function:/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/}),n.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0,greedy:!0}}),n.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\\\|\\?[^\\])*?`/,greedy:!0,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}}}),n.languages.markup&&n.languages.insertBefore("markup","tag",{script:{pattern:/()[\w\W]*?(?=<\/script>)/i,lookbehind:!0,inside:n.languages.javascript,alias:"language-javascript"}}),n.languages.js=n.languages.javascript,function(){"undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.forEach&&Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var r,i=t.getAttribute("data-src"),o=t,a=/\blang(?:uage)?-(?!\*)(\w+)\b/i;o&&!a.test(o.className);)o=o.parentNode;if(o&&(r=(t.className.match(a)||[,""])[1]),!r){var s=(i.match(/\.(\w+)$/)||[,""])[1];r=e[s]||s}var l=document.createElement("code");l.className="language-"+r,t.textContent="",l.textContent="Loading…",t.appendChild(l);var c=new XMLHttpRequest;c.open("GET",i,!0),c.onreadystatechange=function(){4==c.readyState&&(c.status<400&&c.responseText?(l.textContent=c.responseText,n.highlightElement(l)):c.status>=400?l.textContent="✖ Error "+c.status+" while fetching file: "+c.statusText:l.textContent="✖ Error: File does not exist or is empty")},c.send(null)})},document.addEventListener("DOMContentLoaded",self.Prism.fileHighlight))}()}),z=F,D=[],R={},B=document.title,G=function(e,t){return e="object"==typeof e?e:document.querySelector(e),e.innerHTML=t,a.clear(),e},Z=function(){this.beforeHooks=[],this.afterHooks=[],this.initHooks=[],this.readyHooks=[],this.doneEachHooks=[]};Z.prototype.beforeEach=function(e){this.beforeHooks.push(e)},Z.prototype.afterEach=function(e){this.afterHooks.push(e)},Z.prototype.doneEach=function(e){this.doneEachHooks.push(e)},Z.prototype.init=function(e){this.initHooks.push(e)},Z.prototype.ready=function(e){this.readyHooks.push(e)},Z.prototype.emit=function(e,t,n){var r=t,i=this[e+"Hooks"],o=function(e){var a=i[e];if(e>=i.length)n&&n(r);else if("function"==typeof a)if(2===a.length)a(t,function(t){r=t,o(e+1)});else{var s=a(t);r=void 0!==s?s:r,o(e+1)}else o(e+1)};o(0)};var U=O({el:"#app",repo:"",maxLevel:6,subMaxLevel:0,loadSidebar:null,loadNavbar:null,homepage:"README.md",coverpage:"",basePath:"",auto2top:!1,name:"",themeColor:"",nameLink:window.location.pathname,ga:""},window.$docsify),V=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();if(V){for(var Y in U){var J=V.getAttribute("data-"+n(Y));U[Y]=r(J)?U[Y]:J||!0}U.loadSidebar===!0&&(U.loadSidebar="_sidebar.md"),U.loadNavbar===!0&&(U.loadNavbar="_navbar.md"),U.coverpage===!0&&(U.coverpage="_coverpage.md"),U.repo===!0&&(U.repo=""),U.name===!0&&(U.name="")}var X=new Z;window.$docsify=U,window.Docsify={installed:!0,utils:O({},H),hook:X},S();var K=null,Q=null,ee=function(e){return U.alias[e]?ee(U.alias[e]):e},te=function(t){var n,r=i();if(K===r)return t();var o=K=U.basePath+r;/\//.test(o)?o&&!/\/$/.test(o)&&(o=o.match(/(\S*\/)[^\/]+$/)[1]):o="",r="/"+r,r=U.alias&&U.alias[r]?ee(r):(U.basePath+r).replace(/\/+/,"/"),n=r?/\.md$/.test(r)?r:/\/$/.test(r)?r+"README.md":r+".md":U.homepage||"README.md",U.coverpage&&n===("/"+U.homepage).replace(/\/+/,"/")&&e(U.coverpage).then(T),Q&&Q.abort&&Q.abort(),Q=e(n,"GET",q),Q.then(function(r){if(_(r),U.coverpage&&n!==U.homepage&&T(),U.loadSidebar){var i=function(e){E(e),t()};e(o+U.loadSidebar).then(i,function(t){return e(U.loadSidebar).then(i)})}else t()},function(e){return _(null)}),U.loadNavbar&&e(o+U.loadNavbar).then(C,function(t){return e(U.loadNavbar).then(C)})},ne=function(){setTimeout(function(e){[].concat(U.plugins).forEach(function(e){return"function"==typeof e&&e(X)}),window.Docsify.hook.emit("init");var t=document.querySelector(U.el)||document.body,n=t!==document.body,r=function(){te(function(e){c(),u("nav"),window.Docsify.hook.emit("doneEach")})};$(t,n),r(),/^#\//.test(window.location.hash)||(window.location.hash="#/"),window.addEventListener("hashchange",r),window.Docsify.hook.emit("ready")},0)},re=ne();return re}(); From cc4ffb4ab710f45560ec2854870cdffae3a3727a Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Mon, 13 Feb 2017 23:23:25 +0800 Subject: [PATCH 006/746] -> v2.4.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 20d45d6..efb2ccf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docsify", - "version": "2.4.0", + "version": "2.4.1", "description": "A magical documentation generator.", "main": "lib/docsify.js", "files": [ From dc536a39301ae2853c8ac9b9fc68da33d2b2ae91 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Tue, 14 Feb 2017 10:22:44 +0800 Subject: [PATCH 007/746] fix(index): load file path error --- src/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 1a9ee33..49dac57 100644 --- a/src/index.js +++ b/src/index.js @@ -72,9 +72,8 @@ const mainRender = function (cb) { } // replace route - route = '/' + route - if (OPTIONS.alias && OPTIONS.alias[route]) { - route = getAlias(route) + if (OPTIONS.alias && OPTIONS.alias['/' + route]) { + route = getAlias('/' + route) } else { route = (OPTIONS.basePath + route).replace(/\/+/, '/') } @@ -90,7 +89,7 @@ const mainRender = function (cb) { } // Render Cover page - if (OPTIONS.coverpage && page === ('/' + OPTIONS.homepage).replace(/\/+/, '/')) { + if (OPTIONS.coverpage && page === OPTIONS.homepage) { utils.load(OPTIONS.coverpage).then(render.renderCover) } From eff6d2153966aab7eab3f54d55d14aa872462369 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Tue, 14 Feb 2017 10:23:08 +0800 Subject: [PATCH 008/746] bump: 2.4.2 --- CHANGELOG.md | 8 ++++++++ docs/_coverpage.md | 2 +- lib/docsify.js | 7 +++---- lib/docsify.min.js | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 651f786..36b7750 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +### 2.4.2 + +> 2017-02-14 + +#### Bug fixes +- fix(index): load file path error + + ### 2.4.1 > 2017-02-13 diff --git a/docs/_coverpage.md b/docs/_coverpage.md index e1ec333..f17d956 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,6 +1,6 @@ ![logo](_media/icon.svg) -# docsify 2.4.1 +# docsify 2.4.2 > A magical documentation site generator. diff --git a/lib/docsify.js b/lib/docsify.js index c5bb41d..5515dc4 100644 --- a/lib/docsify.js +++ b/lib/docsify.js @@ -2938,9 +2938,8 @@ var mainRender = function (cb) { } // replace route - route = '/' + route; - if (OPTIONS.alias && OPTIONS.alias[route]) { - route = getAlias(route); + if (OPTIONS.alias && OPTIONS.alias['/' + route]) { + route = getAlias('/' + route); } else { route = (OPTIONS.basePath + route).replace(/\/+/, '/'); } @@ -2956,7 +2955,7 @@ var mainRender = function (cb) { } // Render Cover page - if (OPTIONS.coverpage && page === ('/' + OPTIONS.homepage).replace(/\/+/, '/')) { + if (OPTIONS.coverpage && page === OPTIONS.homepage) { load(OPTIONS.coverpage).then(renderCover); } diff --git a/lib/docsify.min.js b/lib/docsify.min.js index 6712bf6..109b2cd 100644 --- a/lib/docsify.min.js +++ b/lib/docsify.min.js @@ -1,2 +1,2 @@ var D=function(){"use strict";function e(e,t,n){void 0===t&&(t="GET");var r=new XMLHttpRequest;return r.open(t,e),r.send(),{then:function(e,t){if(void 0===t&&(t=function(){}),n){var i=setInterval(function(e){return n({step:Math.floor(5*Math.random()+1)})},500);r.addEventListener("progress",n),r.addEventListener("loadend",function(e){n(e),clearInterval(i)})}r.addEventListener("error",t),r.addEventListener("load",function(n){var r=n.target;r.status>=400?t(r):e(r.response)})},abort:function(){return 4!==r.readyState&&r.abort()}}}function t(e,t){var n=[],r={};return e.forEach(function(e){var i=e.level||1,o=i-1;i>t||(r[o]?(r[o].children=r[o].children||[],r[o].children.push(e)):n.push(e),r[i]=e)}),n}function n(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}function r(e){return null===e||void 0===e}function i(){var e=window.location;if(M===e.hash&&!r(j))return j;var t=e.hash.replace(/%23/g,"#").match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,j=t,M=e.hash,t}function o(){return document.body.clientWidth<=600}function a(e){var t=/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g,n=!1,r="-";if(a.occurrences=a.occurrences||{},"string"!=typeof e)return"";n||(e=e.toLowerCase());var i=e.trim().replace(/<[^>\d]+>/g,"").replace(t,"").replace(/\s/g,r).replace(/-+/g,r).replace(/^(\d)/,"_$1"),o=a.occurrences[i];return a.occurrences.hasOwnProperty(i)?o++:o=0,a.occurrences[i]=o,o&&(i=i+"-"+o),i}function s(e){return e.replace(/<(pre|template)[^>]*?>([\s\S]+)<\/(pre|template)>/g,function(e){return e.replace(/:/g,"__colon__")}).replace(/:(\w*?):/gi,'$1').replace(/__colon__/g,":")}function l(){function e(){for(var e,o=document.body.scrollTop,l=0,u=n.length;lo){e||(e=d);break}e=d}if(e){var p=s[e.getAttribute("data-id")];if(p&&p!==c&&(c&&c.classList.remove("active"),p.classList.add("active"),c=p,!t&&!h.noSticky)){var g=0,f=c.offsetTop+c.clientHeight+40,m=c.offsetTop>=i.scrollTop&&f<=i.scrollTop+a,y=f-g=e||h.dom.classList.contains("hidden")?(document.body.classList.add("sticky"),h.noSticky=!1):(document.body.classList.remove("sticky"),h.noSticky=!0)}()}function g(e,t){return t={exports:{}},e(t,t.exports),t.exports}function f(e){return e?(/\/\//.test(e)||(e="https://github.com/"+e),e=e.replace(/^git\+/,""),'\n \n \n '):""}function m(){var e=b()+'';return(o()?e+"
                ":"
                "+e)+'
                \n
                \n
                \n
                '}function y(){var e=", 100%, 85%",t="linear-gradient(to left bottom, hsl("+(Math.floor(255*Math.random())+e)+") 0%, hsl("+(Math.floor(255*Math.random())+e)+") 100%)";return'
                \n
                \n
                \n
                '}function b(){return''}function v(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='
              • '+e.title+"
              • ",e.children&&(t+='
                • '+v(e.children)+"
                ")}),t):""}function k(e,t){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=a(e),r="";return r="#/"+i(),D.push({level:t,slug:r+"#"+encodeURIComponent(n),title:e}),"'+e+""},e.code=function(e,t){void 0===t&&(t="");var n=W.highlight(e,W.languages[t]||W.languages.markup);return'
                '+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''+n+'"},"function"==typeof $docsify.markdown?z=$docsify.markdown.call(this,z,e):($docsify.markdown&&$docsify.markdown.renderer&&($docsify.markdown.renderer=O(e,$docsify.markdown.renderer)),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 D=[],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 a=document.querySelector(".sidebar");a.innerHTML='

                '+$docsify.name+"

                "+a.innerHTML}d("button.sidebar-toggle"),$docsify.coverpage?!o()&&window.addEventListener("scroll",h):r.classList.add("sticky")}function _(e){var t=window.Docsify.hook,n=function(e){if(G("article",e),$docsify.loadSidebar||E(),e&&"undefined"!=typeof Vue){R.vm&&R.vm.$destroy();var t=[].slice.call(document.body.querySelectorAll("article>script")).filter(function(e){return!/template/.test(e.type)})[0],n=t?t.innerText.trim():null;t&&t.remove(),R.vm=n?new Function("return "+n)():new Vue({el:"main"}),R.vm&&R.vm.$nextTick(function(e){return l()})}$docsify.auto2top&&setTimeout(function(){return p($docsify.auto2top)},0)};t.emit("before",e,function(e){var r=e?z(e):"";t.emit("after",r,function(e){return n(e||"not found")})})}function C(e){R.navbar&&R.navbar===e||(R.navbar=e,e&&G("nav",z(e)),u("nav"))}function E(e){var n;e?(n=z(e),n=n.match(/]*>([\s\S]+)<\/ul>/g)[0]):n=v(t(D,$docsify.maxLevel),"
                  "),G(".sidebar-nav",n),D[0]&&1===D[0].level&&(document.title=""+D[0].title+(B?" - "+B:""));var r=u(".sidebar-nav",!0);r&&A(r),D=[],l()}function A(e){$docsify.subMaxLevel&&(D[0]&&1===D[0].level&&D.shift(),e.parentNode.innerHTML+=v(t(D,$docsify.subMaxLevel),"
                    "))}function T(e){if(T.dom=T.dom||document.querySelector("section.cover"),!e)return void T.dom.classList.remove("show");if(T.dom.classList.add("show"),T.rendered)return h();var t=D.slice(),n=z(e),r=n.trim().match('

                    ([^<]*?)

                    $');if(D=t.slice(),r){var i=document.querySelector("section.cover");"color"===r[2]?i.style.background=r[1]+(r[3]||""):(i.classList.add("has-mask"),i.style.backgroundImage="url("+r[1]+")"),n=n.replace(r[0],"")}G(".cover-main",n),T.rendered=!0,h()}function q(e){var t,n=e.loaded,r=e.total,i=e.step;if(!R.loading){var o=document.createElement("div");o.classList.add("progress"),document.body.appendChild(o),R.loading=o}i?(t=parseInt(R.loading.style.width,10)+i,t=t>80?80:t):t=Math.floor(n/r*100),R.loading.style.opacity=1,R.loading.style.width=t>=95?"100%":t+"%",t>=95&&(clearTimeout(q.cacheTimeout),q.cacheTimeout=setTimeout(function(e){R.loading.style.opacity=0,R.loading.style.width="0%"},200))}var j=null,M=null;a.clear=function(){a.occurrences={}};var N=Object.prototype.hasOwnProperty,O=Object.assign||function(e){for(var t=arguments,n=1;n/g,">").replace(/"/g,""").replace(/'/g,"'")}function a(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function s(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function l(){}function c(e){for(var t,n,r=arguments,i=1;iAn error occured:

                    "+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:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\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",/])*?>/)(/tag/g,d._tag)(),d.paragraph=s(d.paragraph)("hr",d.hr)("heading",d.heading)("lheading",d.lheading)("blockquote",d.blockquote)("tag","<"+d._tag)("def",d.def)(),d.normal=c({},d),d.gfm=c({},d.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),d.gfm.paragraph=s(d.paragraph)("(?!","(?!"+d.gfm.fences.source.replace("\\1","\\2")+"|"+d.list.source.replace("\\1","\\3")+"|")(),d.tables=c({},d.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=d,t.lex=function(e,n){var r=new t(n);return r.lex(e)},t.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},t.prototype.token=function(e,t,n){for(var r,i,o,a,s,l,c,u,p,h=this,e=e.replace(/^ +$/gm,"");e;)if((o=h.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&h.tokens.push({type:"space"})),o=h.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),h.tokens.push({type:"code",text:h.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=h.rules.fences.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"code",lang:o[2],text:o[3]||""});else if(o=h.rules.heading.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=h.rules.nptable.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 ?/gm,""),h.token(o,t,!0),h.tokens.push({type:"blockquote_end"});else if(o=h.rules.list.exec(e)){for(e=e.substring(o[0].length),a=o[2],h.tokens.push({type:"list_start",ordered:a.length>1}),o=o[0].match(h.rules.item),r=!1,p=o.length,u=0;u1&&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])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:l,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:l,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,p.link=s(p.link)("inside",p._inside)("href",p._href)(),p.reflink=s(p.reflink)("inside",p._inside)(),p.normal=c({},p),p.pedantic=c({},p.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),p.gfm=c({},p.normal,{escape:s(p.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:s(p.text)("]|","~]|")("|","|https?://|")()}),p.breaks=c({},p.gfm,{br:s(p.br)("{2,}","*")(),text:s(p.gfm.text)("{2,}","*")()}),n.rules=p,n.output=function(e,t,r){var i=new n(t,r);return i.output(e)},n.prototype.output=function(e){for(var t,n,r,i,a=this,s="";e;)if(i=a.rules.escape.exec(e))e=e.substring(i[0].length),s+=i[1];else if(i=a.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=":"===i[1].charAt(6)?a.mangle(i[1].substring(7)):a.mangle(i[1]),r=a.mangle("mailto:")+n):(n=o(i[1]),r=n),s+=a.renderer.link(r,null,n);else if(a.inLink||!(i=a.rules.url.exec(e))){if(i=a.rules.tag.exec(e))!a.inLink&&/^/i.test(i[0])&&(a.inLink=!1),e=e.substring(i[0].length),s+=a.options.sanitize?a.options.sanitizer?a.options.sanitizer(i[0]):o(i[0]):i[0];else if(i=a.rules.link.exec(e))e=e.substring(i[0].length),a.inLink=!0,s+=a.outputLink(i,{href:i[2],title:i[3]}),a.inLink=!1;else if((i=a.rules.reflink.exec(e))||(i=a.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=a.links[t.toLowerCase()],!t||!t.href){s+=i[0].charAt(0),e=i[0].substring(1)+e;continue}a.inLink=!0,s+=a.outputLink(i,t),a.inLink=!1}else if(i=a.rules.strong.exec(e))e=e.substring(i[0].length),s+=a.renderer.strong(a.output(i[2]||i[1]));else if(i=a.rules.em.exec(e))e=e.substring(i[0].length),s+=a.renderer.em(a.output(i[2]||i[1]));else if(i=a.rules.code.exec(e))e=e.substring(i[0].length),s+=a.renderer.codespan(o(i[2],!0));else if(i=a.rules.br.exec(e))e=e.substring(i[0].length),s+=a.renderer.br();else if(i=a.rules.del.exec(e))e=e.substring(i[0].length),s+=a.renderer.del(a.output(i[1]));else if(i=a.rules.text.exec(e))e=e.substring(i[0].length),s+=a.renderer.text(o(a.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=o(i[1]),r=n,s+=a.renderer.link(r,null,n);return s},n.prototype.outputLink=function(e,t){var n=o(t.href),r=t.title?o(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,o(e[1]))},n.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},n.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;i.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},r.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'
                    '+(n?e:o(e,!0))+"\n
                    \n":"
                    "+(n?e:o(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.hr=function(){return this.options.xhtml?"
                    \n":"
                    \n"},r.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},r.prototype.listitem=function(e){return"
                  • "+e+"
                  • \n"},r.prototype.paragraph=function(e){return"

                    "+e+"

                    \n"},r.prototype.table=function(e,t){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"},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='
                    "},r.prototype.image=function(e,t,n){var r=''+n+'":">"},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;te.length)break e;if(!(v instanceof i)){u.lastIndex=0;var k=u.exec(v),w=1;if(!k&&h&&y!=o.length-1){if(u.lastIndex=b,k=u.exec(e),!k)break;for(var x=k.index+(p?k[1].length:0),L=k.index+k[0].length,S=y,$=b,_=o.length;S<_&&$=$&&(++y,b=$);if(o[y]instanceof i||o[S-1].greedy)continue;w=S-y,v=e.slice(b,$),k.index-=b}if(k){p&&(g=k[1].length);var x=k.index+g,k=k[0].slice(g),L=x+k.length,C=v.slice(0,x),E=v.slice(L),A=[y,w];C&&A.push(C);var T=new i(s,d?r.tokenize(k,d):k,f,k,h);A.push(T),E&&A.push(E),Array.prototype.splice.apply(o,A)}}}}}return o},hooks:{all:{},add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=r.hooks.all[e];if(n&&n.length)for(var i,o=0;i=n[o++];)i(t)}}},i=r.Token=function(e,t,n,r,i){this.type=e,this.content=t,this.alias=n,this.length=0|(r||"").length,this.greedy=!!i};if(i.stringify=function(e,t,n){if("string"==typeof e)return e;if("Array"===r.util.type(e))return e.map(function(n){return i.stringify(n,t,e)}).join("");var o={type:e.type,content:i.stringify(e.content,t,n),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:n};if("comment"==o.type&&(o.attributes.spellcheck="true"),e.alias){var a="Array"===r.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(o.classes,a)}r.hooks.run("wrap",o);var s=Object.keys(o.attributes).map(function(e){return e+'="'+(o.attributes[e]||"").replace(/"/g,""")+'"'}).join(" ");return"<"+o.tag+' class="'+o.classes.join(" ")+'"'+(s?" "+s:"")+">"+o.content+""},!t.document)return t.addEventListener?(t.addEventListener("message",function(e){var n=JSON.parse(e.data),i=n.language,o=n.code,a=n.immediateClose; -t.postMessage(r.highlight(o,r.languages[i],i)),a&&t.close()},!1),t.Prism):t.Prism;var o=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return o&&(r.filename=o.src,document.addEventListener&&!o.hasAttribute("data-manual")&&("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(r.highlightAll):window.setTimeout(r.highlightAll,16):document.addEventListener("DOMContentLoaded",r.highlightAll))),t.Prism}();e.exports&&(e.exports=n),"undefined"!=typeof I&&(I.Prism=n),n.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},n.hooks.add("wrap",function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))}),n.languages.xml=n.languages.markup,n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:{pattern:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},n.languages.css.atrule.inside.rest=n.util.clone(n.languages.css),n.languages.markup&&(n.languages.insertBefore("markup","tag",{style:{pattern:/()[\w\W]*?(?=<\/style>)/i,lookbehind:!0,inside:n.languages.css,alias:"language-css"}}),n.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:n.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:n.languages.css}},alias:"language-css"}},n.languages.markup.tag)),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:{pattern:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(true|false)\b/,function:/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,function:/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/}),n.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0,greedy:!0}}),n.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\\\|\\?[^\\])*?`/,greedy:!0,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}}}),n.languages.markup&&n.languages.insertBefore("markup","tag",{script:{pattern:/()[\w\W]*?(?=<\/script>)/i,lookbehind:!0,inside:n.languages.javascript,alias:"language-javascript"}}),n.languages.js=n.languages.javascript,function(){"undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.forEach&&Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var r,i=t.getAttribute("data-src"),o=t,a=/\blang(?:uage)?-(?!\*)(\w+)\b/i;o&&!a.test(o.className);)o=o.parentNode;if(o&&(r=(t.className.match(a)||[,""])[1]),!r){var s=(i.match(/\.(\w+)$/)||[,""])[1];r=e[s]||s}var l=document.createElement("code");l.className="language-"+r,t.textContent="",l.textContent="Loading…",t.appendChild(l);var c=new XMLHttpRequest;c.open("GET",i,!0),c.onreadystatechange=function(){4==c.readyState&&(c.status<400&&c.responseText?(l.textContent=c.responseText,n.highlightElement(l)):c.status>=400?l.textContent="✖ Error "+c.status+" while fetching file: "+c.statusText:l.textContent="✖ Error: File does not exist or is empty")},c.send(null)})},document.addEventListener("DOMContentLoaded",self.Prism.fileHighlight))}()}),z=F,D=[],R={},B=document.title,G=function(e,t){return e="object"==typeof e?e:document.querySelector(e),e.innerHTML=t,a.clear(),e},Z=function(){this.beforeHooks=[],this.afterHooks=[],this.initHooks=[],this.readyHooks=[],this.doneEachHooks=[]};Z.prototype.beforeEach=function(e){this.beforeHooks.push(e)},Z.prototype.afterEach=function(e){this.afterHooks.push(e)},Z.prototype.doneEach=function(e){this.doneEachHooks.push(e)},Z.prototype.init=function(e){this.initHooks.push(e)},Z.prototype.ready=function(e){this.readyHooks.push(e)},Z.prototype.emit=function(e,t,n){var r=t,i=this[e+"Hooks"],o=function(e){var a=i[e];if(e>=i.length)n&&n(r);else if("function"==typeof a)if(2===a.length)a(t,function(t){r=t,o(e+1)});else{var s=a(t);r=void 0!==s?s:r,o(e+1)}else o(e+1)};o(0)};var U=O({el:"#app",repo:"",maxLevel:6,subMaxLevel:0,loadSidebar:null,loadNavbar:null,homepage:"README.md",coverpage:"",basePath:"",auto2top:!1,name:"",themeColor:"",nameLink:window.location.pathname,ga:""},window.$docsify),V=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();if(V){for(var Y in U){var J=V.getAttribute("data-"+n(Y));U[Y]=r(J)?U[Y]:J||!0}U.loadSidebar===!0&&(U.loadSidebar="_sidebar.md"),U.loadNavbar===!0&&(U.loadNavbar="_navbar.md"),U.coverpage===!0&&(U.coverpage="_coverpage.md"),U.repo===!0&&(U.repo=""),U.name===!0&&(U.name="")}var X=new Z;window.$docsify=U,window.Docsify={installed:!0,utils:O({},H),hook:X},S();var K=null,Q=null,ee=function(e){return U.alias[e]?ee(U.alias[e]):e},te=function(t){var n,r=i();if(K===r)return t();var o=K=U.basePath+r;/\//.test(o)?o&&!/\/$/.test(o)&&(o=o.match(/(\S*\/)[^\/]+$/)[1]):o="",r="/"+r,r=U.alias&&U.alias[r]?ee(r):(U.basePath+r).replace(/\/+/,"/"),n=r?/\.md$/.test(r)?r:/\/$/.test(r)?r+"README.md":r+".md":U.homepage||"README.md",U.coverpage&&n===("/"+U.homepage).replace(/\/+/,"/")&&e(U.coverpage).then(T),Q&&Q.abort&&Q.abort(),Q=e(n,"GET",q),Q.then(function(r){if(_(r),U.coverpage&&n!==U.homepage&&T(),U.loadSidebar){var i=function(e){E(e),t()};e(o+U.loadSidebar).then(i,function(t){return e(U.loadSidebar).then(i)})}else t()},function(e){return _(null)}),U.loadNavbar&&e(o+U.loadNavbar).then(C,function(t){return e(U.loadNavbar).then(C)})},ne=function(){setTimeout(function(e){[].concat(U.plugins).forEach(function(e){return"function"==typeof e&&e(X)}),window.Docsify.hook.emit("init");var t=document.querySelector(U.el)||document.body,n=t!==document.body,r=function(){te(function(e){c(),u("nav"),window.Docsify.hook.emit("doneEach")})};$(t,n),r(),/^#\//.test(window.location.hash)||(window.location.hash="#/"),window.addEventListener("hashchange",r),window.Docsify.hook.emit("ready")},0)},re=ne();return re}(); +t.postMessage(r.highlight(o,r.languages[i],i)),a&&t.close()},!1),t.Prism):t.Prism;var o=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return o&&(r.filename=o.src,document.addEventListener&&!o.hasAttribute("data-manual")&&("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(r.highlightAll):window.setTimeout(r.highlightAll,16):document.addEventListener("DOMContentLoaded",r.highlightAll))),t.Prism}();e.exports&&(e.exports=n),"undefined"!=typeof I&&(I.Prism=n),n.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},n.hooks.add("wrap",function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))}),n.languages.xml=n.languages.markup,n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:{pattern:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},n.languages.css.atrule.inside.rest=n.util.clone(n.languages.css),n.languages.markup&&(n.languages.insertBefore("markup","tag",{style:{pattern:/()[\w\W]*?(?=<\/style>)/i,lookbehind:!0,inside:n.languages.css,alias:"language-css"}}),n.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:n.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:n.languages.css}},alias:"language-css"}},n.languages.markup.tag)),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:{pattern:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(true|false)\b/,function:/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,function:/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/}),n.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0,greedy:!0}}),n.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\\\|\\?[^\\])*?`/,greedy:!0,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}}}),n.languages.markup&&n.languages.insertBefore("markup","tag",{script:{pattern:/()[\w\W]*?(?=<\/script>)/i,lookbehind:!0,inside:n.languages.javascript,alias:"language-javascript"}}),n.languages.js=n.languages.javascript,function(){"undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.forEach&&Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var r,i=t.getAttribute("data-src"),o=t,a=/\blang(?:uage)?-(?!\*)(\w+)\b/i;o&&!a.test(o.className);)o=o.parentNode;if(o&&(r=(t.className.match(a)||[,""])[1]),!r){var s=(i.match(/\.(\w+)$/)||[,""])[1];r=e[s]||s}var l=document.createElement("code");l.className="language-"+r,t.textContent="",l.textContent="Loading…",t.appendChild(l);var c=new XMLHttpRequest;c.open("GET",i,!0),c.onreadystatechange=function(){4==c.readyState&&(c.status<400&&c.responseText?(l.textContent=c.responseText,n.highlightElement(l)):c.status>=400?l.textContent="✖ Error "+c.status+" while fetching file: "+c.statusText:l.textContent="✖ Error: File does not exist or is empty")},c.send(null)})},document.addEventListener("DOMContentLoaded",self.Prism.fileHighlight))}()}),z=F,D=[],R={},B=document.title,G=function(e,t){return e="object"==typeof e?e:document.querySelector(e),e.innerHTML=t,a.clear(),e},Z=function(){this.beforeHooks=[],this.afterHooks=[],this.initHooks=[],this.readyHooks=[],this.doneEachHooks=[]};Z.prototype.beforeEach=function(e){this.beforeHooks.push(e)},Z.prototype.afterEach=function(e){this.afterHooks.push(e)},Z.prototype.doneEach=function(e){this.doneEachHooks.push(e)},Z.prototype.init=function(e){this.initHooks.push(e)},Z.prototype.ready=function(e){this.readyHooks.push(e)},Z.prototype.emit=function(e,t,n){var r=t,i=this[e+"Hooks"],o=function(e){var a=i[e];if(e>=i.length)n&&n(r);else if("function"==typeof a)if(2===a.length)a(t,function(t){r=t,o(e+1)});else{var s=a(t);r=void 0!==s?s:r,o(e+1)}else o(e+1)};o(0)};var U=O({el:"#app",repo:"",maxLevel:6,subMaxLevel:0,loadSidebar:null,loadNavbar:null,homepage:"README.md",coverpage:"",basePath:"",auto2top:!1,name:"",themeColor:"",nameLink:window.location.pathname,ga:""},window.$docsify),V=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();if(V){for(var Y in U){var J=V.getAttribute("data-"+n(Y));U[Y]=r(J)?U[Y]:J||!0}U.loadSidebar===!0&&(U.loadSidebar="_sidebar.md"),U.loadNavbar===!0&&(U.loadNavbar="_navbar.md"),U.coverpage===!0&&(U.coverpage="_coverpage.md"),U.repo===!0&&(U.repo=""),U.name===!0&&(U.name="")}var X=new Z;window.$docsify=U,window.Docsify={installed:!0,utils:O({},H),hook:X},S();var K=null,Q=null,ee=function(e){return U.alias[e]?ee(U.alias[e]):e},te=function(t){var n,r=i();if(K===r)return t();var o=K=U.basePath+r;/\//.test(o)?o&&!/\/$/.test(o)&&(o=o.match(/(\S*\/)[^\/]+$/)[1]):o="",r=U.alias&&U.alias["/"+r]?ee("/"+r):(U.basePath+r).replace(/\/+/,"/"),n=r?/\.md$/.test(r)?r:/\/$/.test(r)?r+"README.md":r+".md":U.homepage||"README.md",U.coverpage&&n===U.homepage&&e(U.coverpage).then(T),Q&&Q.abort&&Q.abort(),Q=e(n,"GET",q),Q.then(function(r){if(_(r),U.coverpage&&n!==U.homepage&&T(),U.loadSidebar){var i=function(e){E(e),t()};e(o+U.loadSidebar).then(i,function(t){return e(U.loadSidebar).then(i)})}else t()},function(e){return _(null)}),U.loadNavbar&&e(o+U.loadNavbar).then(C,function(t){return e(U.loadNavbar).then(C)})},ne=function(){setTimeout(function(e){[].concat(U.plugins).forEach(function(e){return"function"==typeof e&&e(X)}),window.Docsify.hook.emit("init");var t=document.querySelector(U.el)||document.body,n=t!==document.body,r=function(){te(function(e){c(),u("nav"),window.Docsify.hook.emit("doneEach")})};$(t,n),r(),/^#\//.test(window.location.hash)||(window.location.hash="#/"),window.addEventListener("hashchange",r),window.Docsify.hook.emit("ready")},0)},re=ne();return re}(); From 8e203b07ab403983a862642388ef314b2a05818f Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Tue, 14 Feb 2017 10:23:14 +0800 Subject: [PATCH 009/746] -> v2.4.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index efb2ccf..57aa193 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docsify", - "version": "2.4.1", + "version": "2.4.2", "description": "A magical documentation generator.", "main": "lib/docsify.js", "files": [ From 00983ab796244d0f782c32906789b45d42d4a28a Mon Sep 17 00:00:00 2001 From: Song Date: Tue, 14 Feb 2017 15:47:04 +0800 Subject: [PATCH 010/746] fix emoji replacing error (#76) --- src/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.js b/src/util.js index b9d4171..8f182df 100644 --- a/src/util.js +++ b/src/util.js @@ -161,6 +161,6 @@ export const merge = Object.assign || function (to) { export function emojify (text) { return text .replace(/<(pre|template)[^>]*?>([\s\S]+)<\/(pre|template)>/g, match => match.replace(/:/g, '__colon__')) - .replace(/:(\w*?):/ig, '$1') + .replace(/:(\w+?):/ig, '$1') .replace(/__colon__/g, ':') } From 94255e22b1bfc85d52f0cfd8b8bf52f3607f90ae Mon Sep 17 00:00:00 2001 From: Jintzo Date: Tue, 14 Feb 2017 10:11:29 +0100 Subject: [PATCH 011/746] Correctly link Get Started (#77) As `## docsify` is the new title of the `README.md`, *Get Started* should link to that. --- docs/_coverpage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_coverpage.md b/docs/_coverpage.md index f17d956..6467a88 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -10,4 +10,4 @@ [GitHub](https://github.com/QingWei-Li/docsify/) -[Get Started](#quick-start) +[Get Started](#docsify) From a6d9669bfa3dfedc209e70c49bbaa31acc3b475d Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Wed, 15 Feb 2017 20:00:56 +0800 Subject: [PATCH 012/746] docs: update package size --- CHANGELOG.md | 7 +++++++ README.md | 2 +- docs/README.md | 2 +- docs/_coverpage.md | 4 ++-- docs/zh-cn/README.md | 4 ++-- docs/zh-cn/configuration.md | 2 +- docs/zh-cn/plugins.md | 4 ++-- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36b7750..76f6013 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### 2.4.3 + +> 2017-02-15 + +#### Bug fixes +* fix emoji replacing error (#76) + ### 2.4.2 > 2017-02-14 diff --git a/README.md b/README.md index 88937d1..dd7de59 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ ## Features - Not build static html files -- Simple and lightweight (~13kB gzipped) +- Simple and lightweight (~14kB gzipped) - Smart full-text search plugin - Multiple themes - Useful plugin API diff --git a/docs/README.md b/docs/README.md index 31602ab..529c54b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -11,7 +11,7 @@ See the [Quick start](/quickstart) for more details. ## Features - Not build static html files -- Simple and lightweight (~13kB gzipped) +- Simple and lightweight (~14kB gzipped) - Smart full-text search plugin - Multiple themes - Useful plugin API diff --git a/docs/_coverpage.md b/docs/_coverpage.md index f17d956..d0f7bbf 100644 --- a/docs/_coverpage.md +++ b/docs/_coverpage.md @@ -1,10 +1,10 @@ ![logo](_media/icon.svg) -# docsify 2.4.2 +# docsify 2.4.3 > A magical documentation site generator. -- Simple and lightweight (~13kB gzipped) +- Simple and lightweight (~14kB gzipped) - Not build static html files - Multiple themes diff --git a/docs/zh-cn/README.md b/docs/zh-cn/README.md index 00035eb..e5051b1 100644 --- a/docs/zh-cn/README.md +++ b/docs/zh-cn/README.md @@ -12,8 +12,8 @@ docsify 是一个动态生成文档网站的工具。不同于 GitBook、Hexo ## 特性 - 无需构建,写完文档直接发布 -- 容易使用并且轻量 (~13Kb gzipped) -- 智能的全文检索 +- 容易使用并且轻量 (~14kB gzipped) +- 智能的全文搜索 - 提供多套主题 - 丰富的 API - 兼容 IE9+ diff --git a/docs/zh-cn/configuration.md b/docs/zh-cn/configuration.md index c79db81..23c96d4 100644 --- a/docs/zh-cn/configuration.md +++ b/docs/zh-cn/configuration.md @@ -108,7 +108,7 @@ window.$docsify = { - 类型:`Number` - 默认值: `0` -自定义侧边栏后默认不会再生成目录,你也可以通过设置生成目录的最大层级开启这个功能, +自定义侧边栏后默认不会再生成目录,你也可以通过设置生成目录的最大层级开启这个功能。 ```js diff --git a/docs/zh-cn/plugins.md b/docs/zh-cn/plugins.md index 9fd249b..8145f01 100644 --- a/docs/zh-cn/plugins.md +++ b/docs/zh-cn/plugins.md @@ -2,9 +2,9 @@ ## 内置插件 -### 全文检索 - Search +### 全文搜索 - Search -全文检索插件会根据当前页面上的超链接获取文档内容,在 `localStorage` 内建立文档索引。默认过期时间为一天,当然我们可以自己指定需要缓存的文件列表或者配置过期时间。 +全文搜索插件会根据当前页面上的超链接获取文档内容,在 `localStorage` 内建立文档索引。默认过期时间为一天,当然我们可以自己指定需要缓存的文件列表或者配置过期时间。 ```html From 00e3609b2578077f9e7d26a90aea1400ef1a3103 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Wed, 15 Feb 2017 20:01:07 +0800 Subject: [PATCH 013/746] bump: 2.4.3 --- lib/docsify.js | 2 +- lib/docsify.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/docsify.js b/lib/docsify.js index 5515dc4..518bafb 100644 --- a/lib/docsify.js +++ b/lib/docsify.js @@ -171,7 +171,7 @@ var merge = Object.assign || function (to) { function emojify (text) { return text .replace(/<(pre|template)[^>]*?>([\s\S]+)<\/(pre|template)>/g, function (match) { return match.replace(/:/g, '__colon__'); }) - .replace(/:(\w*?):/ig, '$1') + .replace(/:(\w+?):/ig, '$1') .replace(/__colon__/g, ':') } diff --git a/lib/docsify.min.js b/lib/docsify.min.js index 109b2cd..15d2f5a 100644 --- a/lib/docsify.min.js +++ b/lib/docsify.min.js @@ -1,2 +1,2 @@ -var D=function(){"use strict";function e(e,t,n){void 0===t&&(t="GET");var r=new XMLHttpRequest;return r.open(t,e),r.send(),{then:function(e,t){if(void 0===t&&(t=function(){}),n){var i=setInterval(function(e){return n({step:Math.floor(5*Math.random()+1)})},500);r.addEventListener("progress",n),r.addEventListener("loadend",function(e){n(e),clearInterval(i)})}r.addEventListener("error",t),r.addEventListener("load",function(n){var r=n.target;r.status>=400?t(r):e(r.response)})},abort:function(){return 4!==r.readyState&&r.abort()}}}function t(e,t){var n=[],r={};return e.forEach(function(e){var i=e.level||1,o=i-1;i>t||(r[o]?(r[o].children=r[o].children||[],r[o].children.push(e)):n.push(e),r[i]=e)}),n}function n(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}function r(e){return null===e||void 0===e}function i(){var e=window.location;if(M===e.hash&&!r(j))return j;var t=e.hash.replace(/%23/g,"#").match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,j=t,M=e.hash,t}function o(){return document.body.clientWidth<=600}function a(e){var t=/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g,n=!1,r="-";if(a.occurrences=a.occurrences||{},"string"!=typeof e)return"";n||(e=e.toLowerCase());var i=e.trim().replace(/<[^>\d]+>/g,"").replace(t,"").replace(/\s/g,r).replace(/-+/g,r).replace(/^(\d)/,"_$1"),o=a.occurrences[i];return a.occurrences.hasOwnProperty(i)?o++:o=0,a.occurrences[i]=o,o&&(i=i+"-"+o),i}function s(e){return e.replace(/<(pre|template)[^>]*?>([\s\S]+)<\/(pre|template)>/g,function(e){return e.replace(/:/g,"__colon__")}).replace(/:(\w*?):/gi,'$1').replace(/__colon__/g,":")}function l(){function e(){for(var e,o=document.body.scrollTop,l=0,u=n.length;lo){e||(e=d);break}e=d}if(e){var p=s[e.getAttribute("data-id")];if(p&&p!==c&&(c&&c.classList.remove("active"),p.classList.add("active"),c=p,!t&&!h.noSticky)){var g=0,f=c.offsetTop+c.clientHeight+40,m=c.offsetTop>=i.scrollTop&&f<=i.scrollTop+a,y=f-g=e||h.dom.classList.contains("hidden")?(document.body.classList.add("sticky"),h.noSticky=!1):(document.body.classList.remove("sticky"),h.noSticky=!0)}()}function g(e,t){return t={exports:{}},e(t,t.exports),t.exports}function f(e){return e?(/\/\//.test(e)||(e="https://github.com/"+e),e=e.replace(/^git\+/,""),'\n \n \n '):""}function m(){var e=b()+'';return(o()?e+"
                    ":"
                    "+e)+'
                    \n
                    \n
                    \n
                    '}function y(){var e=", 100%, 85%",t="linear-gradient(to left bottom, hsl("+(Math.floor(255*Math.random())+e)+") 0%, hsl("+(Math.floor(255*Math.random())+e)+") 100%)";return'
                    \n
                    \n
                    \n
                    '}function b(){return''}function v(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='
                  • '+e.title+"
                  • ",e.children&&(t+='
                    • '+v(e.children)+"
                    ")}),t):""}function k(e,t){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=a(e),r="";return r="#/"+i(),D.push({level:t,slug:r+"#"+encodeURIComponent(n),title:e}),"'+e+""},e.code=function(e,t){void 0===t&&(t="");var n=W.highlight(e,W.languages[t]||W.languages.markup);return'
                    '+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''+n+'"},"function"==typeof $docsify.markdown?z=$docsify.markdown.call(this,z,e):($docsify.markdown&&$docsify.markdown.renderer&&($docsify.markdown.renderer=O(e,$docsify.markdown.renderer)),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 D=[],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 a=document.querySelector(".sidebar");a.innerHTML='

                    '+$docsify.name+"

                    "+a.innerHTML}d("button.sidebar-toggle"),$docsify.coverpage?!o()&&window.addEventListener("scroll",h):r.classList.add("sticky")}function _(e){var t=window.Docsify.hook,n=function(e){if(G("article",e),$docsify.loadSidebar||E(),e&&"undefined"!=typeof Vue){R.vm&&R.vm.$destroy();var t=[].slice.call(document.body.querySelectorAll("article>script")).filter(function(e){return!/template/.test(e.type)})[0],n=t?t.innerText.trim():null;t&&t.remove(),R.vm=n?new Function("return "+n)():new Vue({el:"main"}),R.vm&&R.vm.$nextTick(function(e){return l()})}$docsify.auto2top&&setTimeout(function(){return p($docsify.auto2top)},0)};t.emit("before",e,function(e){var r=e?z(e):"";t.emit("after",r,function(e){return n(e||"not found")})})}function C(e){R.navbar&&R.navbar===e||(R.navbar=e,e&&G("nav",z(e)),u("nav"))}function E(e){var n;e?(n=z(e),n=n.match(/]*>([\s\S]+)<\/ul>/g)[0]):n=v(t(D,$docsify.maxLevel),"
                      "),G(".sidebar-nav",n),D[0]&&1===D[0].level&&(document.title=""+D[0].title+(B?" - "+B:""));var r=u(".sidebar-nav",!0);r&&A(r),D=[],l()}function A(e){$docsify.subMaxLevel&&(D[0]&&1===D[0].level&&D.shift(),e.parentNode.innerHTML+=v(t(D,$docsify.subMaxLevel),"
                        "))}function T(e){if(T.dom=T.dom||document.querySelector("section.cover"),!e)return void T.dom.classList.remove("show");if(T.dom.classList.add("show"),T.rendered)return h();var t=D.slice(),n=z(e),r=n.trim().match('

                        ([^<]*?)

                        $');if(D=t.slice(),r){var i=document.querySelector("section.cover");"color"===r[2]?i.style.background=r[1]+(r[3]||""):(i.classList.add("has-mask"),i.style.backgroundImage="url("+r[1]+")"),n=n.replace(r[0],"")}G(".cover-main",n),T.rendered=!0,h()}function q(e){var t,n=e.loaded,r=e.total,i=e.step;if(!R.loading){var o=document.createElement("div");o.classList.add("progress"),document.body.appendChild(o),R.loading=o}i?(t=parseInt(R.loading.style.width,10)+i,t=t>80?80:t):t=Math.floor(n/r*100),R.loading.style.opacity=1,R.loading.style.width=t>=95?"100%":t+"%",t>=95&&(clearTimeout(q.cacheTimeout),q.cacheTimeout=setTimeout(function(e){R.loading.style.opacity=0,R.loading.style.width="0%"},200))}var j=null,M=null;a.clear=function(){a.occurrences={}};var N=Object.prototype.hasOwnProperty,O=Object.assign||function(e){for(var t=arguments,n=1;n/g,">").replace(/"/g,""").replace(/'/g,"'")}function a(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function s(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function l(){}function c(e){for(var t,n,r=arguments,i=1;iAn error occured:

                        "+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:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\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",/])*?>/)(/tag/g,d._tag)(),d.paragraph=s(d.paragraph)("hr",d.hr)("heading",d.heading)("lheading",d.lheading)("blockquote",d.blockquote)("tag","<"+d._tag)("def",d.def)(),d.normal=c({},d),d.gfm=c({},d.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),d.gfm.paragraph=s(d.paragraph)("(?!","(?!"+d.gfm.fences.source.replace("\\1","\\2")+"|"+d.list.source.replace("\\1","\\3")+"|")(),d.tables=c({},d.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=d,t.lex=function(e,n){var r=new t(n);return r.lex(e)},t.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},t.prototype.token=function(e,t,n){for(var r,i,o,a,s,l,c,u,p,h=this,e=e.replace(/^ +$/gm,"");e;)if((o=h.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&h.tokens.push({type:"space"})),o=h.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),h.tokens.push({type:"code",text:h.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=h.rules.fences.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"code",lang:o[2],text:o[3]||""});else if(o=h.rules.heading.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=h.rules.nptable.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 ?/gm,""),h.token(o,t,!0),h.tokens.push({type:"blockquote_end"});else if(o=h.rules.list.exec(e)){for(e=e.substring(o[0].length),a=o[2],h.tokens.push({type:"list_start",ordered:a.length>1}),o=o[0].match(h.rules.item),r=!1,p=o.length,u=0;u1&&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])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:l,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:l,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,p.link=s(p.link)("inside",p._inside)("href",p._href)(),p.reflink=s(p.reflink)("inside",p._inside)(),p.normal=c({},p),p.pedantic=c({},p.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),p.gfm=c({},p.normal,{escape:s(p.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:s(p.text)("]|","~]|")("|","|https?://|")()}),p.breaks=c({},p.gfm,{br:s(p.br)("{2,}","*")(),text:s(p.gfm.text)("{2,}","*")()}),n.rules=p,n.output=function(e,t,r){var i=new n(t,r);return i.output(e)},n.prototype.output=function(e){for(var t,n,r,i,a=this,s="";e;)if(i=a.rules.escape.exec(e))e=e.substring(i[0].length),s+=i[1];else if(i=a.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=":"===i[1].charAt(6)?a.mangle(i[1].substring(7)):a.mangle(i[1]),r=a.mangle("mailto:")+n):(n=o(i[1]),r=n),s+=a.renderer.link(r,null,n);else if(a.inLink||!(i=a.rules.url.exec(e))){if(i=a.rules.tag.exec(e))!a.inLink&&/^/i.test(i[0])&&(a.inLink=!1),e=e.substring(i[0].length),s+=a.options.sanitize?a.options.sanitizer?a.options.sanitizer(i[0]):o(i[0]):i[0];else if(i=a.rules.link.exec(e))e=e.substring(i[0].length),a.inLink=!0,s+=a.outputLink(i,{href:i[2],title:i[3]}),a.inLink=!1;else if((i=a.rules.reflink.exec(e))||(i=a.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=a.links[t.toLowerCase()],!t||!t.href){s+=i[0].charAt(0),e=i[0].substring(1)+e;continue}a.inLink=!0,s+=a.outputLink(i,t),a.inLink=!1}else if(i=a.rules.strong.exec(e))e=e.substring(i[0].length),s+=a.renderer.strong(a.output(i[2]||i[1]));else if(i=a.rules.em.exec(e))e=e.substring(i[0].length),s+=a.renderer.em(a.output(i[2]||i[1]));else if(i=a.rules.code.exec(e))e=e.substring(i[0].length),s+=a.renderer.codespan(o(i[2],!0));else if(i=a.rules.br.exec(e))e=e.substring(i[0].length),s+=a.renderer.br();else if(i=a.rules.del.exec(e))e=e.substring(i[0].length),s+=a.renderer.del(a.output(i[1]));else if(i=a.rules.text.exec(e))e=e.substring(i[0].length),s+=a.renderer.text(o(a.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=o(i[1]),r=n,s+=a.renderer.link(r,null,n);return s},n.prototype.outputLink=function(e,t){var n=o(t.href),r=t.title?o(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,o(e[1]))},n.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},n.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;i.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},r.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'
                        '+(n?e:o(e,!0))+"\n
                        \n":"
                        "+(n?e:o(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.hr=function(){return this.options.xhtml?"
                        \n":"
                        \n"},r.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},r.prototype.listitem=function(e){return"
                      • "+e+"
                      • \n"},r.prototype.paragraph=function(e){return"

                        "+e+"

                        \n"},r.prototype.table=function(e,t){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"},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='
                        "},r.prototype.image=function(e,t,n){var r=''+n+'":">"},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;te.length)break e;if(!(v instanceof i)){u.lastIndex=0;var k=u.exec(v),w=1;if(!k&&h&&y!=o.length-1){if(u.lastIndex=b,k=u.exec(e),!k)break;for(var x=k.index+(p?k[1].length:0),L=k.index+k[0].length,S=y,$=b,_=o.length;S<_&&$=$&&(++y,b=$);if(o[y]instanceof i||o[S-1].greedy)continue;w=S-y,v=e.slice(b,$),k.index-=b}if(k){p&&(g=k[1].length);var x=k.index+g,k=k[0].slice(g),L=x+k.length,C=v.slice(0,x),E=v.slice(L),A=[y,w];C&&A.push(C);var T=new i(s,d?r.tokenize(k,d):k,f,k,h);A.push(T),E&&A.push(E),Array.prototype.splice.apply(o,A)}}}}}return o},hooks:{all:{},add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=r.hooks.all[e];if(n&&n.length)for(var i,o=0;i=n[o++];)i(t)}}},i=r.Token=function(e,t,n,r,i){this.type=e,this.content=t,this.alias=n,this.length=0|(r||"").length,this.greedy=!!i};if(i.stringify=function(e,t,n){if("string"==typeof e)return e;if("Array"===r.util.type(e))return e.map(function(n){return i.stringify(n,t,e)}).join("");var o={type:e.type,content:i.stringify(e.content,t,n),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:n};if("comment"==o.type&&(o.attributes.spellcheck="true"),e.alias){var a="Array"===r.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(o.classes,a)}r.hooks.run("wrap",o);var s=Object.keys(o.attributes).map(function(e){return e+'="'+(o.attributes[e]||"").replace(/"/g,""")+'"'}).join(" ");return"<"+o.tag+' class="'+o.classes.join(" ")+'"'+(s?" "+s:"")+">"+o.content+""},!t.document)return t.addEventListener?(t.addEventListener("message",function(e){var n=JSON.parse(e.data),i=n.language,o=n.code,a=n.immediateClose; +var D=function(){"use strict";function e(e,t,n){void 0===t&&(t="GET");var r=new XMLHttpRequest;return r.open(t,e),r.send(),{then:function(e,t){if(void 0===t&&(t=function(){}),n){var i=setInterval(function(e){return n({step:Math.floor(5*Math.random()+1)})},500);r.addEventListener("progress",n),r.addEventListener("loadend",function(e){n(e),clearInterval(i)})}r.addEventListener("error",t),r.addEventListener("load",function(n){var r=n.target;r.status>=400?t(r):e(r.response)})},abort:function(){return 4!==r.readyState&&r.abort()}}}function t(e,t){var n=[],r={};return e.forEach(function(e){var i=e.level||1,o=i-1;i>t||(r[o]?(r[o].children=r[o].children||[],r[o].children.push(e)):n.push(e),r[i]=e)}),n}function n(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}function r(e){return null===e||void 0===e}function i(){var e=window.location;if(M===e.hash&&!r(j))return j;var t=e.hash.replace(/%23/g,"#").match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,j=t,M=e.hash,t}function o(){return document.body.clientWidth<=600}function a(e){var t=/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g,n=!1,r="-";if(a.occurrences=a.occurrences||{},"string"!=typeof e)return"";n||(e=e.toLowerCase());var i=e.trim().replace(/<[^>\d]+>/g,"").replace(t,"").replace(/\s/g,r).replace(/-+/g,r).replace(/^(\d)/,"_$1"),o=a.occurrences[i];return a.occurrences.hasOwnProperty(i)?o++:o=0,a.occurrences[i]=o,o&&(i=i+"-"+o),i}function s(e){return e.replace(/<(pre|template)[^>]*?>([\s\S]+)<\/(pre|template)>/g,function(e){return e.replace(/:/g,"__colon__")}).replace(/:(\w+?):/gi,'$1').replace(/__colon__/g,":")}function l(){function e(){for(var e,o=document.body.scrollTop,l=0,u=n.length;lo){e||(e=d);break}e=d}if(e){var p=s[e.getAttribute("data-id")];if(p&&p!==c&&(c&&c.classList.remove("active"),p.classList.add("active"),c=p,!t&&!h.noSticky)){var g=0,f=c.offsetTop+c.clientHeight+40,m=c.offsetTop>=i.scrollTop&&f<=i.scrollTop+a,y=f-g=e||h.dom.classList.contains("hidden")?(document.body.classList.add("sticky"),h.noSticky=!1):(document.body.classList.remove("sticky"),h.noSticky=!0)}()}function g(e,t){return t={exports:{}},e(t,t.exports),t.exports}function f(e){return e?(/\/\//.test(e)||(e="https://github.com/"+e),e=e.replace(/^git\+/,""),'\n \n \n '):""}function m(){var e=b()+'';return(o()?e+"
                        ":"
                        "+e)+'
                        \n
                        \n
                        \n
                        '}function y(){var e=", 100%, 85%",t="linear-gradient(to left bottom, hsl("+(Math.floor(255*Math.random())+e)+") 0%, hsl("+(Math.floor(255*Math.random())+e)+") 100%)";return'
                        \n
                        \n
                        \n
                        '}function b(){return''}function v(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='
                      • '+e.title+"
                      • ",e.children&&(t+='
                        • '+v(e.children)+"
                        ")}),t):""}function k(e,t){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=a(e),r="";return r="#/"+i(),D.push({level:t,slug:r+"#"+encodeURIComponent(n),title:e}),"'+e+""},e.code=function(e,t){void 0===t&&(t="");var n=W.highlight(e,W.languages[t]||W.languages.markup);return'
                        '+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''+n+'"},"function"==typeof $docsify.markdown?z=$docsify.markdown.call(this,z,e):($docsify.markdown&&$docsify.markdown.renderer&&($docsify.markdown.renderer=O(e,$docsify.markdown.renderer)),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 D=[],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 a=document.querySelector(".sidebar");a.innerHTML='

                        '+$docsify.name+"

                        "+a.innerHTML}d("button.sidebar-toggle"),$docsify.coverpage?!o()&&window.addEventListener("scroll",h):r.classList.add("sticky")}function _(e){var t=window.Docsify.hook,n=function(e){if(G("article",e),$docsify.loadSidebar||E(),e&&"undefined"!=typeof Vue){R.vm&&R.vm.$destroy();var t=[].slice.call(document.body.querySelectorAll("article>script")).filter(function(e){return!/template/.test(e.type)})[0],n=t?t.innerText.trim():null;t&&t.remove(),R.vm=n?new Function("return "+n)():new Vue({el:"main"}),R.vm&&R.vm.$nextTick(function(e){return l()})}$docsify.auto2top&&setTimeout(function(){return p($docsify.auto2top)},0)};t.emit("before",e,function(e){var r=e?z(e):"";t.emit("after",r,function(e){return n(e||"not found")})})}function C(e){R.navbar&&R.navbar===e||(R.navbar=e,e&&G("nav",z(e)),u("nav"))}function E(e){var n;e?(n=z(e),n=n.match(/]*>([\s\S]+)<\/ul>/g)[0]):n=v(t(D,$docsify.maxLevel),"
                          "),G(".sidebar-nav",n),D[0]&&1===D[0].level&&(document.title=""+D[0].title+(B?" - "+B:""));var r=u(".sidebar-nav",!0);r&&A(r),D=[],l()}function A(e){$docsify.subMaxLevel&&(D[0]&&1===D[0].level&&D.shift(),e.parentNode.innerHTML+=v(t(D,$docsify.subMaxLevel),"
                            "))}function T(e){if(T.dom=T.dom||document.querySelector("section.cover"),!e)return void T.dom.classList.remove("show");if(T.dom.classList.add("show"),T.rendered)return h();var t=D.slice(),n=z(e),r=n.trim().match('

                            ([^<]*?)

                            $');if(D=t.slice(),r){var i=document.querySelector("section.cover");"color"===r[2]?i.style.background=r[1]+(r[3]||""):(i.classList.add("has-mask"),i.style.backgroundImage="url("+r[1]+")"),n=n.replace(r[0],"")}G(".cover-main",n),T.rendered=!0,h()}function q(e){var t,n=e.loaded,r=e.total,i=e.step;if(!R.loading){var o=document.createElement("div");o.classList.add("progress"),document.body.appendChild(o),R.loading=o}i?(t=parseInt(R.loading.style.width,10)+i,t=t>80?80:t):t=Math.floor(n/r*100),R.loading.style.opacity=1,R.loading.style.width=t>=95?"100%":t+"%",t>=95&&(clearTimeout(q.cacheTimeout),q.cacheTimeout=setTimeout(function(e){R.loading.style.opacity=0,R.loading.style.width="0%"},200))}var j=null,M=null;a.clear=function(){a.occurrences={}};var N=Object.prototype.hasOwnProperty,O=Object.assign||function(e){for(var t=arguments,n=1;n/g,">").replace(/"/g,""").replace(/'/g,"'")}function a(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function s(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function l(){}function c(e){for(var t,n,r=arguments,i=1;iAn error occured:

                            "+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:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\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",/])*?>/)(/tag/g,d._tag)(),d.paragraph=s(d.paragraph)("hr",d.hr)("heading",d.heading)("lheading",d.lheading)("blockquote",d.blockquote)("tag","<"+d._tag)("def",d.def)(),d.normal=c({},d),d.gfm=c({},d.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),d.gfm.paragraph=s(d.paragraph)("(?!","(?!"+d.gfm.fences.source.replace("\\1","\\2")+"|"+d.list.source.replace("\\1","\\3")+"|")(),d.tables=c({},d.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=d,t.lex=function(e,n){var r=new t(n);return r.lex(e)},t.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},t.prototype.token=function(e,t,n){for(var r,i,o,a,s,l,c,u,p,h=this,e=e.replace(/^ +$/gm,"");e;)if((o=h.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&h.tokens.push({type:"space"})),o=h.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),h.tokens.push({type:"code",text:h.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=h.rules.fences.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"code",lang:o[2],text:o[3]||""});else if(o=h.rules.heading.exec(e))e=e.substring(o[0].length),h.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=h.rules.nptable.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 ?/gm,""),h.token(o,t,!0),h.tokens.push({type:"blockquote_end"});else if(o=h.rules.list.exec(e)){for(e=e.substring(o[0].length),a=o[2],h.tokens.push({type:"list_start",ordered:a.length>1}),o=o[0].match(h.rules.item),r=!1,p=o.length,u=0;u1&&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])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:l,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:l,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,p.link=s(p.link)("inside",p._inside)("href",p._href)(),p.reflink=s(p.reflink)("inside",p._inside)(),p.normal=c({},p),p.pedantic=c({},p.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),p.gfm=c({},p.normal,{escape:s(p.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:s(p.text)("]|","~]|")("|","|https?://|")()}),p.breaks=c({},p.gfm,{br:s(p.br)("{2,}","*")(),text:s(p.gfm.text)("{2,}","*")()}),n.rules=p,n.output=function(e,t,r){var i=new n(t,r);return i.output(e)},n.prototype.output=function(e){for(var t,n,r,i,a=this,s="";e;)if(i=a.rules.escape.exec(e))e=e.substring(i[0].length),s+=i[1];else if(i=a.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=":"===i[1].charAt(6)?a.mangle(i[1].substring(7)):a.mangle(i[1]),r=a.mangle("mailto:")+n):(n=o(i[1]),r=n),s+=a.renderer.link(r,null,n);else if(a.inLink||!(i=a.rules.url.exec(e))){if(i=a.rules.tag.exec(e))!a.inLink&&/^/i.test(i[0])&&(a.inLink=!1),e=e.substring(i[0].length),s+=a.options.sanitize?a.options.sanitizer?a.options.sanitizer(i[0]):o(i[0]):i[0];else if(i=a.rules.link.exec(e))e=e.substring(i[0].length),a.inLink=!0,s+=a.outputLink(i,{href:i[2],title:i[3]}),a.inLink=!1;else if((i=a.rules.reflink.exec(e))||(i=a.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=a.links[t.toLowerCase()],!t||!t.href){s+=i[0].charAt(0),e=i[0].substring(1)+e;continue}a.inLink=!0,s+=a.outputLink(i,t),a.inLink=!1}else if(i=a.rules.strong.exec(e))e=e.substring(i[0].length),s+=a.renderer.strong(a.output(i[2]||i[1]));else if(i=a.rules.em.exec(e))e=e.substring(i[0].length),s+=a.renderer.em(a.output(i[2]||i[1]));else if(i=a.rules.code.exec(e))e=e.substring(i[0].length),s+=a.renderer.codespan(o(i[2],!0));else if(i=a.rules.br.exec(e))e=e.substring(i[0].length),s+=a.renderer.br();else if(i=a.rules.del.exec(e))e=e.substring(i[0].length),s+=a.renderer.del(a.output(i[1]));else if(i=a.rules.text.exec(e))e=e.substring(i[0].length),s+=a.renderer.text(o(a.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=o(i[1]),r=n,s+=a.renderer.link(r,null,n);return s},n.prototype.outputLink=function(e,t){var n=o(t.href),r=t.title?o(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,o(e[1]))},n.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},n.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;i.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},r.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'
                            '+(n?e:o(e,!0))+"\n
                            \n":"
                            "+(n?e:o(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.hr=function(){return this.options.xhtml?"
                            \n":"
                            \n"},r.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},r.prototype.listitem=function(e){return"
                          • "+e+"
                          • \n"},r.prototype.paragraph=function(e){return"

                            "+e+"

                            \n"},r.prototype.table=function(e,t){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"},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='
                            "},r.prototype.image=function(e,t,n){var r=''+n+'":">"},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;te.length)break e;if(!(v instanceof i)){u.lastIndex=0;var k=u.exec(v),w=1;if(!k&&h&&y!=o.length-1){if(u.lastIndex=b,k=u.exec(e),!k)break;for(var x=k.index+(p?k[1].length:0),L=k.index+k[0].length,S=y,$=b,_=o.length;S<_&&$=$&&(++y,b=$);if(o[y]instanceof i||o[S-1].greedy)continue;w=S-y,v=e.slice(b,$),k.index-=b}if(k){p&&(g=k[1].length);var x=k.index+g,k=k[0].slice(g),L=x+k.length,C=v.slice(0,x),E=v.slice(L),A=[y,w];C&&A.push(C);var T=new i(s,d?r.tokenize(k,d):k,f,k,h);A.push(T),E&&A.push(E),Array.prototype.splice.apply(o,A)}}}}}return o},hooks:{all:{},add:function(e,t){var n=r.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=r.hooks.all[e];if(n&&n.length)for(var i,o=0;i=n[o++];)i(t)}}},i=r.Token=function(e,t,n,r,i){this.type=e,this.content=t,this.alias=n,this.length=0|(r||"").length,this.greedy=!!i};if(i.stringify=function(e,t,n){if("string"==typeof e)return e;if("Array"===r.util.type(e))return e.map(function(n){return i.stringify(n,t,e)}).join("");var o={type:e.type,content:i.stringify(e.content,t,n),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:n};if("comment"==o.type&&(o.attributes.spellcheck="true"),e.alias){var a="Array"===r.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(o.classes,a)}r.hooks.run("wrap",o);var s=Object.keys(o.attributes).map(function(e){return e+'="'+(o.attributes[e]||"").replace(/"/g,""")+'"'}).join(" ");return"<"+o.tag+' class="'+o.classes.join(" ")+'"'+(s?" "+s:"")+">"+o.content+""},!t.document)return t.addEventListener?(t.addEventListener("message",function(e){var n=JSON.parse(e.data),i=n.language,o=n.code,a=n.immediateClose; t.postMessage(r.highlight(o,r.languages[i],i)),a&&t.close()},!1),t.Prism):t.Prism;var o=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return o&&(r.filename=o.src,document.addEventListener&&!o.hasAttribute("data-manual")&&("loading"!==document.readyState?window.requestAnimationFrame?window.requestAnimationFrame(r.highlightAll):window.setTimeout(r.highlightAll,16):document.addEventListener("DOMContentLoaded",r.highlightAll))),t.Prism}();e.exports&&(e.exports=n),"undefined"!=typeof I&&(I.Prism=n),n.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},n.hooks.add("wrap",function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))}),n.languages.xml=n.languages.markup,n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:{pattern:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},n.languages.css.atrule.inside.rest=n.util.clone(n.languages.css),n.languages.markup&&(n.languages.insertBefore("markup","tag",{style:{pattern:/()[\w\W]*?(?=<\/style>)/i,lookbehind:!0,inside:n.languages.css,alias:"language-css"}}),n.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:n.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:n.languages.css}},alias:"language-css"}},n.languages.markup.tag)),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:{pattern:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(true|false)\b/,function:/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,function:/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*\*?|\/|~|\^|%|\.{3}/}),n.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0,greedy:!0}}),n.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\\\|\\?[^\\])*?`/,greedy:!0,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}}}),n.languages.markup&&n.languages.insertBefore("markup","tag",{script:{pattern:/()[\w\W]*?(?=<\/script>)/i,lookbehind:!0,inside:n.languages.javascript,alias:"language-javascript"}}),n.languages.js=n.languages.javascript,function(){"undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.forEach&&Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var r,i=t.getAttribute("data-src"),o=t,a=/\blang(?:uage)?-(?!\*)(\w+)\b/i;o&&!a.test(o.className);)o=o.parentNode;if(o&&(r=(t.className.match(a)||[,""])[1]),!r){var s=(i.match(/\.(\w+)$/)||[,""])[1];r=e[s]||s}var l=document.createElement("code");l.className="language-"+r,t.textContent="",l.textContent="Loading…",t.appendChild(l);var c=new XMLHttpRequest;c.open("GET",i,!0),c.onreadystatechange=function(){4==c.readyState&&(c.status<400&&c.responseText?(l.textContent=c.responseText,n.highlightElement(l)):c.status>=400?l.textContent="✖ Error "+c.status+" while fetching file: "+c.statusText:l.textContent="✖ Error: File does not exist or is empty")},c.send(null)})},document.addEventListener("DOMContentLoaded",self.Prism.fileHighlight))}()}),z=F,D=[],R={},B=document.title,G=function(e,t){return e="object"==typeof e?e:document.querySelector(e),e.innerHTML=t,a.clear(),e},Z=function(){this.beforeHooks=[],this.afterHooks=[],this.initHooks=[],this.readyHooks=[],this.doneEachHooks=[]};Z.prototype.beforeEach=function(e){this.beforeHooks.push(e)},Z.prototype.afterEach=function(e){this.afterHooks.push(e)},Z.prototype.doneEach=function(e){this.doneEachHooks.push(e)},Z.prototype.init=function(e){this.initHooks.push(e)},Z.prototype.ready=function(e){this.readyHooks.push(e)},Z.prototype.emit=function(e,t,n){var r=t,i=this[e+"Hooks"],o=function(e){var a=i[e];if(e>=i.length)n&&n(r);else if("function"==typeof a)if(2===a.length)a(t,function(t){r=t,o(e+1)});else{var s=a(t);r=void 0!==s?s:r,o(e+1)}else o(e+1)};o(0)};var U=O({el:"#app",repo:"",maxLevel:6,subMaxLevel:0,loadSidebar:null,loadNavbar:null,homepage:"README.md",coverpage:"",basePath:"",auto2top:!1,name:"",themeColor:"",nameLink:window.location.pathname,ga:""},window.$docsify),V=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();if(V){for(var Y in U){var J=V.getAttribute("data-"+n(Y));U[Y]=r(J)?U[Y]:J||!0}U.loadSidebar===!0&&(U.loadSidebar="_sidebar.md"),U.loadNavbar===!0&&(U.loadNavbar="_navbar.md"),U.coverpage===!0&&(U.coverpage="_coverpage.md"),U.repo===!0&&(U.repo=""),U.name===!0&&(U.name="")}var X=new Z;window.$docsify=U,window.Docsify={installed:!0,utils:O({},H),hook:X},S();var K=null,Q=null,ee=function(e){return U.alias[e]?ee(U.alias[e]):e},te=function(t){var n,r=i();if(K===r)return t();var o=K=U.basePath+r;/\//.test(o)?o&&!/\/$/.test(o)&&(o=o.match(/(\S*\/)[^\/]+$/)[1]):o="",r=U.alias&&U.alias["/"+r]?ee("/"+r):(U.basePath+r).replace(/\/+/,"/"),n=r?/\.md$/.test(r)?r:/\/$/.test(r)?r+"README.md":r+".md":U.homepage||"README.md",U.coverpage&&n===U.homepage&&e(U.coverpage).then(T),Q&&Q.abort&&Q.abort(),Q=e(n,"GET",q),Q.then(function(r){if(_(r),U.coverpage&&n!==U.homepage&&T(),U.loadSidebar){var i=function(e){E(e),t()};e(o+U.loadSidebar).then(i,function(t){return e(U.loadSidebar).then(i)})}else t()},function(e){return _(null)}),U.loadNavbar&&e(o+U.loadNavbar).then(C,function(t){return e(U.loadNavbar).then(C)})},ne=function(){setTimeout(function(e){[].concat(U.plugins).forEach(function(e){return"function"==typeof e&&e(X)}),window.Docsify.hook.emit("init");var t=document.querySelector(U.el)||document.body,n=t!==document.body,r=function(){te(function(e){c(),u("nav"),window.Docsify.hook.emit("doneEach")})};$(t,n),r(),/^#\//.test(window.location.hash)||(window.location.hash="#/"),window.addEventListener("hashchange",r),window.Docsify.hook.emit("ready")},0)},re=ne();return re}(); From 5dcd6d43ea3965d1b34414afb04a87a92a8208e0 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Wed, 15 Feb 2017 20:01:11 +0800 Subject: [PATCH 014/746] -> v2.4.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 57aa193..4426089 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "docsify", - "version": "2.4.2", + "version": "2.4.3", "description": "A magical documentation generator.", "main": "lib/docsify.js", "files": [ From aad62b65f512090b7a28eb6ef506c4f59217c567 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Thu, 16 Feb 2017 23:37:39 +0800 Subject: [PATCH 015/746] refactor(core): adjust directory structure: --- src/core/config.js | 38 +++++++++++++ src/core/event/index.js | 11 ++++ src/core/fetch/ajax.js | 37 ++++++++++++ src/core/fetch/index.js | 13 +++++ src/core/index.js | 30 ++++++++++ src/core/init/index.js | 27 +++++++++ src/core/init/lifecycle.js | 41 +++++++++++++ src/core/render/dom.js | 12 ++++ src/core/render/index.js | 9 +++ src/core/render/progressbar.js | 45 +++++++++++++++ src/{ => core/render}/tpl.js | 2 +- src/core/route/hash.js | 24 ++++++++ src/core/route/index.js | 17 ++++++ src/core/route/util.js | 11 ++++ src/core/util/core.js | 56 ++++++++++++++++++ src/core/util/env.js | 5 ++ src/core/util/index.js | 2 + .../util/polyfill/css-vars.js} | 4 +- src/hook.js | 57 ------------------- src/render.js | 33 ----------- 20 files changed, 381 insertions(+), 93 deletions(-) create mode 100644 src/core/config.js create mode 100644 src/core/event/index.js create mode 100644 src/core/fetch/ajax.js create mode 100644 src/core/fetch/index.js create mode 100644 src/core/index.js create mode 100644 src/core/init/index.js create mode 100644 src/core/init/lifecycle.js create mode 100644 src/core/render/dom.js create mode 100644 src/core/render/index.js create mode 100644 src/core/render/progressbar.js rename src/{ => core/render}/tpl.js (98%) create mode 100644 src/core/route/hash.js create mode 100644 src/core/route/index.js create mode 100644 src/core/route/util.js create mode 100644 src/core/util/core.js create mode 100644 src/core/util/env.js create mode 100644 src/core/util/index.js rename src/{polyfill.js => core/util/polyfill/css-vars.js} (91%) delete mode 100644 src/hook.js diff --git a/src/core/config.js b/src/core/config.js new file mode 100644 index 0000000..d344aae --- /dev/null +++ b/src/core/config.js @@ -0,0 +1,38 @@ +import { merge, camelize, isPrimitive } from './util/core' + +const 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, + ga: '' +}, window.$docsify) + +const script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop() + +if (script) { + for (const prop in config) { + const val = script.getAttribute('data-' + camelize(prop)) + + if (isPrimitive(val)) { + config[prop] = val === '' ? true : val + } + } + + if (config.loadSidebar === true) config.loadSidebar = '_sidebar.md' + if (config.loadNavbar === true) config.loadNavbar = '_navbar.md' + if (config.coverpage === true) config.coverpage = '_coverpage.md' + if (config.repo === true) config.repo = '' + if (config.name === true) config.name = '' +} + +export default config diff --git a/src/core/event/index.js b/src/core/event/index.js new file mode 100644 index 0000000..46d9d28 --- /dev/null +++ b/src/core/event/index.js @@ -0,0 +1,11 @@ +export function eventMixin (Docsify) { + Docsify.prototype.$bindEvents = function () { + } + + Docsify.prototype.$resetEvents = function () { + } +} + +export function initEvent (vm) { + vm.$bindEvents() +} diff --git a/src/core/fetch/ajax.js b/src/core/fetch/ajax.js new file mode 100644 index 0000000..ba79b76 --- /dev/null +++ b/src/core/fetch/ajax.js @@ -0,0 +1,37 @@ +import progressbar from '../render/progressbar' +import { noop } from '../util/core' + +/** + * Simple ajax get + * @param {String} url + * @param {Boolean} [loading=false] has loading bar + * @return { then(resolve, reject), abort } + */ +export function get (url, hasLoading = false) { + const xhr = new XMLHttpRequest() + + xhr.open('GET', url) + xhr.send() + + return { + then: function (success, error = noop) { + const on = xhr.addEventListener + + if (hasLoading) { + const id = setInterval(_ => progressbar({}), 500) + + on('progress', progressbar) + on('loadend', evt => { + progressbar(evt) + clearInterval(id) + }) + } + + on('error', error) + on('load', ({ target }) => { + target.status >= 400 ? error(target) : success(target.response) + }) + }, + abort: () => xhr.readyState !== 4 && xhr.abort() + } +} diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js new file mode 100644 index 0000000..7771e89 --- /dev/null +++ b/src/core/fetch/index.js @@ -0,0 +1,13 @@ +import { callHook } from '../init/lifecycle' + +export function fetchMixin (Docsify) { + Docsify.prototype.$fetch = function () { + } +} + +export function initFetch (vm) { + vm.$fetch(result => { + vm.$resetEvents() + callHook(vm, 'doneEach') + }) +} diff --git a/src/core/index.js b/src/core/index.js new file mode 100644 index 0000000..96cab23 --- /dev/null +++ b/src/core/index.js @@ -0,0 +1,30 @@ +import { initMixin } from './init' +import { routeMixin } from './route' +import { renderMixin } from './render' +import { fetchMixin } from './fetch' +import { eventMixin } from './event' +import * as util from './util' +import { get as load } from './fetch/ajax' +import * as routeUtil from './route/util' + +function Docsify () { + this._init() +} + +initMixin(Docsify) +routeMixin(Docsify) +renderMixin(Docsify) +fetchMixin(Docsify) +eventMixin(Docsify) + +/** + * Global API + */ +window.Docsify = { + util: util.merge({ load }, util, routeUtil) +} + +/** + * Run Docsify + */ +setTimeout(() => new Docsify(), 0) diff --git a/src/core/init/index.js b/src/core/init/index.js new file mode 100644 index 0000000..8a6c2a3 --- /dev/null +++ b/src/core/init/index.js @@ -0,0 +1,27 @@ +import config from '../config' +import { initLifecycle, callHook } from './lifecycle' +import { initRender } from '../render' +import { initRoute } from '../route' +import { initEvent } from '../event' +import { initFetch } from '../fetch' +import { isFn } from '../util/core' + +export function initMixin (Docsify) { + Docsify.prototype._init = function () { + const vm = this + vm._config = config || {} + + initLifecycle(vm) // Init hooks + initPlugin(vm) // Install plugins + callHook(vm, 'init') + initRender(vm) // Render base DOM + initEvent(vm) // Bind events + initRoute(vm) // Add hashchange eventListener + initFetch(vm) // Fetch data + callHook(vm, 'ready') + } +} + +function initPlugin (vm) { + [].concat(vm.config.plugins).forEach(fn => isFn(fn) && fn(vm.bindHook)) +} diff --git a/src/core/init/lifecycle.js b/src/core/init/lifecycle.js new file mode 100644 index 0000000..e4a48a8 --- /dev/null +++ b/src/core/init/lifecycle.js @@ -0,0 +1,41 @@ +import { noop } from '../util/core' + +export function initLifecycle (vm) { + const hooks = ['init', 'beforeEach', 'afterEach', 'doneEach', 'ready'] + + vm._hooks = {} + vm.bindHook = {} + hooks.forEach(hook => { + const arr = vm._hooks[hook] = [] + vm._bindHook[hook] = fn => arr.push(fn) + }) +} + +export function callHook (vm, hook, data, next = noop) { + let newData = data + const queue = vm._hooks[hook] + + const step = function (index) { + const hook = queue[index] + if (index >= queue.length) { + next(newData) + } else { + if (typeof hook === 'function') { + if (hook.length === 2) { + hook(data, result => { + newData = result + step(index + 1) + }) + } else { + const result = hook(data) + newData = result !== undefined ? result : newData + step(index + 1) + } + } else { + step(index + 1) + } + } + } + + step(0) +} diff --git a/src/core/render/dom.js b/src/core/render/dom.js new file mode 100644 index 0000000..8277095 --- /dev/null +++ b/src/core/render/dom.js @@ -0,0 +1,12 @@ +const cacheNode = {} + +export function getCacheNode (el) { + if (typeof el === 'string') { + const selector = el + + el = cacheNode[el] || document.querySelector(el) + if (!el) console.error('Cannot find element:', selector) + } + + return el +} diff --git a/src/core/render/index.js b/src/core/render/index.js new file mode 100644 index 0000000..03ef3f0 --- /dev/null +++ b/src/core/render/index.js @@ -0,0 +1,9 @@ +export function renderMixin (Docsify) { + Docsify.prototype._renderTo = function (dom, content) { + + } +} + +export function initRender (vm) { + // init +} diff --git a/src/core/render/progressbar.js b/src/core/render/progressbar.js new file mode 100644 index 0000000..1da5b22 --- /dev/null +++ b/src/core/render/progressbar.js @@ -0,0 +1,45 @@ +import { isPrimitive } from '../util/core' + +let loadingEl +let timeId + +/** + * Init progress component + */ +function init () { + if (loadingEl) return + const div = document.createElement('div') + + div.classList.add('progress') + document.body.appendChild(div) + loadingEl = div +} +/** + * Render progress bar + */ +export default function ({ loaded, total, step }) { + let num + + loadingEl = init() + + if (!isPrimitive(step)) { + step = Math.floor(Math.random() * 5 + 1) + } + if (step) { + num = parseInt(loadingEl.style.width, 10) + step + num = num > 80 ? 80 : num + } else { + num = Math.floor(loaded / total * 100) + } + + loadingEl.style.opacity = 1 + loadingEl.style.width = num >= 95 ? '100%' : num + '%' + + if (num >= 95) { + clearTimeout(timeId) + timeId = setTimeout(_ => { + loadingEl.style.opacity = 0 + loadingEl.style.width = '0%' + }, 200) + } +} diff --git a/src/tpl.js b/src/core/render/tpl.js similarity index 98% rename from src/tpl.js rename to src/core/render/tpl.js index 6655129..df58979 100644 --- a/src/tpl.js +++ b/src/core/render/tpl.js @@ -1,4 +1,4 @@ -import { isMobile } from './util' +import { isMobile } from '../util/core' /** * Render github corner * @param {Object} data diff --git a/src/core/route/hash.js b/src/core/route/hash.js new file mode 100644 index 0000000..90d180c --- /dev/null +++ b/src/core/route/hash.js @@ -0,0 +1,24 @@ +import { cleanPath, getLocation } from './util' + +export function ensureSlash () { + const path = getHash() + if (path.charAt(0) === '/') return + replaceHash('/' + path) +} + +export function getHash () { + // We can't use window.location.hash here because it's not + // consistent across browsers - Firefox will pre-decode it! + const href = window.location.href + const index = href.indexOf('#') + return index === -1 ? '' : href.slice(index + 1) +} + +function replaceHash (path) { + const i = window.location.href.indexOf('#') + window.location.replace( + window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path + ) +} + +// TODO 把第二个 hash 转成 ?id= diff --git a/src/core/route/index.js b/src/core/route/index.js new file mode 100644 index 0000000..011db74 --- /dev/null +++ b/src/core/route/index.js @@ -0,0 +1,17 @@ +import { ensureSlash } from './hash' + +export function routeMixin (Docsify) { + Docsify.prototype.$route = { + query: location.query || {}, + path: location.path || '/', + base: '' + } +} + +export function initRoute (vm) { + ensureSlash() + window.addEventListener('hashchange', () => { + ensureSlash() + vm.$fetch() + }) +} diff --git a/src/core/route/util.js b/src/core/route/util.js new file mode 100644 index 0000000..4cbf898 --- /dev/null +++ b/src/core/route/util.js @@ -0,0 +1,11 @@ +export function cleanPath (path) { + return path.replace(/\/+/g, '/') +} + +export function getLocation (base) { + let path = window.location.pathname + if (base && path.indexOf(base) === 0) { + path = path.slice(base.length) + } + return (path || '/') + window.location.search + window.location.hash +} diff --git a/src/core/util/core.js b/src/core/util/core.js new file mode 100644 index 0000000..9688983 --- /dev/null +++ b/src/core/util/core.js @@ -0,0 +1,56 @@ +/** + * Create a cached version of a pure function. + */ +function cached (fn) { + const cache = Object.create(null) + return function cachedFn (str) { + const hit = cache[str] + return hit || (cache[str] = fn(str)) + } +} + +/** + * Camelize a hyphen-delimited string. + */ +const camelizeRE = /-(\w)/g +export const camelize = cached((str) => { + return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') +}) + +/** + * Simple Object.assign polyfill + */ +export const merge = Object.assign || function (to) { + const hasOwn = Object.prototype.hasOwnProperty + + for (let i = 1; i < arguments.length; i++) { + const from = Object(arguments[i]) + + for (const key in from) { + if (hasOwn.call(from, key)) { + to[key] = from[key] + } + } + } + + return to +} + +/** + * Check if value is primitive + */ +export function isPrimitive (value) { + return typeof value === 'string' || typeof value === 'number' +} + +/** + * Perform no operation. + */ +export function noop () {} + +/** + * Check if value is function + */ +export function isFn (obj) { + return typeof obj === 'function' +} diff --git a/src/core/util/env.js b/src/core/util/env.js new file mode 100644 index 0000000..1e79cfe --- /dev/null +++ b/src/core/util/env.js @@ -0,0 +1,5 @@ +export const UA = window.navigator.userAgent.toLowerCase() + +export const isIE = UA && /msie|trident/.test(UA) + +export const isMobile = document.body.clientWidth <= 600 diff --git a/src/core/util/index.js b/src/core/util/index.js new file mode 100644 index 0000000..bfcc8b2 --- /dev/null +++ b/src/core/util/index.js @@ -0,0 +1,2 @@ +export * from './core' +export * from './env' diff --git a/src/polyfill.js b/src/core/util/polyfill/css-vars.js similarity index 91% rename from src/polyfill.js rename to src/core/util/polyfill/css-vars.js index f3a032b..f0200e6 100644 --- a/src/polyfill.js +++ b/src/core/util/polyfill/css-vars.js @@ -1,4 +1,4 @@ -import { load } from './util' +import { get } from '../fetch/ajax' function replaceVar (block) { block.innerHTML = block.innerHTML.replace(/var\(\s*--theme-color.*?\)/g, $docsify.themeColor) @@ -18,7 +18,7 @@ export function cssVars () { if (!/\.css$/.test(href)) return - load(href).then(res => { + get(href).then(res => { const style = document.createElement('style') style.innerHTML = res diff --git a/src/hook.js b/src/hook.js deleted file mode 100644 index 401765a..0000000 --- a/src/hook.js +++ /dev/null @@ -1,57 +0,0 @@ -export default class Hook { - constructor () { - this.beforeHooks = [] - this.afterHooks = [] - this.initHooks = [] - this.readyHooks = [] - this.doneEachHooks = [] - } - - beforeEach (fn) { - this.beforeHooks.push(fn) - } - - afterEach (fn) { - this.afterHooks.push(fn) - } - - doneEach (fn) { - this.doneEachHooks.push(fn) - } - - init (fn) { - this.initHooks.push(fn) - } - - ready (fn) { - this.readyHooks.push(fn) - } - - emit (name, data, next) { - let newData = data - const queue = this[name + 'Hooks'] - const step = function (index) { - const hook = queue[index] - if (index >= queue.length) { - next && next(newData) - } else { - if (typeof hook === 'function') { - if (hook.length === 2) { - hook(data, result => { - newData = result - step(index + 1) - }) - } else { - const result = hook(data) - newData = result !== undefined ? result : newData - step(index + 1) - } - } else { - step(index + 1) - } - } - } - - step(0) - } -} diff --git a/src/render.js b/src/render.js index 26a5d53..4125088 100644 --- a/src/render.js +++ b/src/render.js @@ -235,36 +235,3 @@ export function renderCover (content) { event.sticky() } - -/** - * render loading bar - * @return {[type]} [description] - */ -export function renderLoading ({ loaded, total, step }) { - let num - - if (!CACHE.loading) { - const div = document.createElement('div') - - div.classList.add('progress') - document.body.appendChild(div) - CACHE.loading = div - } - if (step) { - num = parseInt(CACHE.loading.style.width, 10) + step - num = num > 80 ? 80 : num - } else { - num = Math.floor(loaded / total * 100) - } - - CACHE.loading.style.opacity = 1 - CACHE.loading.style.width = num >= 95 ? '100%' : num + '%' - - if (num >= 95) { - clearTimeout(renderLoading.cacheTimeout) - renderLoading.cacheTimeout = setTimeout(_ => { - CACHE.loading.style.opacity = 0 - CACHE.loading.style.width = '0%' - }, 200) - } -} From 8bee8f0213fe40df64af94a75659791d7b786805 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Fri, 17 Feb 2017 23:09:09 +0800 Subject: [PATCH 016/746] refactor(core): add render --- README.md | 2 +- build/build.js | 61 ++++++++++++++++------------- docs/README.md | 2 +- docs/zh-cn/README.md | 2 +- src/core/config.js | 4 +- src/core/event/index.js | 16 ++++++-- src/core/event/scroll.js | 10 +++++ src/core/event/sidebar.js | 28 +++++++++++++ src/core/fetch/index.js | 3 +- src/core/init/index.js | 4 +- src/core/init/lifecycle.js | 4 +- src/core/render/dom.js | 12 ------ src/core/render/index.js | 44 +++++++++++++++++++-- src/core/render/progressbar.js | 5 ++- src/core/render/tpl.js | 63 ++++++++++++++++-------------- src/core/route/hash.js | 3 +- src/core/util/dom.js | 41 +++++++++++++++++++ src/core/util/index.js | 1 + src/core/util/polyfill/css-vars.js | 27 +++++++------ src/themes/basic/_layout.css | 2 +- 20 files changed, 232 insertions(+), 102 deletions(-) create mode 100644 src/core/event/scroll.js create mode 100644 src/core/event/sidebar.js delete mode 100644 src/core/render/dom.js create mode 100644 src/core/util/dom.js diff --git a/README.md b/README.md index dd7de59..3e7554c 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ - Smart full-text search plugin - Multiple themes - Useful plugin API -- Compatible with IE9+ +- Compatible with IE10+ ## Quick start Create a `index.html`. diff --git a/build/build.js b/build/build.js index cbeefc9..96adf07 100644 --- a/build/build.js +++ b/build/build.js @@ -27,34 +27,39 @@ var build = function (opts) { } build({ - entry: 'index.js', + entry: 'core/index.js', output: 'docsify.js', plugins: [commonjs(), nodeResolve()] }) -isProd && build({ - entry: 'index.js', - output: 'docsify.min.js', - plugins: [commonjs(), nodeResolve(), uglify()] -}) -build({ - entry: 'plugins/search.js', - output: 'plugins/search.js', - moduleName: 'D.Search' -}) -isProd && build({ - entry: 'plugins/search.js', - output: 'plugins/search.min.js', - moduleName: 'D.Search', - plugins: [uglify()] -}) -build({ - entry: 'plugins/ga.js', - output: 'plugins/ga.js', - moduleName: 'D.GA' -}) -isProd && build({ - entry: 'plugins/ga.js', - output: 'plugins/ga.min.js', - moduleName: 'D.GA', - plugins: [uglify()] -}) + +// build({ +// entry: 'plugins/search.js', +// output: 'plugins/search.js', +// moduleName: 'D.Search' +// }) + +// build({ +// entry: 'plugins/ga.js', +// output: 'plugins/ga.js', +// moduleName: 'D.GA' +// }) + +if (isProd) { + build({ + entry: 'index.js', + output: 'docsify.min.js', + plugins: [commonjs(), nodeResolve(), uglify()] + }) + build({ + entry: 'plugins/search.js', + output: 'plugins/search.min.js', + moduleName: 'D.Search', + plugins: [uglify()] + }) + build({ + entry: 'plugins/ga.js', + output: 'plugins/ga.min.js', + moduleName: 'D.GA', + plugins: [uglify()] + }) +} diff --git a/docs/README.md b/docs/README.md index 529c54b..51f2506 100644 --- a/docs/README.md +++ b/docs/README.md @@ -15,7 +15,7 @@ See the [Quick start](/quickstart) for more details. - Smart full-text search plugin - Multiple themes - Useful plugin API -- Compatible with IE9+ +- Compatible with IE10+ ## Examples diff --git a/docs/zh-cn/README.md b/docs/zh-cn/README.md index e5051b1..5f6e9fa 100644 --- a/docs/zh-cn/README.md +++ b/docs/zh-cn/README.md @@ -16,7 +16,7 @@ docsify 是一个动态生成文档网站的工具。不同于 GitBook、Hexo - 智能的全文搜索 - 提供多套主题 - 丰富的 API -- 兼容 IE9+ +- 兼容 IE10+ ## 例子 diff --git a/src/core/config.js b/src/core/config.js index d344aae..d11c3d1 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -17,7 +17,9 @@ const config = merge({ ga: '' }, window.$docsify) -const script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop() +const script = document.currentScript || + [].slice.call(document.getElementsByTagName('script')) + .filter(n => /docsify\./.test(n.src))[0] if (script) { for (const prop in config) { diff --git a/src/core/event/index.js b/src/core/event/index.js index 46d9d28..a31188b 100644 --- a/src/core/event/index.js +++ b/src/core/event/index.js @@ -1,11 +1,19 @@ -export function eventMixin (Docsify) { - Docsify.prototype.$bindEvents = function () { - } +import { isMobile } from '../util/env' +import { dom, on } from '../util/dom' +import * as sidebar from './sidebar' +export function eventMixin (Docsify) { Docsify.prototype.$resetEvents = function () { } } export function initEvent (vm) { - vm.$bindEvents() + // Bind toggle button + sidebar.btn('button.sidebar-toggle') + // Bind sticky effect + if (vm.config.coverpage) { + !isMobile && on('scroll', sidebar.sticky) + } else { + dom.body.classList.add('sticky') + } } diff --git a/src/core/event/scroll.js b/src/core/event/scroll.js new file mode 100644 index 0000000..b79589b --- /dev/null +++ b/src/core/event/scroll.js @@ -0,0 +1,10 @@ +export function activeSidebar () { + +} + +export function scrollIntoView () { + +} + +export function scroll2Top () { +} diff --git a/src/core/event/sidebar.js b/src/core/event/sidebar.js new file mode 100644 index 0000000..aeaeeed --- /dev/null +++ b/src/core/event/sidebar.js @@ -0,0 +1,28 @@ +import { isMobile } from '../util/env' +import { getNode, on, dom } from '../util/dom' +/** + * Toggle button + */ +export function btn (el) { + const toggle = () => dom.body.classList.toggle('close') + + el = getNode(el) + on(el, 'click', toggle) + + if (isMobile) { + const sidebar = getNode('.sidebar') + + on(sidebar, 'click', () => { + toggle() + setTimeout(() => activeLink(sidebar, true), 0) + }) + } +} + +export function sticky () { + +} + +export function activeLink () { + +} diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index 7771e89..61acc81 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -1,7 +1,8 @@ import { callHook } from '../init/lifecycle' export function fetchMixin (Docsify) { - Docsify.prototype.$fetch = function () { + Docsify.prototype.$fetch = function (path) { + // 加载侧边栏、导航、内容 } } diff --git a/src/core/init/index.js b/src/core/init/index.js index 8a6c2a3..826e6ef 100644 --- a/src/core/init/index.js +++ b/src/core/init/index.js @@ -9,7 +9,7 @@ import { isFn } from '../util/core' export function initMixin (Docsify) { Docsify.prototype._init = function () { const vm = this - vm._config = config || {} + vm.config = config || {} initLifecycle(vm) // Init hooks initPlugin(vm) // Install plugins @@ -23,5 +23,5 @@ export function initMixin (Docsify) { } function initPlugin (vm) { - [].concat(vm.config.plugins).forEach(fn => isFn(fn) && fn(vm.bindHook)) + [].concat(vm.config.plugins).forEach(fn => isFn(fn) && fn(vm._lifecycle, vm)) } diff --git a/src/core/init/lifecycle.js b/src/core/init/lifecycle.js index e4a48a8..380bac1 100644 --- a/src/core/init/lifecycle.js +++ b/src/core/init/lifecycle.js @@ -4,10 +4,10 @@ export function initLifecycle (vm) { const hooks = ['init', 'beforeEach', 'afterEach', 'doneEach', 'ready'] vm._hooks = {} - vm.bindHook = {} + vm._lifecycle = {} hooks.forEach(hook => { const arr = vm._hooks[hook] = [] - vm._bindHook[hook] = fn => arr.push(fn) + vm._lifecycle[hook] = fn => arr.push(fn) }) } diff --git a/src/core/render/dom.js b/src/core/render/dom.js deleted file mode 100644 index 8277095..0000000 --- a/src/core/render/dom.js +++ /dev/null @@ -1,12 +0,0 @@ -const cacheNode = {} - -export function getCacheNode (el) { - if (typeof el === 'string') { - const selector = el - - el = cacheNode[el] || document.querySelector(el) - if (!el) console.error('Cannot find element:', selector) - } - - return el -} diff --git a/src/core/render/index.js b/src/core/render/index.js index 03ef3f0..12f50c5 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -1,9 +1,47 @@ -export function renderMixin (Docsify) { - Docsify.prototype._renderTo = function (dom, content) { +import { getNode, dom } from '../util/dom' +import cssVars from '../util/polyfill/css-vars' +import * as tpl from './tpl' +export function renderMixin (Docsify) { + Docsify.prototype._renderTo = function (el, content, replace) { + const node = getNode(el) + if (node) node[replace ? 'outerHTML' : 'innerHTML'] = content } } export function initRender (vm) { - // init + const config = vm.config + const id = config.el || '#app' + const navEl = dom.find('nav') || dom.create('nav') + + let el = dom.find(id) + let html = '' + + navEl.classList.add('app-nav') + + if (!config.repo) { + navEl.classList.add('no-badge') + } + if (!el) { + el = dom.create(id) + dom.appendTo(dom.body, el) + } + if (config.repo) { + html += tpl.corner(config.repo) + } + if (config.coverpage) { + html += tpl.cover() + } + + html += tpl.main(config) + // Render main app + vm._renderTo(el, html, true) + // Add nav + dom.body.insertBefore(navEl, dom.body.children[0]) + + if (config.themeColor) { + dom.head += tpl.theme(config.themeColor) + // Polyfll + cssVars(config.themeColor) + } } diff --git a/src/core/render/progressbar.js b/src/core/render/progressbar.js index 1da5b22..8eff66b 100644 --- a/src/core/render/progressbar.js +++ b/src/core/render/progressbar.js @@ -1,3 +1,4 @@ +import { dom } from '../util/dom' import { isPrimitive } from '../util/core' let loadingEl @@ -8,10 +9,10 @@ let timeId */ function init () { if (loadingEl) return - const div = document.createElement('div') + const div = dom.create('div') div.classList.add('progress') - document.body.appendChild(div) + dom.appendTo(div, dom.body) loadingEl = div } /** diff --git a/src/core/render/tpl.js b/src/core/render/tpl.js index df58979..cdf870d 100644 --- a/src/core/render/tpl.js +++ b/src/core/render/tpl.js @@ -1,4 +1,4 @@ -import { isMobile } from '../util/core' +import { isMobile } from '../util/env' /** * Render github corner * @param {Object} data @@ -9,27 +9,38 @@ export function corner (data) { if (!/\/\//.test(data)) data = 'https://github.com/' + data data = data.replace(/^git\+/, '') - return ` - - - ` + return ( + '' + + '' + + '`') } /** * Render main content */ -export function main () { - const aside = `${toggle()}` +export function main (config) { + const aside = ( + '' + + '') - return (isMobile() ? `${aside}
                            ` : `
                            ${aside}`) + - `
                            -
                            -
                            -
                            ` + return (isMobile ? `${aside}
                            ` : `
                            ${aside}`) + + '
                            ' + + '
                            ' + + '
                            ' + + '
                            ' } /** @@ -37,20 +48,14 @@ export function main () { */ export function cover () { const SL = ', 100%, 85%' - const bgc = `linear-gradient(to left bottom, hsl(${Math.floor(Math.random() * 255) + SL}) 0%, hsl(${Math.floor(Math.random() * 255) + SL}) 100%)` + const bgc = 'linear-gradient(to left bottom, ' + + `hsl(${Math.floor(Math.random() * 255) + SL}) 0%,` + + `hsl(${Math.floor(Math.random() * 255) + SL}) 100%)` - return `
                            -
                            -
                            -
                            ` -} - -export function toggle () { - return `` + return `
                            ` + + '
                            ' + + '
                            ' + + '
                            ' } /** diff --git a/src/core/route/hash.js b/src/core/route/hash.js index 90d180c..1f544d4 100644 --- a/src/core/route/hash.js +++ b/src/core/route/hash.js @@ -1,5 +1,4 @@ -import { cleanPath, getLocation } from './util' - +// import { cleanPath, getLocation } from './util' export function ensureSlash () { const path = getHash() if (path.charAt(0) === '/') return diff --git a/src/core/util/dom.js b/src/core/util/dom.js new file mode 100644 index 0000000..2232219 --- /dev/null +++ b/src/core/util/dom.js @@ -0,0 +1,41 @@ +import { isFn } from '../util/core' + +const cacheNode = {} + +/** + * Get Node + * @param {String|Element} el + * @param {Boolean} noCache + * @return {Element} + */ +export function getNode (el, noCache = false) { + if (typeof el === 'string') { + el = noCache ? dom.find(el) : (cacheNode[el] || dom.find(el)) + } + + return el +} + +export const dom = { + body: document.body, + head: document.head, + find: node => document.querySelector(node), + findAll: node => document.querySelectorAll(node), + create: (node, tpl) => { + node = document.createElement(node) + if (tpl) node.innerHTML = tpl + }, + appendTo: (target, el) => target.appendChild(el) +} + +export function on (el, type, handler) { + isFn(type) + ? window.addEventListener(el, type) + : el.addEventListener(type, handler) +} + +export const off = function on (el, type, handler) { + isFn(type) + ? window.removeEventListener(el, type) + : el.removeEventListener(type, handler) +} diff --git a/src/core/util/index.js b/src/core/util/index.js index bfcc8b2..38687ba 100644 --- a/src/core/util/index.js +++ b/src/core/util/index.js @@ -1,2 +1,3 @@ export * from './core' export * from './env' +export * from './dom' diff --git a/src/core/util/polyfill/css-vars.js b/src/core/util/polyfill/css-vars.js index f0200e6..686ad72 100644 --- a/src/core/util/polyfill/css-vars.js +++ b/src/core/util/polyfill/css-vars.js @@ -1,29 +1,32 @@ -import { get } from '../fetch/ajax' +import { dom } from '../dom' +import { get } from '../../fetch/ajax' -function replaceVar (block) { - block.innerHTML = block.innerHTML.replace(/var\(\s*--theme-color.*?\)/g, $docsify.themeColor) +function replaceVar (block, themeColor) { + block.innerHTML = block.innerHTML + .replace(/var\(\s*--theme-color.*?\)/g, themeColor) } -export function cssVars () { - // variable support - if (window.CSS && window.CSS.supports && window.CSS.supports('(--foo: red)')) return +export default function (themeColor) { + // Variable support + if (window.CSS + && window.CSS.supports + && window.CSS.supports('(--foo: red)')) return - const styleBlocks = document.querySelectorAll('style:not(.inserted),link') + const styleBlocks = dom.findAll('style:not(.inserted),link') ;[].forEach.call(styleBlocks, block => { if (block.nodeName === 'STYLE') { - replaceVar(block) + replaceVar(block, themeColor) } else if (block.nodeName === 'LINK') { const href = block.getAttribute('href') if (!/\.css$/.test(href)) return get(href).then(res => { - const style = document.createElement('style') + const style = dom.create('style', res) - style.innerHTML = res - document.head.appendChild(style) - replaceVar(style) + dom.head.appendChild(style) + replaceVar(style, themeColor) }) } }) diff --git a/src/themes/basic/_layout.css b/src/themes/basic/_layout.css index e194aff..d413c10 100644 --- a/src/themes/basic/_layout.css +++ b/src/themes/basic/_layout.css @@ -64,7 +64,7 @@ kbd { } /* navbar */ -nav { +nav.app-nav { position: absolute; right: 0; left: 0; From 30da0d5d466a0d6617fc3312698d9b58899dfa16 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 11:41:33 +0800 Subject: [PATCH 017/746] refactor(core): add router --- src/core/config.js | 4 +- src/core/event/index.js | 4 +- src/core/event/sidebar.js | 4 +- src/core/fetch/ajax.js | 31 +++++++++++---- src/core/fetch/index.js | 36 +++++++++++++++-- src/core/global-api.js | 13 +++++++ src/core/index.js | 8 +--- src/core/render/compiler.js | 50 ++++++++++++++++++++++++ src/core/render/index.js | 20 ++++++++-- src/core/render/progressbar.js | 21 +++++----- src/core/route/hash.js | 62 +++++++++++++++++++++++++----- src/core/route/index.js | 43 ++++++++++++++++----- src/core/route/util.js | 46 +++++++++++++++++++--- src/core/util/core.js | 9 ++--- src/core/util/dom.js | 34 ++++++++++------ src/core/util/index.js | 1 - src/core/util/polyfill/css-vars.js | 18 ++++----- 17 files changed, 316 insertions(+), 88 deletions(-) create mode 100644 src/core/global-api.js create mode 100644 src/core/render/compiler.js diff --git a/src/core/config.js b/src/core/config.js index d11c3d1..a1bf9bb 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -1,4 +1,4 @@ -import { merge, camelize, isPrimitive } from './util/core' +import { merge, hyphenate, isPrimitive } from './util/core' const config = merge({ el: '#app', @@ -23,7 +23,7 @@ const script = document.currentScript || if (script) { for (const prop in config) { - const val = script.getAttribute('data-' + camelize(prop)) + const val = script.getAttribute('data-' + hyphenate(prop)) if (isPrimitive(val)) { config[prop] = val === '' ? true : val diff --git a/src/core/event/index.js b/src/core/event/index.js index a31188b..4c44100 100644 --- a/src/core/event/index.js +++ b/src/core/event/index.js @@ -1,5 +1,5 @@ import { isMobile } from '../util/env' -import { dom, on } from '../util/dom' +import { body, on } from '../util/dom' import * as sidebar from './sidebar' export function eventMixin (Docsify) { @@ -14,6 +14,6 @@ export function initEvent (vm) { if (vm.config.coverpage) { !isMobile && on('scroll', sidebar.sticky) } else { - dom.body.classList.add('sticky') + body.classList.add('sticky') } } diff --git a/src/core/event/sidebar.js b/src/core/event/sidebar.js index aeaeeed..a02ef7b 100644 --- a/src/core/event/sidebar.js +++ b/src/core/event/sidebar.js @@ -1,10 +1,10 @@ import { isMobile } from '../util/env' -import { getNode, on, dom } from '../util/dom' +import { getNode, on, body } from '../util/dom' /** * Toggle button */ export function btn (el) { - const toggle = () => dom.body.classList.toggle('close') + const toggle = () => body.classList.toggle('close') el = getNode(el) on(el, 'click', toggle) diff --git a/src/core/fetch/ajax.js b/src/core/fetch/ajax.js index ba79b76..09d4390 100644 --- a/src/core/fetch/ajax.js +++ b/src/core/fetch/ajax.js @@ -1,23 +1,33 @@ import progressbar from '../render/progressbar' import { noop } from '../util/core' +const cache = {} +const RUN_VERSION = Date.now() + /** * Simple ajax get - * @param {String} url - * @param {Boolean} [loading=false] has loading bar + * @param {string} url + * @param {boolean} [hasBar=false] has progress bar * @return { then(resolve, reject), abort } */ -export function get (url, hasLoading = false) { +export function get (url, hasBar = false) { const xhr = new XMLHttpRequest() + const on = function () { + xhr.addEventListener.apply(xhr, arguments) + } + + url += (/\?(\w+)=/g.test(url) ? '&' : '?') + `v=${RUN_VERSION}` + + if (cache[url]) { + return { then: cb => cb(cache[url]), abort: noop } + } xhr.open('GET', url) xhr.send() return { then: function (success, error = noop) { - const on = xhr.addEventListener - - if (hasLoading) { + if (hasBar) { const id = setInterval(_ => progressbar({}), 500) on('progress', progressbar) @@ -29,9 +39,14 @@ export function get (url, hasLoading = false) { on('error', error) on('load', ({ target }) => { - target.status >= 400 ? error(target) : success(target.response) + if (target.status >= 400) { + error(target) + } else { + cache[url] = target.response + success(target.response) + } }) }, - abort: () => xhr.readyState !== 4 && xhr.abort() + abort: _ => xhr.readyState !== 4 && xhr.abort() } } diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index 61acc81..2fb7aa0 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -1,13 +1,43 @@ +import { get } from './ajax' import { callHook } from '../init/lifecycle' +import { getCurrentRoot } from '../route/util' export function fetchMixin (Docsify) { - Docsify.prototype.$fetch = function (path) { - // 加载侧边栏、导航、内容 + let last + + Docsify.prototype._fetch = function (cb) { + const { path } = this.route + const { loadNavbar, loadSidebar } = this.config + const currentRoot = getCurrentRoot(path) + + // Abort last request + last && last.abort && last.abort() + + last = get(this.$getFile(path), true) + last.then(text => { + this._renderMain(text) + if (!loadSidebar) return cb() + + const fn = result => { this._renderSidebar(result); cb() } + + // Load sidebar + get(this.$getFile(currentRoot + loadSidebar)) + .then(fn, _ => get(loadSidebar).then(fn)) + }, + _ => this._renderMain(null)) + + // Load nav + loadNavbar && + get(this.$getFile(currentRoot + loadNavbar)) + .then( + this._renderNav, + _ => get(loadNavbar).then(this._renderNav) + ) } } export function initFetch (vm) { - vm.$fetch(result => { + vm._fetch(result => { vm.$resetEvents() callHook(vm, 'doneEach') }) diff --git a/src/core/global-api.js b/src/core/global-api.js new file mode 100644 index 0000000..83a3288 --- /dev/null +++ b/src/core/global-api.js @@ -0,0 +1,13 @@ +import * as util from './util' +import * as dom from './util/dom' +import * as render from './render/compiler' +import * as route from './route/util' +import { get } from './fetch/ajax' +import marked from 'marked' +import prism from 'prismjs' + +export default function () { + window.Docsify = { util, dom, render, route, get } + window.marked = marked + window.Prism = prism +} diff --git a/src/core/index.js b/src/core/index.js index 96cab23..e2c94a4 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -3,9 +3,7 @@ import { routeMixin } from './route' import { renderMixin } from './render' import { fetchMixin } from './fetch' import { eventMixin } from './event' -import * as util from './util' -import { get as load } from './fetch/ajax' -import * as routeUtil from './route/util' +import initGlobalAPI from './global-api' function Docsify () { this._init() @@ -20,9 +18,7 @@ eventMixin(Docsify) /** * Global API */ -window.Docsify = { - util: util.merge({ load }, util, routeUtil) -} +initGlobalAPI() /** * Run Docsify diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js new file mode 100644 index 0000000..daed38c --- /dev/null +++ b/src/core/render/compiler.js @@ -0,0 +1,50 @@ +import marked from 'marked' +import Prism from 'prismjs' + +export const renderer = new marked.Renderer() + +export function markdown () { + +} + +const toc = [] + +/** + * render anchor tag + * @link https://github.com/chjj/marked#overriding-renderer-methods + */ +renderer.heading = function (text, level) { + const slug = slugify(text) + let route = '' + + route = `#/${getRoute()}` + toc.push({ level, slug: `${route}#${encodeURIComponent(slug)}`, title: text }) + + return `${text}` +} +// highlight code +renderer.code = function (code, lang = '') { + const hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup) + + return `
                            ${hl}
                            ` +} +renderer.link = function (href, title, text) { + if (!/:|(\/{2})/.test(href)) { + href = `#/${href}`.replace(/\/+/g, '/') + } + return `${text}` +} +renderer.paragraph = function (text) { + if (/^!>/.test(text)) { + return tpl.helper('tip', text) + } else if (/^\?>/.test(text)) { + return tpl.helper('warn', text) + } + return `

                            ${text}

                            ` +} +renderer.image = function (href, title, text) { + const url = /:|(\/{2})/.test(href) ? href : ($docsify.basePath + href).replace(/\/+/g, '/') + const titleHTML = title ? ` title="${title}"` : '' + + return `${text}` +} diff --git a/src/core/render/index.js b/src/core/render/index.js index 12f50c5..2f9610f 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -1,12 +1,26 @@ -import { getNode, dom } from '../util/dom' +import * as dom from '../util/dom' import cssVars from '../util/polyfill/css-vars' import * as tpl from './tpl' +function renderMain () { + +} + +function renderNav () { +} + +function renderSidebar () { +} + export function renderMixin (Docsify) { Docsify.prototype._renderTo = function (el, content, replace) { - const node = getNode(el) + const node = dom.getNode(el) if (node) node[replace ? 'outerHTML' : 'innerHTML'] = content } + + Docsify.prototype._renderSidebar = renderSidebar + Docsify.prototype._renderNav = renderNav + Docsify.prototype._renderMain = renderMain } export function initRender (vm) { @@ -40,7 +54,7 @@ export function initRender (vm) { dom.body.insertBefore(navEl, dom.body.children[0]) if (config.themeColor) { - dom.head += tpl.theme(config.themeColor) + dom.$.head += tpl.theme(config.themeColor) // Polyfll cssVars(config.themeColor) } diff --git a/src/core/render/progressbar.js b/src/core/render/progressbar.js index 8eff66b..c8347e6 100644 --- a/src/core/render/progressbar.js +++ b/src/core/render/progressbar.js @@ -1,19 +1,18 @@ -import { dom } from '../util/dom' +import * as dom from '../util/dom' import { isPrimitive } from '../util/core' -let loadingEl +let barEl let timeId /** * Init progress component */ function init () { - if (loadingEl) return const div = dom.create('div') div.classList.add('progress') - dom.appendTo(div, dom.body) - loadingEl = div + dom.appendTo(dom.body, div) + barEl = div } /** * Render progress bar @@ -21,26 +20,26 @@ function init () { export default function ({ loaded, total, step }) { let num - loadingEl = init() + !barEl && init() if (!isPrimitive(step)) { step = Math.floor(Math.random() * 5 + 1) } if (step) { - num = parseInt(loadingEl.style.width, 10) + step + num = parseInt(barEl.style.width, 10) + step num = num > 80 ? 80 : num } else { num = Math.floor(loaded / total * 100) } - loadingEl.style.opacity = 1 - loadingEl.style.width = num >= 95 ? '100%' : num + '%' + barEl.style.opacity = 1 + barEl.style.width = num >= 95 ? '100%' : num + '%' if (num >= 95) { clearTimeout(timeId) timeId = setTimeout(_ => { - loadingEl.style.opacity = 0 - loadingEl.style.width = '0%' + barEl.style.opacity = 0 + barEl.style.width = '0%' }, 200) } } diff --git a/src/core/route/hash.js b/src/core/route/hash.js index 1f544d4..fd0607e 100644 --- a/src/core/route/hash.js +++ b/src/core/route/hash.js @@ -1,7 +1,27 @@ -// import { cleanPath, getLocation } from './util' -export function ensureSlash () { - const path = getHash() - if (path.charAt(0) === '/') return +import { parseQuery } from './util' + +function replaceHash (path) { + const i = window.location.href.indexOf('#') + window.location.replace( + window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path + ) +} + +/** + * Normalize the current url + * + * @example + * domain.com/docs/ => domain.com/docs/#/ + * domain.com/docs/#/#slug => domain.com/docs/#/?id=slug + */ +export function normalize () { + let path = getHash() + + path = path + .replace('#', '?id=') + .replace(/\?(\w+)=/g, (_, slug) => slug === 'id' ? '?id=' : `&${slug}=`) + + if (path.charAt(0) === '/') return replaceHash(path) replaceHash('/' + path) } @@ -13,11 +33,33 @@ export function getHash () { return index === -1 ? '' : href.slice(index + 1) } -function replaceHash (path) { - const i = window.location.href.indexOf('#') - window.location.replace( - window.location.href.slice(0, i >= 0 ? i : 0) + '#' + path - ) +/** + * Parse the current url + * @return {object} { path, query } + */ +export function parse () { + let path = window.location.href + let query = '' + + const queryIndex = path.indexOf('?') + if (queryIndex >= 0) { + query = path.slice(queryIndex + 1) + path = path.slice(0, queryIndex) + } + + const hashIndex = path.indexOf('#') + if (hashIndex) { + path = path.slice(hashIndex + 1) + } + + return { path, query: parseQuery(query) } } -// TODO 把第二个 hash 转成 ?id= +/** + * to URL + * @param {String} path + * @param {String} qs query string + */ +export function toURL (path, qs) { + +} diff --git a/src/core/route/index.js b/src/core/route/index.js index 011db74..0d4a3c6 100644 --- a/src/core/route/index.js +++ b/src/core/route/index.js @@ -1,17 +1,42 @@ -import { ensureSlash } from './hash' +import { normalize, parse } from './hash' +import { getBasePath, cleanPath } from './util' +import { on } from '../util/dom' + +function getAlias (path, alias) { + if (alias[path]) return getAlias(alias[path], alias) + return path +} + +function getFileName (path) { + return /\.(md|html)$/g.test(path) + ? path + : /\/$/g.test(path) + ? `${path}README.md` + : `${path}.md` +} export function routeMixin (Docsify) { - Docsify.prototype.$route = { - query: location.query || {}, - path: location.path || '/', - base: '' + Docsify.prototype.route = {} + Docsify.prototype.$getFile = function (path) { + const { config } = this + const base = getBasePath(config.basePath) + + path = getAlias(path, config.alias) + path = getFileName(path) + path = path === '/README.md' ? ('/' + config.homepage || path) : path + path = cleanPath(base + path) + + return path } } export function initRoute (vm) { - ensureSlash() - window.addEventListener('hashchange', () => { - ensureSlash() - vm.$fetch() + normalize() + vm.route = parse() + + on('hashchange', _ => { + normalize() + vm.route = parse() + vm._fetch() }) } diff --git a/src/core/route/util.js b/src/core/route/util.js index 4cbf898..300253a 100644 --- a/src/core/route/util.js +++ b/src/core/route/util.js @@ -1,11 +1,45 @@ +import { cached } from '../util/core' + +const decode = decodeURIComponent + +export const parseQuery = cached(query => { + const res = {} + + query = query.trim().replace(/^(\?|#|&)/, '') + + if (!query) { + return res + } + + query.split('&').forEach(function (param) { + const parts = param.replace(/\+/g, ' ').split('=') + const key = decode(parts.shift()) + const val = parts.length > 0 + ? decode(parts.join('=')) + : null + + if (res[key] === undefined) { + res[key] = val + } else if (Array.isArray(res[key])) { + res[key].push(val) + } else { + res[key] = [res[key], val] + } + }) + + return res +}) + export function cleanPath (path) { return path.replace(/\/+/g, '/') } -export function getLocation (base) { - let path = window.location.pathname - if (base && path.indexOf(base) === 0) { - path = path.slice(base.length) - } - return (path || '/') + window.location.search + window.location.hash +export function getBasePath (base) { + return /^(\/|https?:)/g.test(base) + ? base + : cleanPath(window.location.pathname + '/' + base) +} + +export function getCurrentRoot (path) { + return /\/$/g.test(path) ? path : path.match(/(\S*\/)[^\/]+$/)[1] } diff --git a/src/core/util/core.js b/src/core/util/core.js index 9688983..5a153b8 100644 --- a/src/core/util/core.js +++ b/src/core/util/core.js @@ -1,7 +1,7 @@ /** * Create a cached version of a pure function. */ -function cached (fn) { +export function cached (fn) { const cache = Object.create(null) return function cachedFn (str) { const hit = cache[str] @@ -10,11 +10,10 @@ function cached (fn) { } /** - * Camelize a hyphen-delimited string. + * Hyphenate a camelCase string. */ -const camelizeRE = /-(\w)/g -export const camelize = cached((str) => { - return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') +export const hyphenate = cached(str => { + return str.replace(/([A-Z])/g, m => '-' + m.toLowerCase()) }) /** diff --git a/src/core/util/dom.js b/src/core/util/dom.js index 2232219..a2bd22c 100644 --- a/src/core/util/dom.js +++ b/src/core/util/dom.js @@ -10,22 +10,34 @@ const cacheNode = {} */ export function getNode (el, noCache = false) { if (typeof el === 'string') { - el = noCache ? dom.find(el) : (cacheNode[el] || dom.find(el)) + el = noCache ? find(el) : (cacheNode[el] || find(el)) } return el } -export const dom = { - body: document.body, - head: document.head, - find: node => document.querySelector(node), - findAll: node => document.querySelectorAll(node), - create: (node, tpl) => { - node = document.createElement(node) - if (tpl) node.innerHTML = tpl - }, - appendTo: (target, el) => target.appendChild(el) +export const $ = document + +export const body = $.body + +export const head = $.head + +export function find (node) { + return $.querySelector(node) +} + +export function findAll (node) { + return [].clice.call($.querySelectorAll(node)) +} + +export function create (node, tpl) { + node = $.createElement(node) + if (tpl) node.innerHTML = tpl + return node +} + +export function appendTo (target, el) { + return target.appendChild(el) } export function on (el, type, handler) { diff --git a/src/core/util/index.js b/src/core/util/index.js index 38687ba..bfcc8b2 100644 --- a/src/core/util/index.js +++ b/src/core/util/index.js @@ -1,3 +1,2 @@ export * from './core' export * from './env' -export * from './dom' diff --git a/src/core/util/polyfill/css-vars.js b/src/core/util/polyfill/css-vars.js index 686ad72..bb8e498 100644 --- a/src/core/util/polyfill/css-vars.js +++ b/src/core/util/polyfill/css-vars.js @@ -1,22 +1,22 @@ -import { dom } from '../dom' +import * as dom from '../dom' import { get } from '../../fetch/ajax' -function replaceVar (block, themeColor) { +function replaceVar (block, color) { block.innerHTML = block.innerHTML - .replace(/var\(\s*--theme-color.*?\)/g, themeColor) + .replace(/var\(\s*--theme-color.*?\)/g, color) } -export default function (themeColor) { +export default function (color) { // Variable support - if (window.CSS - && window.CSS.supports - && window.CSS.supports('(--foo: red)')) return + if (window.CSS && + window.CSS.supports && + window.CSS.supports('(--v:red)')) return const styleBlocks = dom.findAll('style:not(.inserted),link') ;[].forEach.call(styleBlocks, block => { if (block.nodeName === 'STYLE') { - replaceVar(block, themeColor) + replaceVar(block, color) } else if (block.nodeName === 'LINK') { const href = block.getAttribute('href') @@ -26,7 +26,7 @@ export default function (themeColor) { const style = dom.create('style', res) dom.head.appendChild(style) - replaceVar(style, themeColor) + replaceVar(style, color) }) } }) From fe88c154b0d48e1d5eb79f2c7dfcd1d60beb83cf Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 14:09:17 +0800 Subject: [PATCH 018/746] refactor(core): and markdown compiler --- .eslintrc | 3 - src/core/fetch/index.js | 11 +-- src/core/index.js | 2 +- src/core/render/compiler.js | 68 ++++++++++++--- src/core/render/emojify.js | 6 ++ src/core/render/gen-tree.js | 27 ++++++ src/core/render/index.js | 41 ++++++--- src/core/render/slugify.js | 27 ++++++ src/core/route/hash.js | 20 +++-- src/core/route/index.js | 10 ++- src/core/route/util.js | 45 +++++----- src/util.js | 166 ------------------------------------ 12 files changed, 194 insertions(+), 232 deletions(-) create mode 100644 src/core/render/emojify.js create mode 100644 src/core/render/gen-tree.js create mode 100644 src/core/render/slugify.js delete mode 100644 src/util.js diff --git a/.eslintrc b/.eslintrc index 527ed9b..86d102d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,8 +2,5 @@ "extends": ["vue"], "env": { "browser": true - }, - "globals": { - "$docsify": true } } diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index 2fb7aa0..3602baf 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -1,14 +1,15 @@ import { get } from './ajax' import { callHook } from '../init/lifecycle' -import { getCurrentRoot } from '../route/util' +import { getRoot } from '../route/util' +import { noop } from '../util/core' export function fetchMixin (Docsify) { let last - Docsify.prototype._fetch = function (cb) { + Docsify.prototype._fetch = function (cb = noop) { const { path } = this.route const { loadNavbar, loadSidebar } = this.config - const currentRoot = getCurrentRoot(path) + const root = getRoot(path) // Abort last request last && last.abort && last.abort() @@ -21,14 +22,14 @@ export function fetchMixin (Docsify) { const fn = result => { this._renderSidebar(result); cb() } // Load sidebar - get(this.$getFile(currentRoot + loadSidebar)) + get(this.$getFile(root + loadSidebar)) .then(fn, _ => get(loadSidebar).then(fn)) }, _ => this._renderMain(null)) // Load nav loadNavbar && - get(this.$getFile(currentRoot + loadNavbar)) + get(this.$getFile(root + loadNavbar)) .then( this._renderNav, _ => get(loadNavbar).then(this._renderNav) diff --git a/src/core/index.js b/src/core/index.js index e2c94a4..3ac8b56 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -23,4 +23,4 @@ initGlobalAPI() /** * Run Docsify */ -setTimeout(() => new Docsify(), 0) +new Docsify() diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index daed38c..2d20240 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -1,26 +1,56 @@ import marked from 'marked' import Prism from 'prismjs' +import { helper as helperTpl } from './tpl' +import { slugify, clearSlugCache } from './slugify' +import { emojify } from './emojify' +import { toURL } from '../route/hash' +import { isFn, merge, cached } from '../util/core' -export const renderer = new marked.Renderer() - -export function markdown () { - -} +let markdownCompiler = marked +let contentBase = '' +let renderer = new marked.Renderer() const toc = [] +/** + * Compile markdown content + */ +export const markdown = cached(text => { + let html = '' + + if (!text) return text + + html = markdownCompiler(text) + html = emojify(html) + clearSlugCache() + + return html +}) + +markdown.renderer = renderer + +markdown.init = function (config = {}, context = window.location.pathname) { + contentBase = context + + if (isFn(config)) { + markdownCompiler = config(marked, renderer) + } else { + renderer = merge(renderer, config.renderer) + marked.setOptions(merge(config, { renderer })) + } +} + /** * render anchor tag * @link https://github.com/chjj/marked#overriding-renderer-methods */ renderer.heading = function (text, level) { const slug = slugify(text) - let route = '' + const url = toURL(contentBase, { id: slug }) - route = `#/${getRoute()}` - toc.push({ level, slug: `${route}#${encodeURIComponent(slug)}`, title: text }) + toc.push({ level, slug: url, title: text }) - return `${text}` + return `${text}` } // highlight code renderer.code = function (code, lang = '') { @@ -30,21 +60,31 @@ renderer.code = function (code, lang = '') { } renderer.link = function (href, title, text) { if (!/:|(\/{2})/.test(href)) { + // TODO href = `#/${href}`.replace(/\/+/g, '/') } return `${text}` } renderer.paragraph = function (text) { if (/^!>/.test(text)) { - return tpl.helper('tip', text) + return helperTpl('tip', text) } else if (/^\?>/.test(text)) { - return tpl.helper('warn', text) + return helperTpl('warn', text) } return `

                            ${text}

                            ` } renderer.image = function (href, title, text) { - const url = /:|(\/{2})/.test(href) ? href : ($docsify.basePath + href).replace(/\/+/g, '/') - const titleHTML = title ? ` title="${title}"` : '' + // TODO + // get base path + // const url = /:|(\/{2})/.test(href) ? href : ($docsify.basePath + href).replace(/\/+/g, '/') + // const titleHTML = title ? ` title="${title}"` : '' + + // return `${text}` +} + +/** + * Compile sidebar + */ +export function sidebar (text) { - return `${text}` } diff --git a/src/core/render/emojify.js b/src/core/render/emojify.js new file mode 100644 index 0000000..bc414a3 --- /dev/null +++ b/src/core/render/emojify.js @@ -0,0 +1,6 @@ +export function emojify (text) { + return text + .replace(/<(pre|template)[^>]*?>([\s\S]+)<\/(pre|template)>/g, m => m.replace(/:/g, '__colon__')) + .replace(/:(\w+?):/ig, '$1') + .replace(/__colon__/g, ':') +} diff --git a/src/core/render/gen-tree.js b/src/core/render/gen-tree.js new file mode 100644 index 0000000..84ff05e --- /dev/null +++ b/src/core/render/gen-tree.js @@ -0,0 +1,27 @@ +/** + * gen toc tree + * @link https://github.com/killercup/grock/blob/5280ae63e16c5739e9233d9009bc235ed7d79a50/styles/solarized/assets/js/behavior.coffee#L54-L81 + * @param {Array} toc + * @param {Number} maxLevel + * @return {Array} + */ +export function genTree (toc, maxLevel) { + const headlines = [] + const last = {} + + toc.forEach(headline => { + const level = headline.level || 1 + const len = level - 1 + + if (level > maxLevel) return + if (last[len]) { + last[len].children = last[len].children || [] + last[len].children.push(headline) + } else { + headlines.push(headline) + } + last[level] = headline + }) + + return headlines +} diff --git a/src/core/render/index.js b/src/core/render/index.js index 2f9610f..ff25518 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -1,30 +1,47 @@ import * as dom from '../util/dom' import cssVars from '../util/polyfill/css-vars' import * as tpl from './tpl' +import { markdown, sidebar } from './compiler' +import { callHook } from '../init/lifecycle' -function renderMain () { - -} - -function renderNav () { -} - -function renderSidebar () { +function renderMain (html) { + if (!html) { + // TODO: Custom 404 page + } + this._renderTo('.markdown-section', html) } export function renderMixin (Docsify) { - Docsify.prototype._renderTo = function (el, content, replace) { + const proto = Docsify.prototype + + proto._renderTo = function (el, content, replace) { const node = dom.getNode(el) if (node) node[replace ? 'outerHTML' : 'innerHTML'] = content } - Docsify.prototype._renderSidebar = renderSidebar - Docsify.prototype._renderNav = renderNav - Docsify.prototype._renderMain = renderMain + proto._renderSidebar = function (text) { + this._renderTo('.sidebar-nav', sidebar(text)) + // bind event + } + + proto._renderNav = function (text) { + this._renderTo('nav', markdown(text)) + } + + proto._renderMain = function (text) { + callHook(this, 'beforeEach', text, result => { + const html = markdown(result) + callHook(this, 'afterEach', html, text => renderMain.call(this, text)) + }) + } } export function initRender (vm) { const config = vm.config + + // Init markdown compiler + markdown.init(vm.config.markdown) + const id = config.el || '#app' const navEl = dom.find('nav') || dom.create('nav') diff --git a/src/core/render/slugify.js b/src/core/render/slugify.js new file mode 100644 index 0000000..a6e9d39 --- /dev/null +++ b/src/core/render/slugify.js @@ -0,0 +1,27 @@ +let cache = {} +const re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g + +export function slugify (str) { + if (typeof str !== 'string') return '' + + let slug = str.toLowerCase().trim() + .replace(/<[^>\d]+>/g, '') + .replace(re, '') + .replace(/\s/g, '-') + .replace(/-+/g, '-') + .replace(/^(\d)/, '_$1') + let count = cache[slug] + + count = cache.hasOwnProperty(slug) ? (count + 1) : 0 + cache[slug] = count + + if (count) { + slug = slug + '-' + count + } + + return slug +} + +export function clearSlugCache () { + cache = {} +} diff --git a/src/core/route/hash.js b/src/core/route/hash.js index fd0607e..b114f3d 100644 --- a/src/core/route/hash.js +++ b/src/core/route/hash.js @@ -1,4 +1,5 @@ -import { parseQuery } from './util' +import { merge } from '../util/core' +import { parseQuery, stringifyQuery, cleanPath } from './util' function replaceHash (path) { const i = window.location.href.indexOf('#') @@ -34,11 +35,11 @@ export function getHash () { } /** - * Parse the current url + * Parse the url + * @param {string} [path=window.location.herf] * @return {object} { path, query } */ -export function parse () { - let path = window.location.href +export function parse (path = window.location.href) { let query = '' const queryIndex = path.indexOf('?') @@ -57,9 +58,14 @@ export function parse () { /** * to URL - * @param {String} path - * @param {String} qs query string + * @param {string} path + * @param {object} qs query params */ -export function toURL (path, qs) { +export function toURL (path, params) { + const route = parse(path) + route.query = merge({}, route.query, params) + path = route.path + stringifyQuery(route.query) + + return '#' + path } diff --git a/src/core/route/index.js b/src/core/route/index.js index 0d4a3c6..3fa1020 100644 --- a/src/core/route/index.js +++ b/src/core/route/index.js @@ -30,13 +30,19 @@ export function routeMixin (Docsify) { } } +let lastRoute = {} + export function initRoute (vm) { normalize() - vm.route = parse() + lastRoute = vm.route = parse() on('hashchange', _ => { normalize() - vm.route = parse() + lastRoute = vm.route = parse() + if (lastRoute.path === vm.route.path) { + // TODO: goto xxx + return + } vm._fetch() }) } diff --git a/src/core/route/util.js b/src/core/route/util.js index 300253a..635273b 100644 --- a/src/core/route/util.js +++ b/src/core/route/util.js @@ -1,6 +1,7 @@ import { cached } from '../util/core' const decode = decodeURIComponent +const encode = encodeURIComponent export const parseQuery = cached(query => { const res = {} @@ -11,35 +12,35 @@ export const parseQuery = cached(query => { return res } + // Simple parse query.split('&').forEach(function (param) { const parts = param.replace(/\+/g, ' ').split('=') - const key = decode(parts.shift()) - const val = parts.length > 0 - ? decode(parts.join('=')) - : null - if (res[key] === undefined) { - res[key] = val - } else if (Array.isArray(res[key])) { - res[key].push(val) - } else { - res[key] = [res[key], val] - } + res[parts[0]] = decode(parts[1]) }) - return res }) +export function stringifyQuery (obj) { + const qs = [] + + for (const key in obj) { + qs.push(`${encode(key)}=${encode(obj[key])}`) + } + + return qs.length ? `?${qs.join('&')}` : '' +} + +export const getBasePath = cached(base => { + return /^(\/|https?:)/g.test(base) + ? base + : cleanPath(window.location.pathname + '/' + base) +}) + +export const getRoot = cached(path => { + return /\/$/g.test(path) ? path : path.match(/(\S*\/)[^\/]+$/)[1] +}) + export function cleanPath (path) { return path.replace(/\/+/g, '/') } - -export function getBasePath (base) { - return /^(\/|https?:)/g.test(base) - ? base - : cleanPath(window.location.pathname + '/' + base) -} - -export function getCurrentRoot (path) { - return /\/$/g.test(path) ? path : path.match(/(\S*\/)[^\/]+$/)[1] -} diff --git a/src/util.js b/src/util.js deleted file mode 100644 index 8f182df..0000000 --- a/src/util.js +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Simple ajax - * @param {String} url - * @param {String} [method=GET] - * @param {Function} [loading] handle loading - * @return {Promise} - */ -export function load (url, method = 'GET', loading) { - const xhr = new XMLHttpRequest() - - xhr.open(method, url) - xhr.send() - - return { - then: function (success, error = function () {}) { - if (loading) { - const id = setInterval(_ => - loading({ step: Math.floor(Math.random() * 5 + 1) }), - 500) - xhr.addEventListener('progress', loading) - xhr.addEventListener('loadend', evt => { - loading(evt) - clearInterval(id) - }) - } - xhr.addEventListener('error', error) - xhr.addEventListener('load', ({ target }) => { - target.status >= 400 ? error(target) : success(target.response) - }) - }, - abort: () => xhr.readyState !== 4 && xhr.abort() - } -} - -/** - * gen toc tree - * @link https://github.com/killercup/grock/blob/5280ae63e16c5739e9233d9009bc235ed7d79a50/styles/solarized/assets/js/behavior.coffee#L54-L81 - * @param {Array} toc - * @param {Number} maxLevel - * @return {Array} - */ -export function genTree (toc, maxLevel) { - const headlines = [] - const last = {} - - toc.forEach(headline => { - const level = headline.level || 1 - const len = level - 1 - - if (level > maxLevel) return - if (last[len]) { - last[len].children = last[len].children || [] - last[len].children.push(headline) - } else { - headlines.push(headline) - } - last[level] = headline - }) - - return headlines -} - -/** - * camel to kebab - * @link https://github.com/bokuweb/kebab2camel/blob/master/index.js - * @param {String} str - * @return {String} - */ -export function camel2kebab (str) { - return str.replace(/([A-Z])/g, m => '-' + m.toLowerCase()) -} - -/** - * is nil - * @param {Object} object - * @return {Boolean} - */ -export function isNil (o) { - return o === null || o === undefined -} - -let cacheRoute = null -let cacheHash = null - -/** - * hash route - */ -export function getRoute () { - const loc = window.location - if (cacheHash === loc.hash && !isNil(cacheRoute)) return cacheRoute - - let route = loc.hash.replace(/%23/g, '#').match(/^#\/([^#]+)/) - - if (route && route.length === 2) { - route = route[1] - } else { - route = /^#\//.test(loc.hash) ? '' : loc.pathname - } - cacheRoute = route - cacheHash = loc.hash - - return route -} - -export function isMobile () { - return document.body.clientWidth <= 600 -} - -export function slugify (string) { - const re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g - const maintainCase = false - const replacement = '-' - - slugify.occurrences = slugify.occurrences || {} - - if (typeof string !== 'string') return '' - if (!maintainCase) string = string.toLowerCase() - - let slug = string.trim() - .replace(/<[^>\d]+>/g, '') - .replace(re, '') - .replace(/\s/g, replacement) - .replace(/-+/g, replacement) - .replace(/^(\d)/, '_$1') - let occurrences = slugify.occurrences[slug] - - if (slugify.occurrences.hasOwnProperty(slug)) { - occurrences++ - } else { - occurrences = 0 - } - - slugify.occurrences[slug] = occurrences - - if (occurrences) { - slug = slug + '-' + occurrences - } - - return slug -} - -slugify.clear = function () { - slugify.occurrences = {} -} - -const hasOwnProperty = Object.prototype.hasOwnProperty -export const merge = Object.assign || function (to) { - for (let i = 1; i < arguments.length; i++) { - const from = Object(arguments[i]) - - for (const key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key] - } - } - } - - return to -} - -export function emojify (text) { - return text - .replace(/<(pre|template)[^>]*?>([\s\S]+)<\/(pre|template)>/g, match => match.replace(/:/g, '__colon__')) - .replace(/:(\w+?):/ig, '$1') - .replace(/__colon__/g, ':') -} From fbd51afdcbd761f64ad12fe8183b952c257f304e Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 16:18:07 +0800 Subject: [PATCH 019/746] refactor(core): and sidebar event --- src/core/event/scroll.js | 2 +- src/core/event/sidebar.js | 28 +++++++++++++++++++++++--- src/core/render/compiler.js | 40 +++++++++++++++++++++++++++++++------ src/core/render/index.js | 13 ++++++++++-- src/core/route/index.js | 3 ++- src/core/util/dom.js | 31 ++++++++++++++++++++++++---- 6 files changed, 100 insertions(+), 17 deletions(-) diff --git a/src/core/event/scroll.js b/src/core/event/scroll.js index b79589b..503c6b4 100644 --- a/src/core/event/scroll.js +++ b/src/core/event/scroll.js @@ -1,4 +1,4 @@ -export function activeSidebar () { +export function scrollActiveSidebar () { } diff --git a/src/core/event/sidebar.js b/src/core/event/sidebar.js index a02ef7b..498354f 100644 --- a/src/core/event/sidebar.js +++ b/src/core/event/sidebar.js @@ -1,5 +1,6 @@ import { isMobile } from '../util/env' -import { getNode, on, body } from '../util/dom' +import { getNode, on, body, findAll, toggleClass } from '../util/dom' +import { getHash } from '../route/hash' /** * Toggle button */ @@ -14,7 +15,7 @@ export function btn (el) { on(sidebar, 'click', () => { toggle() - setTimeout(() => activeLink(sidebar, true), 0) + setTimeout(() => getAndActive(true), 0) }) } } @@ -23,6 +24,27 @@ export function sticky () { } -export function activeLink () { +export function getAndActive (el, isParent) { + const dom = getNode(el) + const links = findAll(dom, 'a') + const hash = '#' + getHash() + let target + + links + .sort((a, b) => b.href.length - a.href.length) + .forEach(a => { + const href = a.getAttribute('href') + const node = isParent ? a.parentNode : a + + if (hash.indexOf(href) === 0 && !target) { + target = a + toggleClass(node, 'add', 'active') + } else { + toggleClass(node, 'remove', 'active') + } + }) + + // TODO FIXED + return target } diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 2d20240..129be25 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -1,6 +1,7 @@ import marked from 'marked' import Prism from 'prismjs' -import { helper as helperTpl } from './tpl' +import { helper as helperTpl, tree as treeTpl } from './tpl' +import { genTree } from './gen-tree' import { slugify, clearSlugCache } from './slugify' import { emojify } from './emojify' import { toURL } from '../route/hash' @@ -9,8 +10,7 @@ import { isFn, merge, cached } from '../util/core' let markdownCompiler = marked let contentBase = '' let renderer = new marked.Renderer() - -const toc = [] +let toc = [] /** * Compile markdown content @@ -29,8 +29,8 @@ export const markdown = cached(text => { markdown.renderer = renderer -markdown.init = function (config = {}, context = window.location.pathname) { - contentBase = context +markdown.init = function (config = {}, base = window.location.pathname) { + contentBase = base if (isFn(config)) { markdownCompiler = config(marked, renderer) @@ -85,6 +85,34 @@ renderer.image = function (href, title, text) { /** * Compile sidebar */ -export function sidebar (text) { +export function sidebar (text, level) { + let html = '' + if (text) { + html = markdown(text) + html = html.match(/]*>([\s\S]+)<\/ul>/g)[0] + } else { + const tree = genTree(toc, level) + html = treeTpl(tree, '
                              ') + } + + return html +} + +/** + * Compile sub sidebar + */ +export function subSidebar (el, level) { + if (el) { + toc[0] && toc[0].level === 1 && toc.shift() + const tree = genTree(toc, level) + el.parentNode.innerHTML += treeTpl(tree, '
                                ') + } + toc = [] +} + +/** + * Compile cover page + */ +export function cover (text) { } diff --git a/src/core/render/index.js b/src/core/render/index.js index ff25518..2f4d1b8 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -1,14 +1,19 @@ import * as dom from '../util/dom' +import { getAndActive } from '../event/sidebar' +import { scrollActiveSidebar } from '../event/scroll' import cssVars from '../util/polyfill/css-vars' import * as tpl from './tpl' -import { markdown, sidebar } from './compiler' +import { markdown, sidebar, subSidebar } from './compiler' import { callHook } from '../init/lifecycle' function renderMain (html) { if (!html) { // TODO: Custom 404 page } + this._renderTo('.markdown-section', html) + // Render sidebar with the TOC + !this.config.loadSidebar && this._renderSidebar() } export function renderMixin (Docsify) { @@ -20,8 +25,12 @@ export function renderMixin (Docsify) { } proto._renderSidebar = function (text) { - this._renderTo('.sidebar-nav', sidebar(text)) + const { maxLevel, subMaxLevel } = this.config + + this._renderTo('.sidebar-nav', sidebar(text, maxLevel)) + subSidebar(getAndActive('.sidebar-nav', true), subMaxLevel) // bind event + scrollActiveSidebar() } proto._renderNav = function (text) { diff --git a/src/core/route/index.js b/src/core/route/index.js index 3fa1020..dc8eca2 100644 --- a/src/core/route/index.js +++ b/src/core/route/index.js @@ -38,11 +38,12 @@ export function initRoute (vm) { on('hashchange', _ => { normalize() - lastRoute = vm.route = parse() + vm.route = parse() if (lastRoute.path === vm.route.path) { // TODO: goto xxx return } vm._fetch() + lastRoute = vm.route }) } diff --git a/src/core/util/dom.js b/src/core/util/dom.js index a2bd22c..06016a5 100644 --- a/src/core/util/dom.js +++ b/src/core/util/dom.js @@ -22,12 +22,24 @@ export const body = $.body export const head = $.head -export function find (node) { - return $.querySelector(node) +/** + * Find element + * @example + * find('nav') => document.querySelector('nav') + * find(nav, 'a') => nav.querySelector('a') + */ +export function find (el, node) { + return node ? el.querySelector(node) : $.querySelector(el) } -export function findAll (node) { - return [].clice.call($.querySelectorAll(node)) +/** + * Find all elements + * @example + * findAll('a') => [].slice.call(document.querySelectorAll('a')) + * findAll(nav, 'a') => [].slice.call(nav.querySelectorAll('a')) + */ +export function findAll (el, node) { + return [].slice.call(node ? el.querySelectorAll(node) : $.querySelectorAll(el)) } export function create (node, tpl) { @@ -51,3 +63,14 @@ export const off = function on (el, type, handler) { ? window.removeEventListener(el, type) : el.removeEventListener(type, handler) } + +/** + * Toggle class + * + * @example + * toggleClass(el, 'active') => el.classList.toggle('active') + * toggleClass(el, 'add', 'active') => el.classList.add('active') + */ +export function toggleClass (el, type, val) { + el.classList[val ? type : 'toggle'](val || type) +} From 27e7e749af6bb80b863dee3624c1a914d0bc05e2 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 17:02:16 +0800 Subject: [PATCH 020/746] refactor(core): and cover --- src/core/event/sidebar.js | 10 +++++++++- src/core/fetch/index.js | 22 ++++++++++++++++++++-- src/core/render/compiler.js | 8 +++++++- src/core/render/index.js | 32 +++++++++++++++++++++++++++++--- src/core/route/hash.js | 2 +- src/core/route/index.js | 3 +++ 6 files changed, 69 insertions(+), 8 deletions(-) diff --git a/src/core/event/sidebar.js b/src/core/event/sidebar.js index 498354f..aa4475b 100644 --- a/src/core/event/sidebar.js +++ b/src/core/event/sidebar.js @@ -1,6 +1,7 @@ import { isMobile } from '../util/env' import { getNode, on, body, findAll, toggleClass } from '../util/dom' import { getHash } from '../route/hash' + /** * Toggle button */ @@ -21,7 +22,15 @@ export function btn (el) { } export function sticky () { + const cover = getNode('section.cover') + if (!cover) return + const coverHeight = cover.getBoundingClientRect().height + if (window.pageYOffset >= coverHeight || cover.classList.contains('hidden')) { + toggleClass(body, 'add', 'sticky') + } else { + toggleClass(body, 'remove', 'sticky') + } } export function getAndActive (el, isParent) { @@ -45,6 +54,5 @@ export function getAndActive (el, isParent) { } }) - // TODO FIXED return target } diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index 3602baf..d5316ae 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -15,6 +15,8 @@ export function fetchMixin (Docsify) { last && last.abort && last.abort() last = get(this.$getFile(path), true) + + // Load main content last.then(text => { this._renderMain(text) if (!loadSidebar) return cb() @@ -23,6 +25,7 @@ export function fetchMixin (Docsify) { // Load sidebar get(this.$getFile(root + loadSidebar)) + // fallback root navbar when fail .then(fn, _ => get(loadSidebar).then(fn)) }, _ => this._renderMain(null)) @@ -31,13 +34,28 @@ export function fetchMixin (Docsify) { loadNavbar && get(this.$getFile(root + loadNavbar)) .then( - this._renderNav, - _ => get(loadNavbar).then(this._renderNav) + text => this._renderNav(text), + // fallback root navbar when fail + _ => get(loadNavbar).then(text => this._renderNav(text)) ) } + + Docsify.prototype._fetchCover = function () { + const { coverpage } = this.config + const root = getRoot(this.route.path) + + if (this.route.path !== '/' || !coverpage) { + this._renderCover() + return + } + + get(this.$getFile(root + coverpage)) + .then(text => this._renderCover(text)) + } } export function initFetch (vm) { + vm._fetchCover(vm) vm._fetch(result => { vm.$resetEvents() callHook(vm, 'doneEach') diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 129be25..06c046c 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -5,7 +5,7 @@ import { genTree } from './gen-tree' import { slugify, clearSlugCache } from './slugify' import { emojify } from './emojify' import { toURL } from '../route/hash' -import { isFn, merge, cached } from '../util/core' +import { isFn, merge, cached, noop } from '../util/core' let markdownCompiler = marked let contentBase = '' @@ -115,4 +115,10 @@ export function subSidebar (el, level) { * Compile cover page */ export function cover (text) { + const cacheToc = toc.slice() + const html = markdown(text) + + toc = cacheToc.slice() + + return html } diff --git a/src/core/render/index.js b/src/core/render/index.js index 2f4d1b8..53cc62d 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -1,9 +1,9 @@ import * as dom from '../util/dom' -import { getAndActive } from '../event/sidebar' +import { getAndActive, sticky } from '../event/sidebar' import { scrollActiveSidebar } from '../event/scroll' import cssVars from '../util/polyfill/css-vars' import * as tpl from './tpl' -import { markdown, sidebar, subSidebar } from './compiler' +import { markdown, sidebar, subSidebar, cover } from './compiler' import { callHook } from '../init/lifecycle' function renderMain (html) { @@ -34,7 +34,8 @@ export function renderMixin (Docsify) { } proto._renderNav = function (text) { - this._renderTo('nav', markdown(text)) + text && this._renderTo('nav', markdown(text)) + getAndActive('nav') } proto._renderMain = function (text) { @@ -43,6 +44,31 @@ export function renderMixin (Docsify) { callHook(this, 'afterEach', html, text => renderMain.call(this, text)) }) } + + proto._renderCover = function (text) { + const el = dom.getNode('.cover') + if (!text) { + dom.toggleClass(el, 'remove', 'show') + return + } + dom.toggleClass(el, 'add', 'show') + + let html = cover(text) + const m = html.trim().match('

                                ([^<]*?)

                                $') + + if (m) { + if (m[2] === 'color') { + el.style.background = m[1] + (m[3] || '') + } else { + dom.toggleClass(el, 'add', 'has-mask') + el.style.backgroundImage = `url(${m[1]})` + } + html = html.replace(m[0], '') + } + + this._renderTo('.cover-main', html) + sticky() + } } export function initRender (vm) { diff --git a/src/core/route/hash.js b/src/core/route/hash.js index b114f3d..7f0129d 100644 --- a/src/core/route/hash.js +++ b/src/core/route/hash.js @@ -1,5 +1,5 @@ import { merge } from '../util/core' -import { parseQuery, stringifyQuery, cleanPath } from './util' +import { parseQuery, stringifyQuery } from './util' function replaceHash (path) { const i = window.location.href.indexOf('#') diff --git a/src/core/route/index.js b/src/core/route/index.js index dc8eca2..ad29c57 100644 --- a/src/core/route/index.js +++ b/src/core/route/index.js @@ -39,10 +39,13 @@ export function initRoute (vm) { on('hashchange', _ => { normalize() vm.route = parse() + if (lastRoute.path === vm.route.path) { // TODO: goto xxx return } + + vm._fetchCover() vm._fetch() lastRoute = vm.route }) From 8cae16539df6b8ce8fcc333dab661329e30b3f38 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 17:20:05 +0800 Subject: [PATCH 021/746] refactor(core): add scroll event --- src/core/event/index.js | 5 -- src/core/event/scroll.js | 85 ++++++++++++++++++++- src/core/fetch/index.js | 5 +- src/core/index.js | 2 - src/event.js | 159 --------------------------------------- 5 files changed, 86 insertions(+), 170 deletions(-) delete mode 100644 src/event.js diff --git a/src/core/event/index.js b/src/core/event/index.js index 4c44100..1181c9b 100644 --- a/src/core/event/index.js +++ b/src/core/event/index.js @@ -2,11 +2,6 @@ import { isMobile } from '../util/env' import { body, on } from '../util/dom' import * as sidebar from './sidebar' -export function eventMixin (Docsify) { - Docsify.prototype.$resetEvents = function () { - } -} - export function initEvent (vm) { // Bind toggle button sidebar.btn('button.sidebar-toggle') diff --git a/src/core/event/scroll.js b/src/core/event/scroll.js index 503c6b4..89b9b82 100644 --- a/src/core/event/scroll.js +++ b/src/core/event/scroll.js @@ -1,10 +1,89 @@ +import { isMobile } from '../util/env' +import * as dom from '../util/dom' + export function scrollActiveSidebar () { + if (isMobile) return + let hoverOver = false + const anchors = dom.findAll('.anchor') + const sidebar = dom.find('.sidebar') + const wrap = dom.find(sidebar, '.sidebar-nav') + const height = sidebar.clientHeight + + const nav = {} + const lis = dom.findAll(sidebar, 'li') + let active = dom.find(sidebar, 'li.active') + + for (let i = 0, len = lis.length; i < len; i += 1) { + const li = lis[i] + const a = li.querySelector('a') + if (!a) continue + let href = a.getAttribute('href') + + if (href !== '/') { + const match = href.match('#([^#]+)$') + if (match && match.length) href = match[0].slice(1) + } + + nav[decodeURIComponent(href)] = li + } + + function highlight () { + const top = dom.body.scrollTop + let last + + for (let i = 0, len = anchors.length; i < len; i += 1) { + const node = anchors[i] + + if (node.offsetTop > top) { + if (!last) last = node + break + } else { + last = node + } + } + if (!last) return + const li = nav[last.getAttribute('data-id')] + + if (!li || li === active) return + if (active) active.classList.remove('active') + + li.classList.add('active') + active = li + + // scroll into view + // https://github.com/vuejs/vuejs.org/blob/master/themes/vue/source/js/common.js#L282-L297 + if (!hoverOver && dom.body.classList.contains('sticky')) { + const curOffset = 0 + const cur = active.offsetTop + active.clientHeight + 40 + const isInView = ( + active.offsetTop >= wrap.scrollTop && + cur <= wrap.scrollTop + height + ) + const notThan = cur - curOffset < height + const top = isInView + ? wrap.scrollTop + : notThan + ? curOffset + : cur - height + + sidebar.scrollTop = top + } + } + + dom.off('scroll', highlight) + dom.on('scroll', highlight) + dom.on(sidebar, 'mouseover', () => { hoverOver = true }) + dom.on(sidebar, 'mouseleave', () => { hoverOver = false }) } -export function scrollIntoView () { - +export function scrollIntoView (id) { + const section = dom.find('#' + id) + section && setTimeout(() => section.scrollIntoView(), 0) } -export function scroll2Top () { +const scrollEl = dom.$.scrollingElement || dom.$.documentElement + +export function scroll2Top (offset = 0) { + scrollEl.scrollTop = offset === true ? 0 : Number(offset) } diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index d5316ae..25b7438 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -2,6 +2,8 @@ import { get } from './ajax' import { callHook } from '../init/lifecycle' import { getRoot } from '../route/util' import { noop } from '../util/core' +import { scrollIntoView } from '../event/scroll' +import { getAndActive } from '../event/sidebar' export function fetchMixin (Docsify) { let last @@ -57,7 +59,8 @@ export function fetchMixin (Docsify) { export function initFetch (vm) { vm._fetchCover(vm) vm._fetch(result => { - vm.$resetEvents() + scrollIntoView(vm.route.query.id) + getAndActive('nav') callHook(vm, 'doneEach') }) } diff --git a/src/core/index.js b/src/core/index.js index 3ac8b56..f5b8b4b 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,7 +2,6 @@ import { initMixin } from './init' import { routeMixin } from './route' import { renderMixin } from './render' import { fetchMixin } from './fetch' -import { eventMixin } from './event' import initGlobalAPI from './global-api' function Docsify () { @@ -13,7 +12,6 @@ initMixin(Docsify) routeMixin(Docsify) renderMixin(Docsify) fetchMixin(Docsify) -eventMixin(Docsify) /** * Global API diff --git a/src/event.js b/src/event.js deleted file mode 100644 index 536899c..0000000 --- a/src/event.js +++ /dev/null @@ -1,159 +0,0 @@ -import { isMobile } from './util' - -/** - * Active sidebar when scroll - * @link https://buble.surge.sh/ - */ -export function scrollActiveSidebar () { - if (isMobile()) return - - let hoveredOverSidebar = false - const anchors = document.querySelectorAll('.anchor') - const sidebar = document.querySelector('.sidebar') - const sidebarContainer = sidebar.querySelector('.sidebar-nav') - const sidebarHeight = sidebar.clientHeight - - const nav = {} - const lis = sidebar.querySelectorAll('li') - let active = sidebar.querySelector('li.active') - - for (let i = 0, len = lis.length; i < len; i += 1) { - const li = lis[i] - const a = li.querySelector('a') - if (!a) continue - let href = a.getAttribute('href') - - if (href !== '/') { - const match = href.match('#([^#]+)$') - if (match && match.length) href = match[0].slice(1) - } - - nav[decodeURIComponent(href)] = li - } - - function highlight () { - const top = document.body.scrollTop - let last - - for (let i = 0, len = anchors.length; i < len; i += 1) { - const node = anchors[i] - - if (node.offsetTop > top) { - if (!last) last = node - break - } else { - last = node - } - } - if (!last) return - const li = nav[last.getAttribute('data-id')] - - if (!li || li === active) return - if (active) active.classList.remove('active') - - li.classList.add('active') - active = li - - // scroll into view - // https://github.com/vuejs/vuejs.org/blob/master/themes/vue/source/js/common.js#L282-L297 - if (!hoveredOverSidebar && !sticky.noSticky) { - const currentPageOffset = 0 - const currentActiveOffset = active.offsetTop + active.clientHeight + 40 - const currentActiveIsInView = ( - active.offsetTop >= sidebarContainer.scrollTop && - currentActiveOffset <= sidebarContainer.scrollTop + sidebarHeight - ) - const linkNotFurtherThanSidebarHeight = currentActiveOffset - currentPageOffset < sidebarHeight - const newScrollTop = currentActiveIsInView - ? sidebarContainer.scrollTop - : linkNotFurtherThanSidebarHeight - ? currentPageOffset - : currentActiveOffset - sidebarHeight - - sidebar.scrollTop = newScrollTop - } - } - - window.removeEventListener('scroll', highlight) - window.addEventListener('scroll', highlight) - sidebar.addEventListener('mouseover', () => { hoveredOverSidebar = true }) - sidebar.addEventListener('mouseleave', () => { hoveredOverSidebar = false }) -} - -export function scrollIntoView () { - const id = window.location.hash.match(/#[^#\/]+$/g) - if (!id || !id.length) return - const section = document.querySelector(decodeURIComponent(id[0])) - - if (section) setTimeout(() => section.scrollIntoView(), 0) - - return section -} - -/** - * Acitve link - */ -export function activeLink (dom, activeParent) { - const host = window.location.href - - dom = typeof dom === 'object' ? dom : document.querySelector(dom) - if (!dom) return - let target - - ;[].slice.call(dom.querySelectorAll('a')) - .sort((a, b) => b.href.length - a.href.length) - .forEach(node => { - if (host.indexOf(node.href) === 0 && !target) { - activeParent - ? node.parentNode.classList.add('active') - : node.classList.add('active') - target = node - } else { - activeParent - ? node.parentNode.classList.remove('active') - : node.classList.remove('active') - } - }) - - return target -} - -/** - * sidebar toggle - */ -export function bindToggle (dom) { - dom = typeof dom === 'object' ? dom : document.querySelector(dom) - if (!dom) return - const body = document.body - - dom.addEventListener('click', () => body.classList.toggle('close')) - - if (isMobile()) { - const sidebar = document.querySelector('.sidebar') - sidebar.addEventListener('click', () => { - body.classList.toggle('close') - setTimeout(() => activeLink(sidebar, true), 0) - }) - } -} - -const scrollingElement = document.scrollingElement || document.documentElement - -export function scroll2Top (offset = 0) { - scrollingElement.scrollTop = offset === true ? 0 : Number(offset) -} - -export function sticky () { - sticky.dom = sticky.dom || document.querySelector('section.cover') - const coverHeight = sticky.dom.getBoundingClientRect().height - - return (function () { - if (window.pageYOffset >= coverHeight || sticky.dom.classList.contains('hidden')) { - document.body.classList.add('sticky') - sticky.noSticky = false - } else { - document.body.classList.remove('sticky') - sticky.noSticky = true - } - })() -} From e2b7b976cf5f36933bd946461d8f100f22962dba Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 19:35:14 +0800 Subject: [PATCH 022/746] refactor(core): fix route path --- src/core/event/index.js | 8 ++ src/core/event/scroll.js | 4 +- src/core/fetch/ajax.js | 4 +- src/core/fetch/index.js | 24 ++-- src/core/index.js | 12 +- src/core/init/index.js | 4 +- src/core/render/compiler.js | 34 +++-- src/core/render/index.js | 39 +++++- src/core/render/progressbar.js | 6 +- src/core/render/tpl.js | 2 +- src/core/route/hash.js | 13 +- src/core/route/index.js | 16 +-- src/core/route/util.js | 12 +- src/index.js | 145 -------------------- src/render.js | 237 --------------------------------- src/themes/vue.css | 9 ++ 16 files changed, 125 insertions(+), 444 deletions(-) delete mode 100644 src/index.js delete mode 100644 src/render.js diff --git a/src/core/event/index.js b/src/core/event/index.js index 1181c9b..6c469a5 100644 --- a/src/core/event/index.js +++ b/src/core/event/index.js @@ -1,6 +1,14 @@ import { isMobile } from '../util/env' import { body, on } from '../util/dom' import * as sidebar from './sidebar' +import { scrollIntoView } from './scroll' + +export function eventMixin (proto) { + proto.$resetEvents = function () { + scrollIntoView(this.route.query.id) + sidebar.getAndActive('nav') + } +} export function initEvent (vm) { // Bind toggle button diff --git a/src/core/event/scroll.js b/src/core/event/scroll.js index 89b9b82..5cfdb11 100644 --- a/src/core/event/scroll.js +++ b/src/core/event/scroll.js @@ -1,5 +1,6 @@ import { isMobile } from '../util/env' import * as dom from '../util/dom' +import { parse } from '../route/hash' export function scrollActiveSidebar () { if (isMobile) return @@ -21,8 +22,7 @@ export function scrollActiveSidebar () { let href = a.getAttribute('href') if (href !== '/') { - const match = href.match('#([^#]+)$') - if (match && match.length) href = match[0].slice(1) + href = parse(href).query.id } nav[decodeURIComponent(href)] = li diff --git a/src/core/fetch/ajax.js b/src/core/fetch/ajax.js index 09d4390..5038897 100644 --- a/src/core/fetch/ajax.js +++ b/src/core/fetch/ajax.js @@ -28,7 +28,9 @@ export function get (url, hasBar = false) { return { then: function (success, error = noop) { if (hasBar) { - const id = setInterval(_ => progressbar({}), 500) + const id = setInterval(_ => progressbar({ + step: Math.floor(Math.random() * 5 + 1) + }), 500) on('progress', progressbar) on('loadend', evt => { diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index 25b7438..e3f4c0d 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -2,13 +2,10 @@ import { get } from './ajax' import { callHook } from '../init/lifecycle' import { getRoot } from '../route/util' import { noop } from '../util/core' -import { scrollIntoView } from '../event/scroll' -import { getAndActive } from '../event/sidebar' -export function fetchMixin (Docsify) { +export function fetchMixin (proto) { let last - - Docsify.prototype._fetch = function (cb = noop) { + proto._fetch = function (cb = noop) { const { path } = this.route const { loadNavbar, loadSidebar } = this.config const root = getRoot(path) @@ -42,7 +39,7 @@ export function fetchMixin (Docsify) { ) } - Docsify.prototype._fetchCover = function () { + proto._fetchCover = function () { const { coverpage } = this.config const root = getRoot(this.route.path) @@ -54,13 +51,16 @@ export function fetchMixin (Docsify) { get(this.$getFile(root + coverpage)) .then(text => this._renderCover(text)) } + + proto.$fetch = function () { + this._fetchCover() + this._fetch(result => { + this.$resetEvents() + callHook(this, 'doneEach') + }) + } } export function initFetch (vm) { - vm._fetchCover(vm) - vm._fetch(result => { - scrollIntoView(vm.route.query.id) - getAndActive('nav') - callHook(vm, 'doneEach') - }) + vm.$fetch() } diff --git a/src/core/index.js b/src/core/index.js index f5b8b4b..3a8b6be 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -2,16 +2,20 @@ import { initMixin } from './init' import { routeMixin } from './route' import { renderMixin } from './render' import { fetchMixin } from './fetch' +import { eventMixin } from './event' import initGlobalAPI from './global-api' function Docsify () { this._init() } -initMixin(Docsify) -routeMixin(Docsify) -renderMixin(Docsify) -fetchMixin(Docsify) +const proto = Docsify.prototype + +initMixin(proto) +routeMixin(proto) +renderMixin(proto) +fetchMixin(proto) +eventMixin(proto) /** * Global API diff --git a/src/core/init/index.js b/src/core/init/index.js index 826e6ef..064704f 100644 --- a/src/core/init/index.js +++ b/src/core/init/index.js @@ -6,8 +6,8 @@ import { initEvent } from '../event' import { initFetch } from '../fetch' import { isFn } from '../util/core' -export function initMixin (Docsify) { - Docsify.prototype._init = function () { +export function initMixin (proto) { + proto._init = function () { const vm = this vm.config = config || {} diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 06c046c..c4abe6a 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -4,12 +4,15 @@ import { helper as helperTpl, tree as treeTpl } from './tpl' import { genTree } from './gen-tree' import { slugify, clearSlugCache } from './slugify' import { emojify } from './emojify' -import { toURL } from '../route/hash' -import { isFn, merge, cached, noop } from '../util/core' +import { toURL, parse } from '../route/hash' +import { getBasePath, getPath } from '../route/util' +import { isFn, merge, cached } from '../util/core' let markdownCompiler = marked let contentBase = '' +let currentPath = '' let renderer = new marked.Renderer() +const TOC = {} let toc = [] /** @@ -30,7 +33,8 @@ export const markdown = cached(text => { markdown.renderer = renderer markdown.init = function (config = {}, base = window.location.pathname) { - contentBase = base + contentBase = getBasePath(base) + currentPath = parse().path if (isFn(config)) { markdownCompiler = config(marked, renderer) @@ -40,13 +44,17 @@ markdown.init = function (config = {}, base = window.location.pathname) { } } +markdown.update = function () { + currentPath = parse().path +} + /** * render anchor tag * @link https://github.com/chjj/marked#overriding-renderer-methods */ renderer.heading = function (text, level) { const slug = slugify(text) - const url = toURL(contentBase, { id: slug }) + const url = toURL(currentPath, { id: slug }) toc.push({ level, slug: url, title: text }) @@ -60,8 +68,7 @@ renderer.code = function (code, lang = '') { } renderer.link = function (href, title, text) { if (!/:|(\/{2})/.test(href)) { - // TODO - href = `#/${href}`.replace(/\/+/g, '/') + href = toURL(href) } return `${text}` } @@ -74,12 +81,10 @@ renderer.paragraph = function (text) { return `

                                ${text}

                                ` } renderer.image = function (href, title, text) { - // TODO - // get base path - // const url = /:|(\/{2})/.test(href) ? href : ($docsify.basePath + href).replace(/\/+/g, '/') - // const titleHTML = title ? ` title="${title}"` : '' + const url = getPath(contentBase, href) + const titleHTML = title ? ` title="${title}"` : '' - // return `${text}` + return `${text}` } /** @@ -105,8 +110,11 @@ export function sidebar (text, level) { export function subSidebar (el, level) { if (el) { toc[0] && toc[0].level === 1 && toc.shift() - const tree = genTree(toc, level) - el.parentNode.innerHTML += treeTpl(tree, '
                                  ') + const tree = genTree(TOC[currentPath] || toc, level) + el.parentNode.innerHTML += treeTpl(tree, '
                                    ') + } + if (toc.length) { + TOC[currentPath] = toc.slice() } toc = [] } diff --git a/src/core/render/index.js b/src/core/render/index.js index 53cc62d..5fcaf1d 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -1,10 +1,21 @@ import * as dom from '../util/dom' import { getAndActive, sticky } from '../event/sidebar' -import { scrollActiveSidebar } from '../event/scroll' +import { scrollActiveSidebar, scroll2Top } from '../event/scroll' import cssVars from '../util/polyfill/css-vars' import * as tpl from './tpl' import { markdown, sidebar, subSidebar, cover } from './compiler' import { callHook } from '../init/lifecycle' +import { getBasePath, getPath } from '../route/util' + +function executeScript () { + const script = dom.findAll('.markdown-section>script') + .filter(s => !/template/.test(s.type))[0] + if (!script) return false + const code = script.innerText.trim() + if (!code) return false + + window.__EXECUTE_RESULT__ = new Function('return ' + code)() +} function renderMain (html) { if (!html) { @@ -14,11 +25,21 @@ function renderMain (html) { this._renderTo('.markdown-section', html) // Render sidebar with the TOC !this.config.loadSidebar && this._renderSidebar() + // execute script + this.config.executeScript && executeScript() + + if (!this.config.executeScript + && typeof window.Vue !== 'undefined' + && !executeScript()) { + window.__EXECUTE_RESULT__ = new window.Vue().$mount('#main') + } + + if (this.config.auto2top) { + setTimeout(() => scroll2Top(this.config.auto2top), 0) + } } -export function renderMixin (Docsify) { - const proto = Docsify.prototype - +export function renderMixin (proto) { proto._renderTo = function (el, content, replace) { const node = dom.getNode(el) if (node) node[replace ? 'outerHTML' : 'innerHTML'] = content @@ -54,14 +75,14 @@ export function renderMixin (Docsify) { dom.toggleClass(el, 'add', 'show') let html = cover(text) - const m = html.trim().match('

                                    ([^<]*?)

                                    $') + const m = html.trim().match('

                                    ([^<]*?)

                                    $') if (m) { if (m[2] === 'color') { el.style.background = m[1] + (m[3] || '') } else { dom.toggleClass(el, 'add', 'has-mask') - el.style.backgroundImage = `url(${m[1]})` + el.style.backgroundImage = `url(${getPath(getBasePath(this.config.basePath), m[1])})` } html = html.replace(m[0], '') } @@ -69,13 +90,17 @@ export function renderMixin (Docsify) { this._renderTo('.cover-main', html) sticky() } + + proto._updateRender = function () { + markdown.update() + } } export function initRender (vm) { const config = vm.config // Init markdown compiler - markdown.init(vm.config.markdown) + markdown.init(config.markdown, config.basePath) const id = config.el || '#app' const navEl = dom.find('nav') || dom.create('nav') diff --git a/src/core/render/progressbar.js b/src/core/render/progressbar.js index c8347e6..420fd6d 100644 --- a/src/core/render/progressbar.js +++ b/src/core/render/progressbar.js @@ -1,5 +1,4 @@ import * as dom from '../util/dom' -import { isPrimitive } from '../util/core' let barEl let timeId @@ -22,11 +21,8 @@ export default function ({ loaded, total, step }) { !barEl && init() - if (!isPrimitive(step)) { - step = Math.floor(Math.random() * 5 + 1) - } if (step) { - num = parseInt(barEl.style.width, 10) + step + num = parseInt(barEl.style.width || 0, 10) + step num = num > 80 ? 80 : num } else { num = Math.floor(loaded / total * 100) diff --git a/src/core/render/tpl.js b/src/core/render/tpl.js index cdf870d..0bd5198 100644 --- a/src/core/render/tpl.js +++ b/src/core/render/tpl.js @@ -38,7 +38,7 @@ export function main (config) { return (isMobile ? `${aside}
                                    ` : `
                                    ${aside}`) + '
                                    ' + - '
                                    ' + + '
                                    ' + '
                                    ' + '
                                    ' } diff --git a/src/core/route/hash.js b/src/core/route/hash.js index 7f0129d..0ca7880 100644 --- a/src/core/route/hash.js +++ b/src/core/route/hash.js @@ -1,4 +1,4 @@ -import { merge } from '../util/core' +import { merge, cached } from '../util/core' import { parseQuery, stringifyQuery } from './util' function replaceHash (path) { @@ -8,6 +8,11 @@ function replaceHash (path) { ) } +const replaceSlug = cached(path => { + return path + .replace('#', '?id=') + .replace(/\?(\w+)=/g, (_, slug) => slug === 'id' ? '?id=' : `&${slug}=`) +}) /** * Normalize the current url * @@ -18,9 +23,7 @@ function replaceHash (path) { export function normalize () { let path = getHash() - path = path - .replace('#', '?id=') - .replace(/\?(\w+)=/g, (_, slug) => slug === 'id' ? '?id=' : `&${slug}=`) + path = replaceSlug(path) if (path.charAt(0) === '/') return replaceHash(path) replaceHash('/' + path) @@ -62,7 +65,7 @@ export function parse (path = window.location.href) { * @param {object} qs query params */ export function toURL (path, params) { - const route = parse(path) + const route = parse(replaceSlug(path)) route.query = merge({}, route.query, params) path = route.path + stringifyQuery(route.query) diff --git a/src/core/route/index.js b/src/core/route/index.js index ad29c57..7e6606d 100644 --- a/src/core/route/index.js +++ b/src/core/route/index.js @@ -1,5 +1,5 @@ import { normalize, parse } from './hash' -import { getBasePath, cleanPath } from './util' +import { getBasePath, getPath } from './util' import { on } from '../util/dom' function getAlias (path, alias) { @@ -15,16 +15,16 @@ function getFileName (path) { : `${path}.md` } -export function routeMixin (Docsify) { - Docsify.prototype.route = {} - Docsify.prototype.$getFile = function (path) { +export function routeMixin (proto) { + proto.route = {} + proto.$getFile = function (path) { const { config } = this const base = getBasePath(config.basePath) path = getAlias(path, config.alias) path = getFileName(path) path = path === '/README.md' ? ('/' + config.homepage || path) : path - path = cleanPath(base + path) + path = getPath(base, path) return path } @@ -39,14 +39,14 @@ export function initRoute (vm) { on('hashchange', _ => { normalize() vm.route = parse() + vm._updateRender() if (lastRoute.path === vm.route.path) { - // TODO: goto xxx + vm.$resetEvents() return } - vm._fetchCover() - vm._fetch() + vm.$fetch() lastRoute = vm.route }) } diff --git a/src/core/route/util.js b/src/core/route/util.js index 635273b..f49afde 100644 --- a/src/core/route/util.js +++ b/src/core/route/util.js @@ -3,7 +3,7 @@ import { cached } from '../util/core' const decode = decodeURIComponent const encode = encodeURIComponent -export const parseQuery = cached(query => { +export function parseQuery (query) { const res = {} query = query.trim().replace(/^(\?|#|&)/, '') @@ -19,7 +19,7 @@ export const parseQuery = cached(query => { res[parts[0]] = decode(parts[1]) }) return res -}) +} export function stringifyQuery (obj) { const qs = [] @@ -37,6 +37,14 @@ export const getBasePath = cached(base => { : cleanPath(window.location.pathname + '/' + base) }) +export function getPath (...args) { + const path = args.find(path => /:|(\/{2})/.test(path)) + + if (path) return path + + return cleanPath(args.join('/')) +} + export const getRoot = cached(path => { return /\/$/g.test(path) ? path : path.match(/(\S*\/)[^\/]+$/)[1] }) diff --git a/src/index.js b/src/index.js deleted file mode 100644 index 49dac57..0000000 --- a/src/index.js +++ /dev/null @@ -1,145 +0,0 @@ -import * as utils from './util' -import { scrollIntoView, activeLink } from './event' -import * as render from './render' -import Hook from './hook' - -const OPTIONS = utils.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, - ga: '' -}, window.$docsify) -const script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop() - -// load configuration for script attribute -if (script) { - for (const prop in OPTIONS) { - const val = script.getAttribute('data-' + utils.camel2kebab(prop)) - OPTIONS[prop] = utils.isNil(val) ? OPTIONS[prop] : (val || true) - } - if (OPTIONS.loadSidebar === true) OPTIONS.loadSidebar = '_sidebar.md' - if (OPTIONS.loadNavbar === true) OPTIONS.loadNavbar = '_navbar.md' - if (OPTIONS.coverpage === true) OPTIONS.coverpage = '_coverpage.md' - if (OPTIONS.repo === true) OPTIONS.repo = '' - if (OPTIONS.name === true) OPTIONS.name = '' -} - -const hook = new Hook() - -// utils -window.$docsify = OPTIONS -window.Docsify = { - installed: true, - utils: utils.merge({}, utils), - hook -} - -// load options -render.init() - -let cacheRoute = null -let cacheXhr = null - -const getAlias = function (route) { - if (OPTIONS.alias[route]) { - return getAlias(OPTIONS.alias[route]) - } else { - return route - } -} - -const mainRender = function (cb) { - let page - let route = utils.getRoute() - if (cacheRoute === route) return cb() - - let basePath = cacheRoute = OPTIONS.basePath + route - - if (!/\//.test(basePath)) { - basePath = '' - } else if (basePath && !/\/$/.test(basePath)) { - basePath = basePath.match(/(\S*\/)[^\/]+$/)[1] - } - - // replace route - if (OPTIONS.alias && OPTIONS.alias['/' + route]) { - route = getAlias('/' + route) - } else { - route = (OPTIONS.basePath + route).replace(/\/+/, '/') - } - - if (!route) { - page = OPTIONS.homepage || 'README.md' - } else if (/\.md$/.test(route)) { - page = route - } else if (/\/$/.test(route)) { - page = `${route}README.md` - } else { - page = `${route}.md` - } - - // Render Cover page - if (OPTIONS.coverpage && page === OPTIONS.homepage) { - utils.load(OPTIONS.coverpage).then(render.renderCover) - } - - cacheXhr && cacheXhr.abort && cacheXhr.abort() - // Render markdown file - cacheXhr = utils.load(page, 'GET', render.renderLoading) - cacheXhr.then(result => { - render.renderArticle(result) - // clear cover - if (OPTIONS.coverpage && page !== OPTIONS.homepage) render.renderCover() - // render sidebar - if (OPTIONS.loadSidebar) { - const renderSidebar = result => { render.renderSidebar(result); cb() } - - utils.load(basePath + OPTIONS.loadSidebar).then(renderSidebar, - _ => utils.load(OPTIONS.loadSidebar).then(renderSidebar)) - } else { - cb() - } - }, _ => render.renderArticle(null)) - - // Render navbar - if (OPTIONS.loadNavbar) { - utils.load(basePath + OPTIONS.loadNavbar).then(render.renderNavbar, - _ => utils.load(OPTIONS.loadNavbar).then(render.renderNavbar)) - } -} - -const Docsify = function () { - setTimeout(_ => { - ;[].concat(OPTIONS.plugins).forEach(fn => typeof fn === 'function' && fn(hook)) - window.Docsify.hook.emit('init') - - const dom = document.querySelector(OPTIONS.el) || document.body - const replace = dom !== document.body - const main = function () { - mainRender(_ => { - scrollIntoView() - activeLink('nav') - window.Docsify.hook.emit('doneEach') - }) - } - - // Render app - render.renderApp(dom, replace) - main() - if (!/^#\//.test(window.location.hash)) window.location.hash = '#/' - window.addEventListener('hashchange', main) - window.Docsify.hook.emit('ready') - }, 0) -} - -export default Docsify() diff --git a/src/render.js b/src/render.js deleted file mode 100644 index 4125088..0000000 --- a/src/render.js +++ /dev/null @@ -1,237 +0,0 @@ -import marked from 'marked' -import Prism from 'prismjs' -import * as tpl from './tpl' -import * as event from './event' -import * as polyfill from './polyfill' -import { genTree, getRoute, isMobile, slugify, merge, emojify } from './util' - -let markdown = marked -let toc = [] -const CACHE = {} -const originTitle = document.title - -const renderTo = function (dom, content) { - dom = typeof dom === 'object' ? dom : document.querySelector(dom) - dom.innerHTML = content - slugify.clear() - - return dom -} - -/** - * init render - */ -export function init () { - const renderer = new marked.Renderer() - /** - * render anchor tag - * @link https://github.com/chjj/marked#overriding-renderer-methods - */ - renderer.heading = function (text, level) { - const slug = slugify(text) - let route = '' - - route = `#/${getRoute()}` - toc.push({ level, slug: `${route}#${encodeURIComponent(slug)}`, title: text }) - - return `${text}` - } - // highlight code - renderer.code = function (code, lang = '') { - const hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup) - - return `
                                    ${hl}
                                    ` - } - renderer.link = function (href, title, text) { - if (!/:|(\/{2})/.test(href)) { - href = `#/${href}`.replace(/\/+/g, '/') - } - return `${text}` - } - renderer.paragraph = function (text) { - if (/^!>/.test(text)) { - return tpl.helper('tip', text) - } else if (/^\?>/.test(text)) { - return tpl.helper('warn', text) - } - return `

                                    ${text}

                                    ` - } - renderer.image = function (href, title, text) { - const url = /:|(\/{2})/.test(href) ? href : ($docsify.basePath + href).replace(/\/+/g, '/') - const titleHTML = title ? ` title="${title}"` : '' - - return `${text}` - } - - if (typeof $docsify.markdown === 'function') { - markdown = $docsify.markdown.call(this, markdown, renderer) - } else { - if ($docsify.markdown && $docsify.markdown.renderer) { - $docsify.markdown.renderer = merge(renderer, $docsify.markdown.renderer) - } - markdown.setOptions(merge({ renderer }, $docsify.markdown)) - } - - const md = markdown - - markdown = text => emojify(md(text)) - - window.Docsify.utils.marked = text => { - const result = markdown(text) - toc = [] - return result - } -} - -/** - * App - */ -export function renderApp (dom, replace) { - const nav = document.querySelector('nav') || document.createElement('nav') - const body = document.body - const head = document.head - - if (!$docsify.repo) nav.classList.add('no-badge') - - dom[replace ? 'outerHTML' : 'innerHTML'] = tpl.corner($docsify.repo) + - ($docsify.coverpage ? tpl.cover() : '') + - tpl.main() - body.insertBefore(nav, body.children[0]) - - // theme color - if ($docsify.themeColor) { - head.innerHTML += tpl.theme($docsify.themeColor) - polyfill.cssVars() - } - - // render name - if ($docsify.name) { - const aside = document.querySelector('.sidebar') - aside.innerHTML = `

                                    ${$docsify.name}

                                    ` + aside.innerHTML - } - - // bind toggle - event.bindToggle('button.sidebar-toggle') - // bind sticky effect - if ($docsify.coverpage) { - !isMobile() && window.addEventListener('scroll', event.sticky) - } else { - body.classList.add('sticky') - } -} - -/** - * article - */ -export function renderArticle (content) { - const hook = window.Docsify.hook - const renderFn = function (data) { - renderTo('article', data) - if (!$docsify.loadSidebar) renderSidebar() - - if (data && typeof Vue !== 'undefined') { - CACHE.vm && CACHE.vm.$destroy() - - const script = [].slice.call( - document.body.querySelectorAll('article>script')) - .filter(script => !/template/.test(script.type) - )[0] - const code = script ? script.innerText.trim() : null - - script && script.remove() - CACHE.vm = code - ? new Function(`return ${code}`)() - : new Vue({ el: 'main' }) // eslint-disable-line - CACHE.vm && CACHE.vm.$nextTick(_ => event.scrollActiveSidebar()) - } - if ($docsify.auto2top) setTimeout(() => event.scroll2Top($docsify.auto2top), 0) - } - - hook.emit('before', content, result => { - const html = result ? markdown(result) : '' - - hook.emit('after', html, result => renderFn(result || 'not found')) - }) -} - -/** - * navbar - */ -export function renderNavbar (content) { - if (CACHE.navbar && CACHE.navbar === content) return - CACHE.navbar = content - - if (content) renderTo('nav', markdown(content)) - event.activeLink('nav') -} - -/** - * sidebar - */ -export function renderSidebar (content) { - let html - - if (content) { - html = markdown(content) - // find url tag - html = html.match(/]*>([\s\S]+)<\/ul>/g)[0] - } else { - html = tpl.tree(genTree(toc, $docsify.maxLevel), '
                                      ') - } - - renderTo('.sidebar-nav', html) - - if (toc[0] && toc[0].level === 1) { - document.title = `${toc[0].title}${originTitle ? ' - ' + originTitle : ''}` - } - - const target = event.activeLink('.sidebar-nav', true) - if (target) renderSubSidebar(target) - - toc = [] - event.scrollActiveSidebar() -} - -export function renderSubSidebar (target) { - if (!$docsify.subMaxLevel) return - toc[0] && toc[0].level === 1 && toc.shift() - target.parentNode.innerHTML += tpl.tree(genTree(toc, $docsify.subMaxLevel), '
                                        ') -} - -/** - * Cover Page - */ -export function renderCover (content) { - renderCover.dom = renderCover.dom || document.querySelector('section.cover') - if (!content) { - renderCover.dom.classList.remove('show') - return - } - renderCover.dom.classList.add('show') - if (renderCover.rendered) return event.sticky() - - // render cover - const cacheToc = toc.slice() - let html = markdown(content) - const match = html.trim().match('

                                        ([^<]*?)

                                        $') - - toc = cacheToc.slice() - - // render background - if (match) { - const coverEl = document.querySelector('section.cover') - - if (match[2] === 'color') { - coverEl.style.background = match[1] + (match[3] || '') - } else { - coverEl.classList.add('has-mask') - coverEl.style.backgroundImage = `url(${match[1]})` - } - html = html.replace(match[0], '') - } - - renderTo('.cover-main', html) - renderCover.rendered = true - - event.sticky() -} diff --git a/src/themes/vue.css b/src/themes/vue.css index 70ed86c..4c3d03f 100644 --- a/src/themes/vue.css +++ b/src/themes/vue.css @@ -46,6 +46,15 @@ body { } } +.app-sub-sidebar { + .section-link { + &::before { + content: '-'; + padding-right: 4px; + } + } +} + /* markdown content found on pages */ .markdown-section h1, .markdown-section h2, From fd9c3bd19d99ba17f0cbb8e987746cbc9d8a33a1 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 19:36:28 +0800 Subject: [PATCH 023/746] docs: update --- docs/_sidebar.md | 2 +- docs/cover.md | 2 +- docs/vue.md | 4 ++-- docs/zh-cn/_sidebar.md | 2 +- docs/zh-cn/vue.md | 4 ++-- src/core/render/index.js | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 76261f0..3753426 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -4,7 +4,7 @@ - [Custom navbar](/custom-navbar) - [Cover page](/cover) -- Configuration +- Customization - [Configuration](/configuration) - [Themes](/themes) - [Using plugins](/plugins) diff --git a/docs/cover.md b/docs/cover.md index 7054a06..2a538e7 100644 --- a/docs/cover.md +++ b/docs/cover.md @@ -1,6 +1,6 @@ # Cover -Activate the cover feature by setting `coverpage`. The detail in [Configuration#coverpage](zh-cn/configuration#coverpage). +Activate the cover feature by setting `coverpage`. The detail in [Configuration#coverpage](configuration#coverpage). ## Basic usage diff --git a/docs/vue.md b/docs/vue.md index 40b98fd..27c4204 100644 --- a/docs/vue.md +++ b/docs/vue.md @@ -13,7 +13,7 @@ Load the Vue in `index.html`. ``` Then you can immediately write Vue code at Markdown file. -`new Vue({ el: 'main' })` script is executed by default to create instance. +`new Vue({ el: '#main' })` script is executed by default to create instance. *README.md* @@ -44,7 +44,7 @@ You can manually initialize a Vue instance. diff --git a/docs/zh-cn/_sidebar.md b/docs/zh-cn/_sidebar.md index e911c38..952a6fd 100644 --- a/docs/zh-cn/_sidebar.md +++ b/docs/zh-cn/_sidebar.md @@ -4,7 +4,7 @@ - [定制导航栏](zh-cn/custom-navbar) - [封面](zh-cn/cover) -- 配置 +- 定制化 - [配置项](zh-cn/configuration) - [主题](zh-cn/themes) - [使用插件](zh-cn/plugins) diff --git a/docs/zh-cn/vue.md b/docs/zh-cn/vue.md index 37dd807..3c811c4 100644 --- a/docs/zh-cn/vue.md +++ b/docs/zh-cn/vue.md @@ -12,7 +12,7 @@ ``` -接着就可以愉快地在 Markdown 里写 Vue 了。默认会执行 `new Vue({ el: 'main' })` 创建示例。 +接着就可以愉快地在 Markdown 里写 Vue 了。默认会执行 `new Vue({ el: '#main' })` 创建示例。 *README.md* @@ -43,7 +43,7 @@ diff --git a/src/core/render/index.js b/src/core/render/index.js index 5fcaf1d..4a744bd 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -28,9 +28,9 @@ function renderMain (html) { // execute script this.config.executeScript && executeScript() - if (!this.config.executeScript - && typeof window.Vue !== 'undefined' - && !executeScript()) { + if (!this.config.executeScript && + typeof window.Vue !== 'undefined' && + !executeScript()) { window.__EXECUTE_RESULT__ = new window.Vue().$mount('#main') } From b7768b1b3c1a9914427c7219351ae1d8c60650a5 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 21:59:19 +0800 Subject: [PATCH 024/746] feat(render): add auto header --- src/core/config.js | 1 + src/core/event/sidebar.js | 44 +++++++++++++++++++++++-------------- src/core/render/compiler.js | 5 +---- src/core/render/index.js | 16 +++++++++++--- src/core/route/hash.js | 4 ++-- src/core/util/dom.js | 6 ++++- 6 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/core/config.js b/src/core/config.js index a1bf9bb..230348a 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -14,6 +14,7 @@ const config = merge({ name: '', themeColor: '', nameLink: window.location.pathname, + autoHeader: false, ga: '' }, window.$docsify) diff --git a/src/core/event/sidebar.js b/src/core/event/sidebar.js index aa4475b..9bb1d07 100644 --- a/src/core/event/sidebar.js +++ b/src/core/event/sidebar.js @@ -1,43 +1,51 @@ import { isMobile } from '../util/env' -import { getNode, on, body, findAll, toggleClass } from '../util/dom' +import * as dom from '../util/dom' import { getHash } from '../route/hash' +const title = dom.$.title /** * Toggle button */ export function btn (el) { - const toggle = () => body.classList.toggle('close') + const toggle = () => dom.body.classList.toggle('close') - el = getNode(el) - on(el, 'click', toggle) + el = dom.getNode(el) + dom.on(el, 'click', toggle) if (isMobile) { - const sidebar = getNode('.sidebar') + const sidebar = dom.getNode('.sidebar') - on(sidebar, 'click', () => { + dom.on(sidebar, 'click', () => { toggle() - setTimeout(() => getAndActive(true), 0) + setTimeout(() => getAndActive(sidebar, true, true), 0) }) } } export function sticky () { - const cover = getNode('section.cover') + const cover = dom.getNode('section.cover') if (!cover) return const coverHeight = cover.getBoundingClientRect().height if (window.pageYOffset >= coverHeight || cover.classList.contains('hidden')) { - toggleClass(body, 'add', 'sticky') + dom.toggleClass(dom.body, 'add', 'sticky') } else { - toggleClass(body, 'remove', 'sticky') + dom.toggleClass(dom.body, 'remove', 'sticky') } } -export function getAndActive (el, isParent) { - const dom = getNode(el) - const links = findAll(dom, 'a') - const hash = '#' + getHash() +/** + * Get and active link + * @param {string|element} el + * @param {Boolean} isParent acitve parent + * @param {Boolean} autoTitle auto set title + * @return {element} + */ +export function getAndActive (el, isParent, autoTitle) { + el = dom.getNode(el) + const links = dom.findAll(el, 'a') + const hash = '#' + getHash() let target links @@ -48,11 +56,15 @@ export function getAndActive (el, isParent) { if (hash.indexOf(href) === 0 && !target) { target = a - toggleClass(node, 'add', 'active') + dom.toggleClass(node, 'add', 'active') } else { - toggleClass(node, 'remove', 'active') + dom.toggleClass(node, 'remove', 'active') } }) + if (autoTitle) { + dom.$.title = target ? `${target.innerText} - ${title}` : title + } + return target } diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index c4abe6a..92d27ba 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -67,10 +67,7 @@ renderer.code = function (code, lang = '') { return `
                                        ${hl}
                                        ` } renderer.link = function (href, title, text) { - if (!/:|(\/{2})/.test(href)) { - href = toURL(href) - } - return `${text}` + return `${text}` } renderer.paragraph = function (text) { if (/^!>/.test(text)) { diff --git a/src/core/render/index.js b/src/core/render/index.js index 4a744bd..746fdf7 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -46,12 +46,22 @@ export function renderMixin (proto) { } proto._renderSidebar = function (text) { - const { maxLevel, subMaxLevel } = this.config + const { maxLevel, subMaxLevel, autoHeader } = this.config this._renderTo('.sidebar-nav', sidebar(text, maxLevel)) - subSidebar(getAndActive('.sidebar-nav', true), subMaxLevel) + const active = getAndActive('.sidebar-nav', true, true) + subSidebar(active, subMaxLevel) // bind event scrollActiveSidebar() + + if (autoHeader && active) { + const main = dom.getNode('#main') + if (main.children[0].tagName !== 'H1') { + const h1 = dom.create('h1') + h1.innerText = active.innerText + dom.before(main, h1) + } + } } proto._renderNav = function (text) { @@ -128,7 +138,7 @@ export function initRender (vm) { // Render main app vm._renderTo(el, html, true) // Add nav - dom.body.insertBefore(navEl, dom.body.children[0]) + dom.before(dom.body, navEl) if (config.themeColor) { dom.$.head += tpl.theme(config.themeColor) diff --git a/src/core/route/hash.js b/src/core/route/hash.js index 0ca7880..60e0164 100644 --- a/src/core/route/hash.js +++ b/src/core/route/hash.js @@ -1,5 +1,5 @@ import { merge, cached } from '../util/core' -import { parseQuery, stringifyQuery } from './util' +import { parseQuery, stringifyQuery, cleanPath } from './util' function replaceHash (path) { const i = window.location.href.indexOf('#') @@ -70,5 +70,5 @@ export function toURL (path, params) { route.query = merge({}, route.query, params) path = route.path + stringifyQuery(route.query) - return '#' + path + return cleanPath('#/' + path) } diff --git a/src/core/util/dom.js b/src/core/util/dom.js index 06016a5..bbd3601 100644 --- a/src/core/util/dom.js +++ b/src/core/util/dom.js @@ -52,6 +52,10 @@ export function appendTo (target, el) { return target.appendChild(el) } +export function before (target, el) { + return target.insertBefore(el, target.children[0]) +} + export function on (el, type, handler) { isFn(type) ? window.addEventListener(el, type) @@ -72,5 +76,5 @@ export const off = function on (el, type, handler) { * toggleClass(el, 'add', 'active') => el.classList.add('active') */ export function toggleClass (el, type, val) { - el.classList[val ? type : 'toggle'](val || type) + el && el.classList[val ? type : 'toggle'](val || type) } From c108645e3483065639e6cb4a59d843a3fc523e0f Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 22:12:17 +0800 Subject: [PATCH 025/746] docs: add autoHeader --- docs/configuration.md | 13 +++++++++++++ docs/zh-cn/configuration.md | 14 +++++++++++++- docs/zh-cn/quickstart.md | 1 - 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 5af2515..487df25 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -254,3 +254,16 @@ window.$docsify = { } } ``` + +## auto-header + +- type: `Boolean` + +If `loadSidebar` and `autoHeader` are both enabled, for each link in _sidebar.md, prepend a header to the page before converting it to html. [#78](https://github.com/QingWei-Li/docsify/issues/78) + +```js +window.$docsify = { + loadSidebar: true, + autoHeader: true +} +``` diff --git a/docs/zh-cn/configuration.md b/docs/zh-cn/configuration.md index 23c96d4..8ab8157 100644 --- a/docs/zh-cn/configuration.md +++ b/docs/zh-cn/configuration.md @@ -229,7 +229,7 @@ window.$docsify = { - 类型:`String` -替换主题色。利用 [CSS3 支持变量]((https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables)的特性,对于老的浏览器有 polyfill 处理。 +替换主题色。利用 [CSS3 支持变量](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_variables)的特性,对于老的浏览器有 polyfill 处理。 ```js window.$docsify = { @@ -253,3 +253,15 @@ window.$docsify = { } ``` +## auto-header + +- 类型:`Boolean` + +同时设置 `loadSidebar` 和 `autoHeader` 后,可以根据 `_sidebar.md` 的内容自动为每个页面增加标题。[#78](https://github.com/QingWei-Li/docsify/issues/78) + +```js +window.$docsify = { + loadSidebar: true, + autoHeader: true +} +``` diff --git a/docs/zh-cn/quickstart.md b/docs/zh-cn/quickstart.md index c4ebc28..8ae891f 100644 --- a/docs/zh-cn/quickstart.md +++ b/docs/zh-cn/quickstart.md @@ -1,4 +1,3 @@ -# 快速开始 推荐安装 `docsify-cli` 工具,可以方便创建及本地预览文档网站。 From c7e09c34a719180d9a752d9fa44835a5de37dc3d Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 22:13:03 +0800 Subject: [PATCH 026/746] fix(compiler): link --- src/core/render/compiler.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 92d27ba..70e8991 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -67,7 +67,13 @@ renderer.code = function (code, lang = '') { return `
                                        ${hl}
                                        ` } renderer.link = function (href, title, text) { - return `${text}` + let blank = '' + if (!/:|(\/{2})/.test(href)) { + href = toURL(href) + } else { + blank = ' target="_blank"' + } + return `${text}` } renderer.paragraph = function (text) { if (/^!>/.test(text)) { From 4b643864652bd34d8b69c08c2e9f14e44d798450 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 22:13:45 +0800 Subject: [PATCH 027/746] docs: move changelog to history --- CHANGELOG.md | 97 -------------------------------------------------- HISTORY.md | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 97 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76f6013..e69de29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,97 +0,0 @@ -### 2.4.3 - -> 2017-02-15 - -#### Bug fixes -* fix emoji replacing error (#76) - -### 2.4.2 - -> 2017-02-14 - -#### Bug fixes -- fix(index): load file path error - - -### 2.4.1 - -> 2017-02-13 - -#### Bug fixes -- fix(index): cover page - -### 2.4.0 - -> 2017-02-13 - -#### Features - -- feat(hook): add `doneEach` - - -### 2.3.0 - -> 2017-02-13 - -#### Features - -- feat(src): add alias feature -- docs: update all documents -- feat(src): dynamic title -- feat(hook): support custom plugin -- feat(themes): add dark theme - -#### Bug fixes -- fix(event): `auto2top` has no effect on a FF mobile browser, fixed #67 -- fix: sidebar style -- fix(render): fix render link - -### 2.2.1 - -> 2017-02-11 - -#### Bug fixes -- fix(search): crash when not content, fixed #68 -- fix(event): scroll active sidebar -- fix(search): not work in mobile - -### 2.2.0 - -#### Features -- Add `Google Analytics` plugin. -```html - - -``` - -### 2.1.0 -#### Features -- Add search plugin -```html - - -``` - -#### Bug fixes -- fix sidebar style - -### 2.0.3 -#### Bug fixes -- fix: rendering emojis -- fix: css var polyfill - -### 2.0.2 - -#### Bug fixes -- fix button style in cover page. - -### 2.0.1 -#### Bug fixes -- border style. - -### 2.0.0 -#### Features -- Customize the theme color - -#### Break change -- Remove `data-router`, `data-sidebar`, `data-sidebar-toggle` APIs diff --git a/HISTORY.md b/HISTORY.md index d3cc3e3..6c9358e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,102 @@ +### 2.4.3 + +> 2017-02-15 + +#### Bug fixes +* fix emoji replacing error (#76) + +### 2.4.2 + +> 2017-02-14 + +#### Bug fixes +- fix(index): load file path error + + +### 2.4.1 + +> 2017-02-13 + +#### Bug fixes +- fix(index): cover page + +### 2.4.0 + +> 2017-02-13 + +#### Features + +- feat(hook): add `doneEach` + + +### 2.3.0 + +> 2017-02-13 + +#### Features + +- feat(src): add alias feature +- docs: update all documents +- feat(src): dynamic title +- feat(hook): support custom plugin +- feat(themes): add dark theme + +#### Bug fixes +- fix(event): `auto2top` has no effect on a FF mobile browser, fixed #67 +- fix: sidebar style +- fix(render): fix render link + +### 2.2.1 + +> 2017-02-11 + +#### Bug fixes +- fix(search): crash when not content, fixed #68 +- fix(event): scroll active sidebar +- fix(search): not work in mobile + +### 2.2.0 + +#### Features +- Add `Google Analytics` plugin. +```html + + +``` + +### 2.1.0 +#### Features +- Add search plugin +```html + + +``` + +#### Bug fixes +- fix sidebar style + +### 2.0.3 +#### Bug fixes +- fix: rendering emojis +- fix: css var polyfill + +### 2.0.2 + +#### Bug fixes +- fix button style in cover page. + +### 2.0.1 +#### Bug fixes +- border style. + +### 2.0.0 +#### Features +- Customize the theme color + +#### Break change +- Remove `data-router`, `data-sidebar`, `data-sidebar-toggle` APIs + + ### 1.10.5 #### Bug fixes - fix initialize the Vue instance From 3e7d6ab26ceb5b96fd1f1a3123c5c71ad8d5bca2 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 18 Feb 2017 23:04:52 +0800 Subject: [PATCH 028/746] docs: add executeScript demo --- docs/configuration.md | 22 ++++++++++++++++++++ docs/themes.md | 34 +++++++++++++++++++++++++++++++ docs/zh-cn/configuration.md | 22 ++++++++++++++++++++ docs/zh-cn/themes.md | 40 ++++++++++++++++++++++++++++++++++++- src/core/config.js | 1 + src/core/render/index.js | 10 +++++++--- 6 files changed, 125 insertions(+), 4 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index 487df25..4b05476 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -267,3 +267,25 @@ window.$docsify = { autoHeader: true } ``` + +## execute-script + +- type: `Boolean` + +Execute the script on the page. Only parse the first script tag([demo](themes)). If Vue is present, it is turned on by default. + +```js +window.$docsify = { + executeScript: true +} +``` + +```markdown +## This is test + + + +``` + diff --git a/docs/themes.md b/docs/themes.md index 67b9a5d..ed5ae40 100644 --- a/docs/themes.md +++ b/docs/themes.md @@ -12,3 +12,37 @@ There are currently three themes available. Copy [Vue](//vuejs.org) and [buble]( !> This compressed files in `/lib/themes/`. If you have any ideas or would like to develop new theme, welcome submit [PR](https://github.com/QingWei-Li/docsify/pulls). + +#### Click to preview + + + + + + + + diff --git a/docs/zh-cn/configuration.md b/docs/zh-cn/configuration.md index 8ab8157..685de3c 100644 --- a/docs/zh-cn/configuration.md +++ b/docs/zh-cn/configuration.md @@ -265,3 +265,25 @@ window.$docsify = { autoHeader: true } ``` + +## execute-script + +- 类型:`Boolean` + +执行文档里的 script 标签里的脚本,只执行第一个 script ([demo](zh-cn/themes))。 如果 Vue 存在,则自动开启。 + +```js +window.$docsify = { + executeScript: true +} +``` + +```markdown +## This is test + + + +``` + diff --git a/docs/zh-cn/themes.md b/docs/zh-cn/themes.md index b728d7a..28596e2 100644 --- a/docs/zh-cn/themes.md +++ b/docs/zh-cn/themes.md @@ -8,6 +8,44 @@ ``` +vue.css +buble.css +dark.css + !> CSS 的压缩文件位于 `/lib/themes/` -如果你有其他想法或者想开发别的主题,欢迎提 [PR](https://github.com/QingWei-Li/docsify/pulls)。 \ No newline at end of file +如果你有其他想法或者想开发别的主题,欢迎提 [PR](https://github.com/QingWei-Li/docsify/pulls)。 + +#### 点击切换主题 + + + + + + + + diff --git a/src/core/config.js b/src/core/config.js index 230348a..f218e6d 100644 --- a/src/core/config.js +++ b/src/core/config.js @@ -15,6 +15,7 @@ const config = merge({ themeColor: '', nameLink: window.location.pathname, autoHeader: false, + executeScript: false, ga: '' }, window.$docsify) diff --git a/src/core/render/index.js b/src/core/render/index.js index 746fdf7..370a570 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -14,7 +14,9 @@ function executeScript () { const code = script.innerText.trim() if (!code) return false - window.__EXECUTE_RESULT__ = new Function('return ' + code)() + setTimeout(_ => { + window.__EXECUTE_RESULT__ = new Function(code)() + }, 0) } function renderMain (html) { @@ -31,11 +33,13 @@ function renderMain (html) { if (!this.config.executeScript && typeof window.Vue !== 'undefined' && !executeScript()) { - window.__EXECUTE_RESULT__ = new window.Vue().$mount('#main') + setTimeout(_ => { + window.__EXECUTE_RESULT__ = new window.Vue().$mount('#main') + }, 0) } if (this.config.auto2top) { - setTimeout(() => scroll2Top(this.config.auto2top), 0) + scroll2Top(this.config.auto2top) } } From 7b6a2ac404110b153b5fc2ee60adf19a0270f22c Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sun, 19 Feb 2017 00:10:38 +0800 Subject: [PATCH 029/746] fix(render): support html file --- src/core/event/scroll.js | 2 +- src/core/fetch/index.js | 7 ++++++- src/core/render/compiler.js | 8 ++++++-- src/core/render/index.js | 20 ++++++++++++++------ src/core/render/tpl.js | 2 +- src/core/route/index.js | 2 +- src/core/route/util.js | 12 ++++++------ 7 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/core/event/scroll.js b/src/core/event/scroll.js index 5cfdb11..6b4eab7 100644 --- a/src/core/event/scroll.js +++ b/src/core/event/scroll.js @@ -9,7 +9,6 @@ export function scrollActiveSidebar () { const anchors = dom.findAll('.anchor') const sidebar = dom.find('.sidebar') const wrap = dom.find(sidebar, '.sidebar-nav') - const height = sidebar.clientHeight const nav = {} const lis = dom.findAll(sidebar, 'li') @@ -54,6 +53,7 @@ export function scrollActiveSidebar () { // scroll into view // https://github.com/vuejs/vuejs.org/blob/master/themes/vue/source/js/common.js#L282-L297 if (!hoverOver && dom.body.classList.contains('sticky')) { + const height = sidebar.clientHeight const curOffset = 0 const cur = active.offsetTop + active.clientHeight + 40 const isInView = ( diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index e3f4c0d..8465449 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -15,6 +15,9 @@ export function fetchMixin (proto) { last = get(this.$getFile(path), true) + // Current page is html + this.isHTML = /\.html$/g.test(path) + // Load main content last.then(text => { this._renderMain(text) @@ -42,13 +45,15 @@ export function fetchMixin (proto) { proto._fetchCover = function () { const { coverpage } = this.config const root = getRoot(this.route.path) + const path = this.$getFile(root + coverpage) if (this.route.path !== '/' || !coverpage) { this._renderCover() return } - get(this.$getFile(root + coverpage)) + this.coverIsHTML = /\.html$/g.test(path) + get(path) .then(text => this._renderCover(text)) } diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 70e8991..d369c1d 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -5,7 +5,7 @@ import { genTree } from './gen-tree' import { slugify, clearSlugCache } from './slugify' import { emojify } from './emojify' import { toURL, parse } from '../route/hash' -import { getBasePath, getPath } from '../route/util' +import { getBasePath, isResolvePath, getPath } from '../route/util' import { isFn, merge, cached } from '../util/core' let markdownCompiler = marked @@ -84,9 +84,13 @@ renderer.paragraph = function (text) { return `

                                        ${text}

                                        ` } renderer.image = function (href, title, text) { - const url = getPath(contentBase, href) + let url = href const titleHTML = title ? ` title="${title}"` : '' + if (!isResolvePath(href)) { + url = getPath(contentBase, href) + } + return `${text}` } diff --git a/src/core/render/index.js b/src/core/render/index.js index 370a570..c8df337 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -5,7 +5,7 @@ import cssVars from '../util/polyfill/css-vars' import * as tpl from './tpl' import { markdown, sidebar, subSidebar, cover } from './compiler' import { callHook } from '../init/lifecycle' -import { getBasePath, getPath } from '../route/util' +import { getBasePath, getPath, isResolvePath } from '../route/util' function executeScript () { const script = dom.findAll('.markdown-section>script') @@ -22,6 +22,7 @@ function executeScript () { function renderMain (html) { if (!html) { // TODO: Custom 404 page + html = 'not found' } this._renderTo('.markdown-section', html) @@ -56,11 +57,13 @@ export function renderMixin (proto) { const active = getAndActive('.sidebar-nav', true, true) subSidebar(active, subMaxLevel) // bind event + this.activeLink = active scrollActiveSidebar() if (autoHeader && active) { const main = dom.getNode('#main') - if (main.children[0].tagName !== 'H1') { + const firstNode = main.children[0] + if (firstNode && firstNode.tagName !== 'H1') { const h1 = dom.create('h1') h1.innerText = active.innerText dom.before(main, h1) @@ -75,7 +78,7 @@ export function renderMixin (proto) { proto._renderMain = function (text) { callHook(this, 'beforeEach', text, result => { - const html = markdown(result) + const html = this.isHTML ? result : markdown(result) callHook(this, 'afterEach', html, text => renderMain.call(this, text)) }) } @@ -88,15 +91,20 @@ export function renderMixin (proto) { } dom.toggleClass(el, 'add', 'show') - let html = cover(text) + let html = this.coverIsHTML ? text : cover(text) const m = html.trim().match('

                                        ([^<]*?)

                                        $') if (m) { if (m[2] === 'color') { el.style.background = m[1] + (m[3] || '') } else { + let path = m[1] + dom.toggleClass(el, 'add', 'has-mask') - el.style.backgroundImage = `url(${getPath(getBasePath(this.config.basePath), m[1])})` + if (isResolvePath(m[1])) { + path = getPath(getBasePath(this.config.basePath), m[1]) + } + el.style.backgroundImage = `url(${path})` } html = html.replace(m[0], '') } @@ -145,7 +153,7 @@ export function initRender (vm) { dom.before(dom.body, navEl) if (config.themeColor) { - dom.$.head += tpl.theme(config.themeColor) + dom.$.head.innerHTML += tpl.theme(config.themeColor) // Polyfll cssVars(config.themeColor) } diff --git a/src/core/render/tpl.js b/src/core/render/tpl.js index 0bd5198..ce9cabb 100644 --- a/src/core/render/tpl.js +++ b/src/core/render/tpl.js @@ -10,7 +10,7 @@ export function corner (data) { data = data.replace(/^git\+/, '') return ( - '' + + `` + '
                                        Please wait...
                                        +``` + +You should set the `data-app` attribute if you changed `el`. + +*index.html* +```html +
                                        Please wait...
                                        + + +``` diff --git a/docs/zh-cn/plugins.md b/docs/zh-cn/plugins.md index 8145f01..aeabf8d 100644 --- a/docs/zh-cn/plugins.md +++ b/docs/zh-cn/plugins.md @@ -61,7 +61,7 @@ docsify 提供了一套插件机制,其中提供的钩子(hook)支持处 ```js window.$docsify = { plugins: [ - function (hook) { + function (hook, vm) { hook.init(function() { // 初始化时调用,只调用一次,没有参数。 }) diff --git a/docs/zh-cn/quickstart.md b/docs/zh-cn/quickstart.md index c4ebc28..5bdaf2d 100644 --- a/docs/zh-cn/quickstart.md +++ b/docs/zh-cn/quickstart.md @@ -59,3 +59,26 @@ docsify serve docs ```bash cd docs && python -m SimpleHTTPServer 3000 ``` + +## Loading 提示 + +初始化时会显示 `Loading...` 内容,你可以自定义提示信息。 + +*index.html* +```html +
                                        加载中
                                        +``` + +如果更改了 `el` 的配置,需要将该元素加上 `data-app` 属性。 + +*index.html* +```html +
                                        加载中
                                        + + +``` + diff --git a/src/themes/basic/_layout.css b/src/themes/basic/_layout.css index d413c10..6241ffd 100644 --- a/src/themes/basic/_layout.css +++ b/src/themes/basic/_layout.css @@ -7,6 +7,23 @@ -webkit-font-smoothing: antialiased; } +body:not(.ready) { + [data-cloak] { + display: none; + } +} + +div#app { + text-align: center; + font-size: 30px; + font-weight: lighter; + margin: 40vw auto; + + &:empty::before { + content: "Loading..."; + } +} + .emoji { height: 1.2em; vertical-align: middle; From 079bd00395b4d5f9644e0ba6066155489de91119 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sun, 19 Feb 2017 10:47:47 +0800 Subject: [PATCH 032/746] refactor(plugins): update search plugin --- .eslintrc | 4 + build/build.js | 24 +-- docs/index.html | 2 +- docs/plugins.md | 2 +- docs/zh-cn/plugins.md | 2 +- package.json | 2 +- src/core/config.js | 2 + src/core/event/scroll.js | 4 +- src/core/fetch/index.js | 5 +- src/core/global-api.js | 2 +- src/core/index.js | 3 +- src/core/init/index.js | 1 - src/core/render/compiler.js | 4 +- src/core/render/index.js | 5 +- src/core/route/hash.js | 1 + src/core/route/index.js | 7 +- src/core/route/util.js | 6 +- src/plugins/ga.js | 13 +- src/plugins/search.js | 349 -------------------------------- src/plugins/search/component.js | 116 +++++++++++ src/plugins/search/index.js | 31 +++ src/plugins/search/search.js | 156 ++++++++++++++ 22 files changed, 348 insertions(+), 393 deletions(-) delete mode 100644 src/plugins/search.js create mode 100644 src/plugins/search/component.js create mode 100644 src/plugins/search/index.js create mode 100644 src/plugins/search/search.js diff --git a/.eslintrc b/.eslintrc index 86d102d..d6a85f8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -2,5 +2,9 @@ "extends": ["vue"], "env": { "browser": true + }, + "globals": { + "Docsify": true, + "$docsify": true } } diff --git a/build/build.js b/build/build.js index 96adf07..ceeb3c3 100644 --- a/build/build.js +++ b/build/build.js @@ -32,26 +32,26 @@ build({ plugins: [commonjs(), nodeResolve()] }) -// build({ -// entry: 'plugins/search.js', -// output: 'plugins/search.js', -// moduleName: 'D.Search' -// }) +build({ + entry: 'plugins/search/index.js', + output: 'plugins/search.js', + moduleName: 'D.Search' +}) -// build({ -// entry: 'plugins/ga.js', -// output: 'plugins/ga.js', -// moduleName: 'D.GA' -// }) +build({ + entry: 'plugins/ga.js', + output: 'plugins/ga.js', + moduleName: 'D.GA' +}) if (isProd) { build({ - entry: 'index.js', + entry: 'core/index.js', output: 'docsify.min.js', plugins: [commonjs(), nodeResolve(), uglify()] }) build({ - entry: 'plugins/search.js', + entry: 'plugins/search/index.js', output: 'plugins/search.min.js', moduleName: 'D.Search', plugins: [uglify()] diff --git a/docs/index.html b/docs/index.html index 7748c82..2b2f9d3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -10,7 +10,7 @@ -