tera/Source/HTML/JS/highlight.js

1 line
9.3 KiB
JavaScript
Raw Normal View History

2019-02-10 19:53:54 +00:00
!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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}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