| 185 | r=e,n=t),void 0===a&&(a=!0);const i={code:n,language:r};I("before:highlight",i) |
| 186 | ;const s=i.result?i.result:T(i.language,i.code,a) |
| 187 | ;return s.code=i.code,I("after:highlight",s),s}function T(e,t,r,i){ |
| 188 | const l=Object.create(null);function _(){if(!h.keywords)return void A.addText(v) |
| 189 | ;let e=0;h.keywordPatternRe.lastIndex=0;let t=h.keywordPatternRe.exec(v),a="" |
| 190 | ;for(;t;){a+=v.substring(e,t.index) |
| 191 | ;const r=R.case_insensitive?t[0].toLowerCase():t[0],i=(n=r,h.keywords[n]);if(i){ |
| 192 | const[e,n]=i |
| 193 | ;if(A.addText(a),a="",l[r]=(l[r]||0)+1,l[r]<=7&&(y+=n),e.startsWith("_"))a+=t[0];else{ |
| 194 | const a=R.classNameAliases[e]||e;A.addKeyword(t[0],a)}}else a+=t[0] |
| 195 | ;e=h.keywordPatternRe.lastIndex,t=h.keywordPatternRe.exec(v)}var n |
| 196 | ;a+=v.substring(e),A.addText(a)}function d(){null!=h.subLanguage?(()=>{ |
| 197 | if(""===v)return;let e=null;if("string"==typeof h.subLanguage){ |
| 198 | if(!n[h.subLanguage])return void A.addText(v) |
| 199 | ;e=T(h.subLanguage,v,!0,I[h.subLanguage]),I[h.subLanguage]=e._top |
| 200 | }else e=b(v,h.subLanguage.length?h.subLanguage:null) |
| 201 | ;h.relevance>0&&(y+=e.relevance),A.addSublanguage(e._emitter,e.language) |
| 202 | })():_(),v=""}function m(e,t){let a=1;const n=t.length-1;for(;a<=n;){ |
| 203 | if(!e._emit[a]){a++;continue}const n=R.classNameAliases[e[a]]||e[a],r=t[a] |
| 204 | ;n?A.addKeyword(r,n):(v=r,_(),v=""),a++}}function p(e,t){ |
| 205 | return e.scope&&"string"==typeof e.scope&&A.openNode(R.classNameAliases[e.scope]||e.scope), |
| 206 | e.beginScope&&(e.beginScope._wrap?(A.addKeyword(v,R.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap), |
| 207 | v=""):e.beginScope._multi&&(m(e.beginScope,t),v="")),h=Object.create(e,{parent:{ |
| 208 | value:h}}),h}function u(e,t,n){let r=((e,t)=>{const a=e&&e.exec(t) |
| 209 | ;return a&&0===a.index})(e.endRe,n);if(r){if(e["on:end"]){const n=new a(e) |
| 210 | ;e["on:end"](t,n),n.isMatchIgnored&&(r=!1)}if(r){ |
| 211 | for(;e.endsParent&&e.parent;)e=e.parent;return e}} |
| 212 | if(e.endsWithParent)return u(e.parent,t,n)}function E(e){ |
| 213 | return 0===h.matcher.regexIndex?(v+=e[0],1):(L=!0,0)}function g(e){ |
| 214 | const a=e[0],n=t.substring(e.index),r=u(h,e,n);if(!r)return te;const i=h |
| 215 | ;h.endScope&&h.endScope._wrap?(d(), |
| 216 | A.addKeyword(a,h.endScope._wrap)):h.endScope&&h.endScope._multi?(d(), |
| 217 | m(h.endScope,e)):i.skip?v+=a:(i.returnEnd||i.excludeEnd||(v+=a), |
| 218 | d(),i.excludeEnd&&(v=a));do{ |
| 219 | h.scope&&A.closeNode(),h.skip||h.subLanguage||(y+=h.relevance),h=h.parent |
| 220 | }while(h!==r.parent);return r.starts&&p(r.starts,e),i.returnEnd?0:a.length} |
| 221 | let S={};function C(n,i){const o=i&&i[0];if(v+=n,null==o)return d(),0 |
| 222 | ;if("begin"===S.type&&"end"===i.type&&S.index===i.index&&""===o){ |
| 223 | if(v+=t.slice(i.index,i.index+1),!s){const t=Error(`0 width match regex (${e})`) |
| 224 | ;throw t.languageName=e,t.badRule=S.rule,t}return 1} |
| 225 | if(S=i,"begin"===i.type)return(e=>{ |
| 226 | const t=e[0],n=e.rule,r=new a(n),i=[n.__beforeBegin,n["on:begin"]] |
| 227 | ;for(const a of i)if(a&&(a(e,r),r.isMatchIgnored))return E(t) |
| 228 | ;return n.skip?v+=t:(n.excludeBegin&&(v+=t), |
| 229 | d(),n.returnBegin||n.excludeBegin||(v=t)),p(n,e),n.returnBegin?0:t.length})(i) |
| 230 | ;if("illegal"===i.type&&!r){ |
| 231 | const e=Error('Illegal lexeme "'+o+'" for mode "'+(h.scope||"<unnamed>")+'"') |
| 232 | ;throw e.mode=h,e}if("end"===i.type){const e=g(i);if(e!==te)return e} |
| 233 | if("illegal"===i.type&&""===o)return 1 |
| 234 | ;if(M>1e5&&M>3*i.index)throw Error("potential infinite loop, way more iterations than matches") |
| 235 | ;return v+=o,o.length}const R=O(e) |
| 236 | ;if(!R)throw q(o.replace("{}",e)),Error('Unknown language: "'+e+'"') |
| 237 | ;const N=j(R);let f="",h=i||N;const I={},A=new c.__emitter(c);(()=>{const e=[] |
| 238 | ;for(let t=h;t!==R;t=t.parent)t.scope&&e.unshift(t.scope) |
| 239 | ;e.forEach((e=>A.openNode(e)))})();let v="",y=0,D=0,M=0,L=!1;try{ |
| 240 | for(h.matcher.considerAll();;){ |
| 241 | M++,L?L=!1:h.matcher.considerAll(),h.matcher.lastIndex=D |
| 242 | ;const e=h.matcher.exec(t);if(!e)break;const a=C(t.substring(D,e.index),e) |
| 243 | ;D=e.index+a} |
| 244 | return C(t.substring(D)),A.closeAllNodes(),A.finalize(),f=A.toHTML(),{ |