WokerTask/public/admin/assets/highlight.js.dba6fa1b.js

3 lines
20 KiB
JavaScript
Raw Permalink Normal View History

2023-12-27 14:06:33 +08:00
var te={exports:{}};function ne(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(function(t){var i=e[t];typeof i=="object"&&!Object.isFrozen(i)&&ne(i)}),e}te.exports=ne;te.exports.default=ne;class de{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function xe(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function v(e,...t){const i=Object.create(null);for(const f in e)i[f]=e[f];return t.forEach(function(f){for(const b in f)i[b]=f[b]}),i}const Je="</span>",pe=e=>!!e.scope||e.sublanguage&&e.language,Ve=(e,{prefix:t})=>{if(e.includes(".")){const i=e.split(".");return[`${t}${i.shift()}`,...i.map((f,b)=>`${f}${"_".repeat(b+1)}`)].join(" ")}return`${t}${e}`};class qe{constructor(t,i){this.buffer="",this.classPrefix=i.classPrefix,t.walk(this)}addText(t){this.buffer+=xe(t)}openNode(t){if(!pe(t))return;let i="";t.sublanguage?i=`language-${t.language}`:i=Ve(t.scope,{prefix:this.classPrefix}),this.span(i)}closeNode(t){!pe(t)||(this.buffer+=Je)}value(){return this.buffer}span(t){this.buffer+=`<span class="${t}">`}}const Ee=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class ie{constructor(){this.rootNode=Ee(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(t){this.top.children.push(t)}openNode(t){const i=Ee({scope:t});this.add(i),this.stack.push(i)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(t){return this.constructor._walk(t,this.rootNode)}static _walk(t,i){return typeof i=="string"?t.addText(i):i.children&&(t.openNode(i),i.children.forEach(f=>this._walk(t,f)),t.closeNode(i)),t}static _collapse(t){typeof t!="string"&&(!t.children||(t.children.every(i=>typeof i=="string")?t.children=[t.children.join("")]:t.children.forEach(i=>{ie._collapse(i)})))}}class Qe extends ie{constructor(t){super(),this.options=t}addKeyword(t,i){t!==""&&(this.openNode(i),this.addText(t),this.closeNode())}addText(t){t!==""&&this.add(t)}addSublanguage(t,i){const f=t.root;f.sublanguage=!0,f.language=i,this.add(f)}toHTML(){return new qe(this,this.options).value()}finalize(){return!0}}function j(e){return e?typeof e=="string"?e:e.source:null}function Oe(e){return L("(?=",e,")")}function me(e){return L("(?:",e,")*")}function et(e){return L("(?:",e,")?")}function L(...e){return e.map(i=>j(i)).join("")}function tt(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function se(...e){return"("+(tt(e).capture?"":"?:")+e.map(f=>j(f)).join("|")+")"}function ye(e){return new RegExp(e.toString()+"|").exec("").length-1}function nt(e,t){const i=e&&e.exec(t);return i&&i.index===0}const it=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function re(e,{joinWith:t}){let i=0;return e.map(f=>{i+=1;const b=i;let _=j(f),c="";for(;_.length>0;){const r=it.exec(_);if(!r){c+=_;break}c+=_.substring(0,r.index),_=_.substring(r.index+r[0].length),r[0][0]==="\\"&&r[1]?c+="\\"+String(Number(r[1])+b):(c+=r[0],r[0]==="("&&i++)}return c}).map(f=>`(${f})`).join(t)}const st=/\b\B/,Re="[a-zA-Z]\\w*",ce="[a-zA-Z_]\\w*",Se="\\b\\d+(\\.\\d+)?",Ne="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Ae="\\b(0b[01]+)",rt="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ct=(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=L(t,/.*\b/,e.binary,/\b.*/)),v({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(i,f)=>{i.index!==0&&f.ignoreMatch()}},e)},P={begin:"\\\\[\\s\\S]",relevance:0},ot={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[P]},at={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[
https://github.com/highlightjs/highlight.js/issues/2277`),M=n,p=a),h===void 0&&(h=!0);const S={code:p,language:M};G("before:highlight",S);const k=S.result?S.result:H(S.language,S.code,h);return k.code=S.code,G("after:highlight",k),k}function H(n,a,h,p){const M=Object.create(null);function S(s,o){return s.keywords[o]}function k(){if(!u.keywords){O.addText(E);return}let s=0;u.keywordPatternRe.lastIndex=0;let o=u.keywordPatternRe.exec(E),g="";for(;o;){g+=E.substring(s,o.index);const d=I.case_insensitive?o[0].toLowerCase():o[0],y=S(u,d);if(y){const[N,Ye]=y;if(O.addText(g),g="",M[d]=(M[d]||0)+1,M[d]<=$t&&(z+=Ye),N.startsWith("_"))g+=o[0];else{const Ze=I.classNameAliases[N]||N;O.addKeyword(o[0],Ze)}}else g+=o[0];s=u.keywordPatternRe.lastIndex,o=u.keywordPatternRe.exec(E)}g+=E.substring(s),O.addText(g)}function K(){if(E==="")return;let s=null;if(typeof u.subLanguage=="string"){if(!t[u.subLanguage]){O.addText(E);return}s=H(u.subLanguage,E,!0,he[u.subLanguage]),he[u.subLanguage]=s._top}else s=J(E,u.subLanguage.length?u.subLanguage:null);u.relevance>0&&(z+=s.relevance),O.addSublanguage(s._emitter,s.language)}function R(){u.subLanguage!=null?K():k(),E=""}function T(s,o){let g=1;const d=o.length-1;for(;g<=d;){if(!s._emit[g]){g++;continue}const y=I.classNameAliases[s[g]]||s[g],N=o[g];y?O.addKeyword(N,y):(E=N,k(),E=""),g++}}function ue(s,o){return s.scope&&typeof s.scope=="string"&&O.openNode(I.classNameAliases[s.scope]||s.scope),s.beginScope&&(s.beginScope._wrap?(O.addKeyword(E,I.classNameAliases[s.beginScope._wrap]||s.beginScope._wrap),E=""):s.beginScope._multi&&(T(s.beginScope,o),E="")),u=Object.create(s,{parent:{value:u}}),u}function fe(s,o,g){let d=nt(s.endRe,g);if(d){if(s["on:end"]){const y=new de(s);s["on:end"](o,y),y.isMatchIgnored&&(d=!1)}if(d){for(;s.endsParent&&s.parent;)s=s.parent;return s}}if(s.endsWithParent)return fe(s.parent,o,g)}function Ke(s){return u.matcher.regexIndex===0?(E+=s[0],1):(m=!0,0)}function We(s){const o=s[0],g=s.rule,d=new de(g),y=[g.__beforeBegin,g["on:begin"]];for(const N of y)if(!!N&&(N(s,d),d.isMatchIgnored))return Ke(o);return g.skip?E+=o:(g.excludeBegin&&(E+=o),R(),!g.returnBegin&&!g.excludeBegin&&(E=o)),ue(g,s),g.returnBegin?0:o.length}function ze(s){const o=s[0],g=a.substring(s.index),d=fe(u,s,g);if(!d)return Me;const y=u;u.endScope&&u.endScope._wrap?(R(),O.addKeyword(o,u.endScope._wrap)):u.endScope&&u.endScope._multi?(R(),T(u.endScope,s)):y.skip?E+=o:(y.returnEnd||y.excludeEnd||(E+=o),R(),y.excludeEnd&&(E=o));do u.scope&&O.closeNode(),!u.skip&&!u.subLanguage&&(z+=u.relevance),u=u.parent;while(u!==d.parent);return d.starts&&ue(d.starts,s),y.returnEnd?0:o.length}function Fe(){const s=[];for(let o=u;o!==I;o=o.parent)o.scope&&s.unshift(o.scope);s.forEach(o=>O.openNode(o))}let W={};function ge(s,o){const g=o&&o[0];if(E+=s,g==null)return R(),0;if(W.type==="begin"&&o.type==="end"&&W.index===o.index&&g===""){if(E+=a.slice(o.index,o.index+1),!b){const d=new Error(`0 width match regex (${n})`);throw d.languageName=n,d.badRule=W.rule,d}return 1}if(W=o,o.type==="begin")return We(o);if(o.type==="illegal"&&!h){const d=new Error('Illegal lexeme "'+g+'" for mode "'+(u.scope||"<unnamed>")+'"');throw d.mode=u,d}else if(o.type==="end"){const d=ze(o);if(d!==Me)return d}if(o.type==="illegal"&&g==="")return 1;if(Q>1e5&&Q>o.index*3)throw new Error("potential infinite loop, way more iterations than matches");return E+=g,g.length}const I=A(n);if(!I)throw D(_.replace("{}",n)),new Error('Unknown language: "'+n+'"');const Xe=Ht(I);let q="",u=p||Xe;const he={},O=new r.__emitter(r);Fe();let E="",z=0,B=0,Q=0,m=!1;try{for(u.matcher.considerAll();;){Q++,m?m=!1:u.matcher.considerAll(),u.matcher.lastIndex=B;const s=u.matcher.exec(a);if(!s)break;const o=a.substring(B,s.index),g=ge(o,s);B=s.index+g}return ge(a.substring(B)),O.closeAllNodes(),O.finalize(),q=O.toHTML(),{language:n,value:q,relevance:z,illegal:!1,_emitter:O,_top:u}}catch(s){if(s.message&&s.message.includes("Illegal"))return{language:n,value:ee(a),illegal:!0,relevance:0,_illegalBy:{message:s.message,index:B,context:a.slice(B-100,B+100),mode:s.mode,resultSoFar:q},_emit