5 lines
144 KiB
JavaScript
5 lines
144 KiB
JavaScript
|
var un={exports:{}};function gn(n){return n instanceof Map?n.clear=n.delete=n.set=function(){throw new Error("map is read-only")}:n instanceof Set&&(n.add=n.clear=n.delete=function(){throw new Error("set is read-only")}),Object.freeze(n),Object.getOwnPropertyNames(n).forEach(function(e){var t=n[e];typeof t=="object"&&!Object.isFrozen(t)&&gn(t)}),n}un.exports=gn;un.exports.default=gn;class Nn{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function ct(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function de(n,...e){const t=Object.create(null);for(const s in n)t[s]=n[s];return e.forEach(function(s){for(const d in s)t[d]=s[d]}),t}const ht="</span>",hn=n=>!!n.scope||n.sublanguage&&n.language,yt=(n,{prefix:e})=>{if(n.includes(".")){const t=n.split(".");return[`${e}${t.shift()}`,...t.map((s,d)=>`${s}${"_".repeat(d+1)}`)].join(" ")}return`${e}${n}`};class Tt{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=ct(e)}openNode(e){if(!hn(e))return;let t="";e.sublanguage?t=`language-${e.language}`:t=yt(e.scope,{prefix:this.classPrefix}),this.span(t)}closeNode(e){!hn(e)||(this.buffer+=ht)}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}const yn=(n={})=>{const e={children:[]};return Object.assign(e,n),e};class bn{constructor(){this.rootNode=yn(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const t=yn({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return typeof t=="string"?e.addText(t):t.children&&(e.openNode(t),t.children.forEach(s=>this._walk(e,s)),e.closeNode(t)),e}static _collapse(e){typeof e!="string"&&(!e.children||(e.children.every(t=>typeof t=="string")?e.children=[e.children.join("")]:e.children.forEach(t=>{bn._collapse(t)})))}}class vt extends bn{constructor(e){super(),this.options=e}addKeyword(e,t){e!==""&&(this.openNode(t),this.addText(e),this.closeNode())}addText(e){e!==""&&this.add(e)}addSublanguage(e,t){const s=e.root;s.sublanguage=!0,s.language=t,this.add(s)}toHTML(){return new Tt(this,this.options).value()}finalize(){return!0}}function Ee(n){return n?typeof n=="string"?n:n.source:null}function lt(n){return ge("(?=",n,")")}function St(n){return ge("(?:",n,")*")}function wt(n){return ge("(?:",n,")?")}function ge(...n){return n.map(t=>Ee(t)).join("")}function Ot(n){const e=n[n.length-1];return typeof e=="object"&&e.constructor===Object?(n.splice(n.length-1,1),e):{}}function pn(...n){const e=Ot(n);return"("+(e.capture?"":"?:")+n.map(s=>Ee(s)).join("|")+")"}function dt(n){return new RegExp(n.toString()+"|").exec("").length-1}function Rt(n,e){const t=n&&n.exec(e);return t&&t.index===0}const At=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function _n(n,{joinWith:e}){let t=0;return n.map(s=>{t+=1;const d=t;let o=Ee(s),r="";for(;o.length>0;){const a=At.exec(o);if(!a){r+=o;break}r+=o.substring(0,a.index),o=o.substring(a.index+a[0].length),a[0][0]==="\\"&&a[1]?r+="\\"+String(Number(a[1])+d):(r+=a[0],a[0]==="("&&t++)}return r}).map(s=>`(${s})`).join(e)}const Mt=/\b\B/,ut="[a-zA-Z]\\w*",mn="[a-zA-Z_]\\w*",gt="\\b\\d+(\\.\\d+)?",bt="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",pt="\\b(0b[01]+)",It="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Ct=(n={})=>{const e=/^#![ ]*\//;return n.binary&&(n.begin=ge(e,/.*\b/,n.binary,/\b.*/)),de({scope:"meta",begin:e,end:/$/,relevance:0,"on:begin":(t,s)=>{t.index!==0&&s.ignoreMatch()}},n)},fe={begin:"\\\\[\\s\\S]",relevance:0},kt={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[fe]},xt={scope:"string",begin:'"',end:'"',i
|
||
|
https://github.com/highlightjs/highlight.js/issues/2277`),P=g,k=N),S===void 0&&(S=!0);const H={code:k,language:P};z("before:highlight",H);const J=H.result?H.result:u(H.language,H.code,S);return J.code=H.code,z("after:highlight",J),J}function u(g,N,S,k){const P=Object.create(null);function H(_,y){return _.keywords[y]}function J(){if(!v.keywords){G.addText(L);return}let _=0;v.keywordPatternRe.lastIndex=0;let y=v.keywordPatternRe.exec(L),O="";for(;y;){O+=L.substring(_,y.index);const x=re.case_insensitive?y[0].toLowerCase():y[0],Z=H(v,x);if(Z){const[ae,we]=Z;if(G.addText(O),O="",P[x]=(P[x]||0)+1,P[x]<=ur&&(le+=we),ae.startsWith("_"))O+=y[0];else{const Oe=re.classNameAliases[ae]||ae;G.addKeyword(y[0],Oe)}}else O+=y[0];_=v.keywordPatternRe.lastIndex,y=v.keywordPatternRe.exec(L)}O+=L.substring(_),G.addText(O)}function ie(){if(L==="")return;let _=null;if(typeof v.subLanguage=="string"){if(!e[v.subLanguage]){G.addText(L);return}_=u(v.subLanguage,L,!0,he[v.subLanguage]),he[v.subLanguage]=_._top}else _=p(L,v.subLanguage.length?v.subLanguage:null);v.relevance>0&&(le+=_.relevance),G.addSublanguage(_._emitter,_.language)}function $(){v.subLanguage!=null?ie():J(),L=""}function W(_,y){let O=1;const x=y.length-1;for(;O<=x;){if(!_._emit[O]){O++;continue}const Z=re.classNameAliases[_[O]]||_[O],ae=y[O];Z?G.addKeyword(ae,Z):(L=ae,J(),L=""),O++}}function Y(_,y){return _.scope&&typeof _.scope=="string"&&G.openNode(re.classNameAliases[_.scope]||_.scope),_.beginScope&&(_.beginScope._wrap?(G.addKeyword(L,re.classNameAliases[_.beginScope._wrap]||_.beginScope._wrap),L=""):_.beginScope._multi&&(W(_.beginScope,y),L="")),v=Object.create(_,{parent:{value:v}}),v}function F(_,y,O){let x=Rt(_.endRe,O);if(x){if(_["on:end"]){const Z=new Nn(_);_["on:end"](y,Z),Z.isMatchIgnored&&(x=!1)}if(x){for(;_.endsParent&&_.parent;)_=_.parent;return _}}if(_.endsWithParent)return F(_.parent,y,O)}function Q(_){return v.matcher.regexIndex===0?(L+=_[0],1):(me=!0,0)}function ee(_){const y=_[0],O=_.rule,x=new Nn(O),Z=[O.__beforeBegin,O["on:begin"]];for(const ae of Z)if(!!ae&&(ae(_,x),x.isMatchIgnored))return Q(y);return O.skip?L+=y:(O.excludeBegin&&(L+=y),$(),!O.returnBegin&&!O.excludeBegin&&(L=y)),Y(O,_),O.returnBegin?0:y.length}function te(_){const y=_[0],O=N.substring(_.index),x=F(v,_,O);if(!x)return wn;const Z=v;v.endScope&&v.endScope._wrap?($(),G.addKeyword(y,v.endScope._wrap)):v.endScope&&v.endScope._multi?($(),W(v.endScope,_)):Z.skip?L+=y:(Z.returnEnd||Z.excludeEnd||(L+=y),$(),Z.excludeEnd&&(L=y));do v.scope&&G.closeNode(),!v.skip&&!v.subLanguage&&(le+=v.relevance),v=v.parent;while(v!==x.parent);return x.starts&&Y(x.starts,_),Z.returnEnd?0:y.length}function se(){const _=[];for(let y=v;y!==re;y=y.parent)y.scope&&_.unshift(y.scope);_.forEach(y=>G.openNode(y))}let oe={};function ce(_,y){const O=y&&y[0];if(L+=_,O==null)return $(),0;if(oe.type==="begin"&&y.type==="end"&&oe.index===y.index&&O===""){if(L+=N.slice(y.index,y.index+1),!d){const x=new Error(`0 width match regex (${g})`);throw x.languageName=g,x.badRule=oe.rule,x}return 1}if(oe=y,y.type==="begin")return ee(y);if(y.type==="illegal"&&!S){const x=new Error('Illegal lexeme "'+O+'" for mode "'+(v.scope||"<unnamed>")+'"');throw x.mode=v,x}else if(y.type==="end"){const x=te(y);if(x!==wn)return x}if(y.type==="illegal"&&O==="")return 1;if(_e>1e5&&_e>y.index*3)throw new Error("potential infinite loop, way more iterations than matches");return L+=O,O.length}const re=C(g);if(!re)throw ue(o.replace("{}",g)),new Error('Unknown language: "'+g+'"');const Se=or(re);let pe="",v=k||Se;const he={},G=new a.__emitter(a);se();let L="",le=0,j=0,_e=0,me=!1;try{for(v.matcher.considerAll();;){_e++,me?me=!1:v.matcher.considerAll(),v.matcher.lastIndex=j;const _=v.matcher.exec(N);if(!_)break;const y=N.substring(j,_.index),O=ce(y,_);j=_.index+O}return ce(N.substring(j)),G.closeAllNodes(),G.finalize(),pe=G.toHTML(),{language:g,value:pe,relevance:le,illegal:!1,_emitter:G,_top:v}}catch(_){if(_.message&&_.message.includes("Illegal"))return{language:g,value:Re(N),illegal:!0,relevance:0,_illegalBy:{message:_.message,index:j,context:N.slice(j-100,j+10
|
||
|
`},m]}}return qe=d,qe}var Ge,Kn;function Mr(){if(Kn)return Ge;Kn=1;const n=i=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:i.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[i.APOS_STRING_MODE,i.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:i.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},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z][A-Za-z0-9_-]*/}}),e=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","p","q","quote","samp","section","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],t=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"],s=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"],d=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"],o=["align-content","align-items","align-self","all","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius
|
||
|
]`,p={scope:"string",variants:[l,c,u]},m={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},E=["false","null","true"],h=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],f=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],A={keyword:h,literal:(X=>{const z=[];return X.forEach(V=>{z.push(V),V.toLowerCase()===V?z.push(V.toUpperCase()):z.push(V.toLowerCase())}),z})(E),built_in:f},w=X=>X.map(z=>z.replace(/\|\d+$/,"")),I={variants:[{match:[/new/,t.concat(b,"+"),t.concat("(?!",w(f).join("\\b|"),"\\b)"),o],scope:{1:"keyword",4:"title.class"}}]},D=t.concat(d,"\\b(?!\\()"),B={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),D],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[o,t.concat(/::/,t.lookahead(/(?!class\b)/)),D],scope:{1:"title.class",3:"variable.constant"}},{match:[o,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[o,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},T={scope:"attr",match:t.concat(d,t.lookahead(":"),t.lookahead(/(?!::)/))},C={relevance:0,begin:/\(/,end:/\)/,keywords:A,contains:[T,r,B,e.C_BLOCK_COMMENT_MODE,p,m,I]},q={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",w(h).join("\\b|"),"|",w(f).join("\\b|"),"\\b)"),d,t.concat(b,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[C]};C.contains.push(q);const U=[T,B,e.C_BLOCK_COMMENT_MODE,p,m,I],ne={begin:t.concat(/#\[\s*/,o),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:E,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:E,keyword:["new","array"]},contains:["self",...U]},...U,{sc
|