spaCy/website/docs/legacy/resources/js/prism.min.js

3 lines
34 KiB
JavaScript
Raw Normal View History

2016-03-31 14:24:48 +00:00
var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var a={};for(var i in e)e.hasOwnProperty(i)&&(a[i]=t.util.clone(e[i]));return a;case"Array":return e.map&&e.map(function(e){return t.util.clone(e)})}return e}},languages:{extend:function(e,n){var a=t.util.clone(t.languages[e]);for(var i in n)a[i]=n[i];return a},insertBefore:function(e,n,a,i){i=i||t.languages;var r=i[e];if(2==arguments.length){a=arguments[1];for(var s in a)a.hasOwnProperty(s)&&(r[s]=a[s]);return r}var o={};for(var l in r)if(r.hasOwnProperty(l)){if(l==n)for(var s in a)a.hasOwnProperty(s)&&(o[s]=a[s]);o[l]=r[l]}return t.languages.DFS(t.languages,function(t,n){n===i[e]&&t!=e&&(this[t]=o)}),i[e]=o},DFS:function(e,n,a){for(var i in e)e.hasOwnProperty(i)&&(n.call(e,i,e[i],a||i),"Object"===t.util.type(e[i])?t.languages.DFS(e[i],n):"Array"===t.util.type(e[i])&&t.languages.DFS(e[i],n,i))}},highlightAll:function(e,n){for(var a,i=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'),r=0;a=i[r++];)t.highlightElement(a,e===!0,n)},highlightElement:function(a,i,r){for(var s,o,l=a;l&&!e.test(l.className);)l=l.parentNode;l&&(s=(l.className.match(e)||[,""])[1],o=t.languages[s]),a.className=a.className.replace(e,"").replace(/\s+/g," ")+" language-"+s,l=a.parentNode,/pre/i.test(l.nodeName)&&(l.className=l.className.replace(e,"").replace(/\s+/g," ")+" language-"+s);var u=a.textContent,p={element:a,language:s,grammar:o,code:u};if(u&&(p.code=u.replace(/^(?:\r?\n|\r)/,"")),!u||!o)return void t.hooks.run("complete",p);if(t.hooks.run("before-highlight",p),i&&_self.Worker){var c=new Worker(t.filename);c.onmessage=function(e){p.highlightedCode=n.stringify(JSON.parse(e.data),s),t.hooks.run("before-insert",p),p.element.innerHTML=p.highlightedCode,r&&r.call(p.element),t.hooks.run("after-highlight",p),t.hooks.run("complete",p)},c.postMessage(JSON.stringify({language:p.language,code:p.code}))}else p.highlightedCode=t.highlight(p.code,p.grammar,p.language),t.hooks.run("before-insert",p),p.element.innerHTML=p.highlightedCode,r&&r.call(a),t.hooks.run("after-highlight",p),t.hooks.run("complete",p)},highlight:function(e,a,i){var r=t.tokenize(e,a);return n.stringify(t.util.encode(r),i)},tokenize:function(e,n,a){var i=t.Token,r=[e],s=n.rest;if(s){for(var o in s)n[o]=s[o];delete n.rest}e:for(var o in n)if(n.hasOwnProperty(o)&&n[o]){var l=n[o];l="Array"===t.util.type(l)?l:[l];for(var u=0;u<l.length;++u){var p=l[u],c=p.inside,d=!!p.lookbehind,g=0,m=p.alias;p=p.pattern||p;for(var E=0;E<r.length;E++){var h=r[E];if(r.length>e.length)break e;if(!(h instanceof i)){p.lastIndex=0;var f=p.exec(h);if(f){d&&(g=f[1].length);var b=f.index-1+g,f=f[0].slice(g),T=f.length,S=b+T,P=h.slice(0,b+1),k=h.slice(S+1),I=[E,1];P&&I.push(P);var A=new i(o,c?t.tokenize(f,c):f,m);I.push(A),k&&I.push(k),Array.prototype.splice.apply(r,I)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var i,r=0;i=a[r++];)i(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,i){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var r={type:e.type,content:n.stringify(e.content,a,i),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:i};if("comment"==r.type&&(r.attributes.spellcheck="true"),e.alias){var s="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(r.classes,s)}t.hooks.run("wrap",r);var o="";for(var l in r.attributes)
"boolean":/\b(?:TRUE|FALSE|NULL)\b/i,number:/\b-?(0x)?\d*\.?[\da-f]+\b/,operator:/\b(?:ALL|AND|ANY|BETWEEN|EXISTS|IN|LIKE|NOT|OR|IS|UNIQUE|CHARACTER SET|COLLATE|DIV|OFFSET|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b|[-+]|!|[=<>]{1,2}|(&){1,2}|\|?\||\?|\*|\//i,punctuation:/[;[\]()`,.]/},Prism.languages.wiki=Prism.languages.extend("markup",{"block-comment":{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0,alias:"comment"},heading:{pattern:/^(=+).+?\1/m,inside:{punctuation:/^=+|=+$/,important:/.+/}},emphasis:{pattern:/('{2,4}).+?\1/,inside:{"bold italic":{pattern:/('''').+?(?=\1)/,lookbehind:!0},bold:{pattern:/(''').+?(?=\1)/,lookbehind:!0},italic:{pattern:/('').+?(?=\1)/,lookbehind:!0},punctuation:/^''+|''+$/}},hr:{pattern:/^-{4,}/m,alias:"punctuation"},url:[/ISBN +(?:97[89][ -]?)?(?:\d[ -]?){9}[\dx]\b/i,/(?:RFC|PMID) +\d+/,/\[\[.+?\]\]/,/\[.+?\]/],variable:[/__[A-Z]+__/,/\{{3}.+?\}{3}/,/\{\{.+?}}/],symbol:[/^#redirect/im,/~{3,5}/],"table-tag":{pattern:/((?:^|[|!])[|!])[^|\r\n]+\|(?!\|)/m,lookbehind:!0,inside:{"table-bar":{pattern:/\|$/,alias:"punctuation"},rest:Prism.languages.markup.tag.inside}},punctuation:/^(?:\{\||\|\}|\|-|[*#:;!|])|\|\||!!/m}),Prism.languages.insertBefore("wiki","tag",{nowiki:{pattern:/<(nowiki|pre|source)\b[\w\W]*?>[\w\W]*?<\/\1>/i,inside:{tag:{pattern:/<(?:nowiki|pre|source)\b[\w\W]*?>|<\/(?:nowiki|pre|source)>/i,inside:Prism.languages.markup.tag.inside}}}});