docsify/lib/docsify.min.js

2 lines
30 KiB
JavaScript
Raw Normal View History

2016-11-28 12:23:43 +08:00
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Docsify=t()}(this,function(){"use strict";function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e){function t(){for(var e=0,t=r.length;e<t;e+=1){var n=r[e].parentNode,s=n.getBoundingClientRect();if(s.top<10&&s.bottom>10){var o=i[n.id];if(!o)return;if(o===a)return;return a&&a.setAttribute("class",""),o.setAttribute("class","active"),void(a=o)}}}function n(){var e=window.location.hash.slice(1);if(e){var t=document.querySelector("#"+e);t&&t.scrollIntoView()}}if(!/mobile/i.test(navigator.userAgent)&&!e){for(var r=document.querySelectorAll(".anchor"),i={},s=document.querySelectorAll(".sidebar li"),a=null,o=0,l=s.length;o<l;o+=1){var u=s[o],c=u.querySelector("a");i[c.getAttribute("href").slice(1)]=u}document.querySelector("main .content").addEventListener("scroll",t),t(),window.addEventListener("hashchange",n),n()}}var n=function(e,t){void 0===t&&(t={});var n=new XMLHttpRequest;return n.open(t.method||"get",e),n.send(),{then:function(e){return n.addEventListener("load",e)},catch:function(e){return n.addEventListener("error",e)}}},r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i=e(function(e,t){(function(){function n(e){this.tokens=[],this.tokens.links={},this.options=e||p.defaults,this.rules=h.normal,this.options.gfm&&(this.options.tables?this.rules=h.tables:this.rules=h.gfm)}function r(e,t){if(this.options=t||p.defaults,this.links=e,this.rules=g.normal,this.renderer=this.options.renderer||new i,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=g.breaks:this.rules=g.gfm:this.options.pedantic&&(this.rules=g.pedantic)}function i(e){this.options=e||{}}function s(e){this.tokens=[],this.token=null,this.options=e||p.defaults,this.options.renderer=this.options.renderer||new i,this.renderer=this.options.renderer,this.renderer.options=this.options}function a(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function o(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 l(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 u(){}function c(e){for(var t,n,r=arguments,i=1;i<arguments.length;i++){t=r[i];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}function p(e,t,r){if(r||"function"==typeof t){r||(r=t,t=null),t=c({},p.defaults,t||{});var i,o,l=t.highlight,u=0;try{i=n.lex(e,t)}catch(e){return r(e)}o=i.length;var h=function(e){if(e)return t.highlight=l,r(e);var n;try{n=s.parse(i,t)}catch(t){e=t}return t.highlight=l,e?r(e):r(null,n)};if(!l||l.length<3)return h();if(delete t.highlight,!o)return h();for(;u<i.length;u++)!function(e){return"code"!==e.type?--o||h():l(e.text,e.lang,function(t,n){return t?h(t):null==n||n===e.text?--o||h():(e.text=n,e.escaped=!0,void(--o||h()))})}(i[u])}else try{return t&&(t=c({},p.defaults,t)),s.parse(n.lex(e,t),t)}catch(e){if(e.message+="\nPlease report this to https://github.com/chjj/marked.",(t||p.defaults).silent)return"<p>An error occured:</p><pre>"+a(e.message+"",!0)+"</pre>";throw e}}var h={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:u,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:u,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:u,paragraph:/^((?:[^\n]+\n?(?!hr|heading|