1 line
9.3 KiB
JavaScript
1 line
9.3 KiB
JavaScript
!function(e){var n="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):n&&(n.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return n.hljs}))}(function(r){var f=[],c=Object.keys,b={},d={},n=/^(no-?highlight|plain|text)$/i,E=/\blang(?:uage)?-([\w-]+)\b/i,t=/((^(<[^>]+>|\t|)+|(?:\n)))/gm,h="</span>",R={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0};function _(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function v(e){return e.nodeName.toLowerCase()}function N(e,n){var t=e&&e.exec(n);return t&&0===t.index}function m(e){return n.test(e)}function u(e){var n,t={},a=Array.prototype.slice.call(arguments,1);for(n in e)t[n]=e[n];return a.forEach(function(e){for(n in e)t[n]=e[n]}),t}function p(e){var r=[];return function e(n,t){for(var a=n.firstChild;a;a=a.nextSibling)3===a.nodeType?t+=a.nodeValue.length:1===a.nodeType&&(r.push({event:"start",offset:t,node:a}),t=e(a,t),v(a).match(/br|hr|img|input/)||r.push({event:"stop",offset:t,node:a}));return t}(e,0),r}function w(s){function o(e){return e&&e.source||e}function l(e,n){return new RegExp(o(e),"m"+(s.case_insensitive?"i":"")+(n?"g":""))}!function n(t,e){if(!t.compiled){if(t.compiled=!0,t.keywords=t.keywords||t.beginKeywords,t.keywords){var a={},r=function(t,e){s.case_insensitive&&(e=e.toLowerCase()),e.split(" ").forEach(function(e){var n=e.split("|");a[n[0]]=[t,n[1]?Number(n[1]):1]})};"string"==typeof t.keywords?r("keyword",t.keywords):c(t.keywords).forEach(function(e){r(e,t.keywords[e])}),t.keywords=a}t.lexemesRe=l(t.lexemes||/\w+/,!0),e&&(t.beginKeywords&&(t.begin="\\b("+t.beginKeywords.split(" ").join("|")+")\\b"),t.begin||(t.begin=/\B|\b/),t.beginRe=l(t.begin),t.endSameAsBegin&&(t.end=t.begin),t.end||t.endsWithParent||(t.end=/\B|\b/),t.end&&(t.endRe=l(t.end)),t.terminator_end=o(t.end)||"",t.endsWithParent&&e.terminator_end&&(t.terminator_end+=(t.end?"|":"")+e.terminator_end)),t.illegal&&(t.illegalRe=l(t.illegal)),null==t.relevance&&(t.relevance=1),t.contains||(t.contains=[]),t.contains=Array.prototype.concat.apply([],t.contains.map(function(e){return(n="self"===e?t:e).variants&&!n.cached_variants&&(n.cached_variants=n.variants.map(function(e){return u(n,{variants:null},e)})),n.cached_variants||n.endsWithParent&&[u(n)]||[n];var n})),t.contains.forEach(function(e){n(e,t)}),t.starts&&n(t.starts,e);var i=t.contains.map(function(e){return e.beginKeywords?"\\.?("+e.begin+")\\.?":e.begin}).concat([t.terminator_end,t.illegal]).map(o).filter(Boolean);t.terminators=i.length?l(i.join("|"),!0):{exec:function(){return null}}}}(s)}function M(e,n,o,t){function l(e,n,t,a){var r='<span class="'+(a?"":R.classPrefix);return(r+=e+'">')+n+(t?"":h)}function c(){d+=null!=f.subLanguage?function(){var e="string"==typeof f.subLanguage;if(e&&!b[f.subLanguage])return _(E);var n=e?M(f.subLanguage,E,!0,i[f.subLanguage]):x(E,f.subLanguage.length?f.subLanguage:void 0);return 0<f.relevance&&(v+=n.relevance),e&&(i[f.subLanguage]=n.top),l(n.language,n.value,!1,!0)}():function(){var e,n,t,a,r,i,s;if(!f.keywords)return _(E);for(a="",n=0,f.lexemesRe.lastIndex=0,t=f.lexemesRe.exec(E);t;)a+=_(E.substring(n,t.index)),r=f,i=t,s=g.case_insensitive?i[0].toLowerCase():i[0],(e=r.keywords.hasOwnProperty(s)&&r.keywords[s])?(v+=e[1],a+=l(e[0],_(t[0]))):a+=_(t[0]),n=f.lexemesRe.lastIndex,t=f.lexemesRe.exec(E);return a+_(E.substr(n))}(),E=""}function u(e){d+=e.className?l(e.className,"",!0):"",f=Object.create(e,{parent:{value:f}})}function a(e,n){if(E+=e,null==n)return c(),0;var t=function(e,n){var t,a,r;for(t=0,a=n.contains.length;t<a;t++)if(N(n.contains[t].beginRe,e))return n.contains[t].endSameAsBegin&&(n.contains[t].endRe=(r=n.contains[t].beginRe.exec(e)[0],new RegExp(r.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"m"))),n.contains[t]}(n,f);if(t)return t.skip?E+=n:(t.excludeBegin&&(E+=n),c(),t.returnBegin||t.excludeBegin||(E=n)),u(t),t.returnBegin?0:n.length;var a,r,i=function e(n,t){if(N(n.endRe,t)){for(;n.endsParent&&n.parent;)n=n.parent;return n}if(n.endsWithParent)return e(n.parent,t)}(f,n);if(i){var s=f;for(s.skip?E+=n:(s.returnEnd||s.excludeEnd||(E+=n),c(),s.excludeEnd&&(E=n));f.className&&(d+=h),f.skip||f.subLanguage||(v+=f.relevance),(f=f.parent)!==i.parent;);return i.starts&&(i.endSameAsBegin&&(i.starts.endRe=i.endRe),u(i.starts)),s.returnEnd?0:n.length}if(a=n,r=f,!o&&N(r.illegalRe,a))throw new Error('Illegal lexeme "'+n+'" for mode "'+(f.className||"<unnamed>")+'"');return E+=n,n.length||1}var g=y(e);if(!g)throw new Error('Unknown language: "'+e+'"');w(g);var r,f=t||g,i={},d="";for(r=f;r!==g;r=r.parent)r.className&&(d=l(r.className,"",!0)+d);var E="",v=0;try{for(var s,m,p=0;f.terminators.lastIndex=p,s=f.terminators.exec(n);)m=a(n.substring(p,s.index),s[0]),p=s.index+m;for(a(n.substr(p)),r=f;r.parent;r=r.parent)r.className&&(d+=h);return{relevance:v,value:d,language:e,top:f}}catch(e){if(e.message&&-1!==e.message.indexOf("Illegal"))return{relevance:0,value:_(n)};throw e}}function x(t,e){e=e||R.languages||c(b);var a={relevance:0,value:_(t)},r=a;return e.filter(y).filter(s).forEach(function(e){var n=M(e,t,!1);n.language=e,n.relevance>r.relevance&&(r=n),n.relevance>a.relevance&&(r=a,a=n)}),r.language&&(a.second_best=r),a}function O(e){return R.tabReplace||R.useBR?e.replace(t,function(e,n){return R.useBR&&"\n"===e?"<br>":R.tabReplace?n.replace(/\t/g,R.tabReplace):""}):e}function a(e){var n,t,a,r,i,s,o,l,c,u,g=function(e){var n,t,a,r,i=e.className+" ";if(i+=e.parentNode?e.parentNode.className:"",t=E.exec(i))return y(t[1])?t[1]:"no-highlight";for(n=0,a=(i=i.split(/\s+/)).length;n<a;n++)if(m(r=i[n])||y(r))return r}(e);m(g)||(R.useBR?(n=document.createElementNS("http://www.w3.org/1999/xhtml","div")).innerHTML=e.innerHTML.replace(/\n/g,"").replace(/<br[ \/]*>/g,"\n"):n=e,i=n.textContent,a=g?M(g,i,!0):x(i),(t=p(n)).length&&((r=document.createElementNS("http://www.w3.org/1999/xhtml","div")).innerHTML=a.value,a.value=function(e,n,t){var a=0,r="",i=[];function s(){return e.length&&n.length?e[0].offset!==n[0].offset?e[0].offset<n[0].offset?e:n:"start"===n[0].event?e:n:e.length?e:n}function o(e){r+="<"+v(e)+f.map.call(e.attributes,function(e){return" "+e.nodeName+'="'+_(e.value).replace('"',""")+'"'}).join("")+">"}function l(e){r+="</"+v(e)+">"}function c(e){("start"===e.event?o:l)(e.node)}for(;e.length||n.length;){var u=s();if(r+=_(t.substring(a,u[0].offset)),a=u[0].offset,u===e){for(i.reverse().forEach(l);c(u.splice(0,1)[0]),(u=s())===e&&u.length&&u[0].offset===a;);i.reverse().forEach(o)}else"start"===u[0].event?i.push(u[0].node):i.pop(),c(u.splice(0,1)[0])}return r+_(t.substr(a))}(t,p(r),i)),a.value=O(a.value),e.innerHTML=a.value,e.className=(s=e.className,o=g,l=a.language,c=o?d[o]:l,u=[s.trim()],s.match(/\bhljs\b/)||u.push("hljs"),-1===s.indexOf(c)&&u.push(c),u.join(" ").trim()),e.result={language:a.language,re:a.relevance},a.second_best&&(e.second_best={language:a.second_best.language,re:a.second_best.relevance}))}function i(){if(!i.called){i.called=!0;var e=document.querySelectorAll("pre code");f.forEach.call(e,a)}}function y(e){return e=(e||"").toLowerCase(),b[e]||b[d[e]]}function s(e){var n=y(e);return n&&!n.disableAutodetect}return r.highlight=M,r.highlightAuto=x,r.fixMarkup=O,r.highlightBlock=a,r.configure=function(e){R=u(R,e)},r.initHighlighting=i,r.initHighlightingOnLoad=function(){addEventListener("DOMContentLoaded",i,!1),addEventListener("load",i,!1)},r.registerLanguage=function(n,e){var t=b[n]=e(r);t.aliases&&t.aliases.forEach(function(e){d[e]=n})},r.listLanguages=function(){return c(b)},r.getLanguage=y,r.autoDetection=s,r.inherit=u,r.IDENT_RE="[a-zA-Z]\\w*",r.UNDERSCORE_IDENT_RE="[a-zA-Z_]\\w*",r.NUMBER_RE="\\b\\d+(\\.\\d+)?",r.C_NUMBER_RE="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",r.BINARY_NUMBER_RE="\\b(0b[01]+)",r.RE_STARTERS_RE="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",r.BACKSLASH_ESCAPE={begin:"\\\\[\\s\\S]",relevance:0},r.APOS_STRING_MODE={className:"string",begin:"'",end:"'",illegal:"\\n",contains:[r.BACKSLASH_ESCAPE]},r.QUOTE_STRING_MODE={className:"string",begin:'"',end:'"',illegal:"\\n",contains:[r.BACKSLASH_ESCAPE]},r.PHRASAL_WORDS_MODE={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},r.COMMENT=function(e,n,t){var a=r.inherit({className:"comment",begin:e,end:n,contains:[]},t||{});return a.contains.push(r.PHRASAL_WORDS_MODE),a.contains.push({className:"doctag",begin:"(?:TODO|FIXME|NOTE|BUG|XXX):",relevance:0}),a},r.C_LINE_COMMENT_MODE=r.COMMENT("//","$"),r.C_BLOCK_COMMENT_MODE=r.COMMENT("/\\*","\\*/"),r.HASH_COMMENT_MODE=r.COMMENT("#","$"),r.NUMBER_MODE={className:"number",begin:r.NUMBER_RE,relevance:0},r.C_NUMBER_MODE={className:"number",begin:r.C_NUMBER_RE,relevance:0},r.BINARY_NUMBER_MODE={className:"number",begin:r.BINARY_NUMBER_RE,relevance:0},r.CSS_NUMBER_MODE={className:"number",begin:r.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},r.REGEXP_MODE={className:"regexp",begin:/\//,end:/\/[gimuy]*/,illegal:/\n/,contains:[r.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[r.BACKSLASH_ESCAPE]}]},r.TITLE_MODE={className:"title",begin:r.IDENT_RE,relevance:0},r.UNDERSCORE_TITLE_MODE={className:"title",begin:r.UNDERSCORE_IDENT_RE,relevance:0},r.METHOD_GUARD={begin:"\\.\\s*"+r.UNDERSCORE_IDENT_RE,relevance:0},r}); |