PageSourceSearch

https://pika.page/assets/@lezer--highlight-70809da571fd850a150cc11849efeb80443c6af22d411924ca6c6066ead97dd2.js

js pika.page collected 2026-10-03 21:43:51 UTC 7,555 bytes, 5 lines download raw bytes

vendor: 4,175 bytes, lines 1-4
1// @lezer/[email protected] downloaded from https://ga.jspm.io/npm:@lezer/[email protected]/dist/index.js
2
3import{NodeProp as e}from"@lezer/common";let t=0;class Tag{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=t++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e==`string`?e:`?`;if(e instanceof Tag&&(t=e),t!=null&&t.base)throw Error(`Can not derive from a modified tag`);let r=new Tag(n,[],null,[]);if(r.set.push(r),t)for(let e of t.set)r.set.push(e);return r}static defineModifier(e){let t=new Modifier(e);return e=>e.modified.indexOf(t)>-1?e:Modifier.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}}let n=0;class Modifier{constructor(e){this.name=e,this.instances=[],this.id=n++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>n.base==e&&r(t,n.modified));if(n)return n;let a=[],o=new Tag(e.name,a,e,t);for(let e of t)e.instances.push(o);let s=i(t);for(let t of e.set)if(!t.modified.length)for(let e of s)a.push(Modifier.get(t,e));return o}}function r(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function i(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function a(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new Rule(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return o.add(t)}const o=new e({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new Rule(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}});class Rule{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}Rule.empty=new Rule([],2,null);function s(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function c(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function l(e,t,n,r=0,i=e.length){let a=new HighlightBuilder(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}function u(e,t,n,r,i,a=0,o=e.length){let s=a;function c(t,n){if(!(t<=s)){for(let a=e.slice(s,t),o=0;;){let e=a.indexOf(`
4`,o),t=e<0?a.length:e;if(t>o&&r(a.slice(o,t),n),e<0)break;i(),o=e+1}s=t}}l(t,n,(e,t,n)=>{c(e,``),c(t,n)},a,o),c(o,``)}class HighlightBuilder{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(t,n,r,i,a){let{type:o,from:s,to:l}=t;if(s>=r||l<=n)return;o.isTop&&(a=this.highlighters.filter(e=>!e.scope||e.scope(o)));let u=i,f=d(t)||Rule.empty,p=c(a,f.tags);if(p&&(u&&(u+=` `),u+=p,f.mode==1&&(i+=(i?` `:``)+p)),this.startSpan(Math.max(n,s),u),f.opaque)return;let m=t.tree&&t.tree.prop(e.mounted);if(m&&m.overlay){let e=t.node.enter(m.overlay[0].from+s,1),o=this.highlighters.filter(e=>!e.scope||e.scope(m.tree.type)),c=t.firstChild();for(let d=0,f=s;;d++){let p=d<m.overlay.length?m.overlay[d]:null,h=p?p.from+s:l,g=Math.max(n,f),_=Math.min(r,h);if(g<_&&c)for(;t.from<_&&(this.highlightRange(t,g,_,i,a),this.startSpan(Math.min(_,t.to),u),!(t.to>=h||!t.nextSibling())););
4if(!p||h>r)break;f=p.to+s,f>n&&(this.highlightRange(e.cursor(),Math.max(n,p.from+s),Math.min(r,f),``,o),this.startSpan(Math.min(r,f),u))}c&&t.parent()}else if(t.firstChild()){m&&(i=``);do{if(t.to<=n)continue;if(t.from>=r)break;this.highlightRange(t,n,r,i,a),this.startSpan(Math.min(r,t.to),u)}while(t.nextSibling());t.parent()}}}function d(e){let t=e.type.prop(o);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const f=Tag.define,p=f(),m=f(),h=f(m),g=f(m),_=f(),v=f(_),y=f(_),b=f(),x=f(b),S=f(),C=f(),w=f(),T=f(w),E=f(),D={comment:p,lineComment:f(p),blockComment:f(p),docComment:f(p),name:m,variableName:f(m),typeName:h,tagName:f(h),propertyName:g,attributeName:f(g),className:f(m),labelName:f(m),namespace:f(m),macroName:f(m),literal:_,string:v,docString:f(v),character:f(v),attributeValue:f(v),number:y,integer:f(y),float:f(y),bool:f(_),regexp:f(_),escape:f(_),color:f(_),url:f(_),keyword:S,self:f(S),null:f(S),atom:f(S),unit:f(S),modifier:f(S),operatorKeyword:f(S),controlKeyword:f(S),definitionKeyword:f(S),moduleKeyword:f(S),operator:C,derefOperator:f(C),arithmeticOperator:f(C),logicOperator:f(C),bitwiseOperator:f(C),compareOperator:f(C),updateOperator:f(C),definitionOperator:f(C),typeOperator:f(C),controlOperator:f(C),punctuation:w,separator:f(w),bracket:T,angleBracket:f(T),squareBracket:f(T),paren:f(T),brace:f(T),content:b,heading:x,heading1:f(x),heading2:f(x),heading3:f(x),heading4:f(x),heading5:f(x),heading6:f(x),contentSeparator:f(b),list:f(b),quote:f(b),emphasis:f(b),strong:f(b),link:f(b),monospace:f(b),strikethrough:f(b),inserted:f(),deleted:f(),changed:f(),invalid:f(),meta:E,documentMeta:f(E),annotation:f(E),processingInstruction:f(E),definition:Tag.defineModifier(`definition`),constant:Tag.defineModifier(`constant`),function:Tag.defineModifier(`function`),standard:Tag.defineModifier(`standard`),local:Tag.defineModifier(`local`),special:Tag.defineModifier(`special`)};for(let e in D){let t=D[e];t instanceof Tag&&(t.name=e)}const O=s([{tag:D.link,class:`tok-link`},{tag:D.heading,class:`tok-heading`},{tag:D.emphasis,class:`tok-emphasis`},{tag:D.strong,class:`tok-strong`},{tag:D.keyword,class:`tok-keyword`},{tag:D.atom,class:`tok-atom`},{tag:D.bool,class:`tok-bool`},{tag:D.url,class:`tok-url`},{tag:D.labelName,class:`tok-labelName`},{tag:D.inserted,class:`tok-inserted`},{tag:D.deleted,class:`tok-deleted`},{tag:D.literal,class:`tok-literal`},{tag:D.string,class:`tok-string`},{tag:D.number,class:`tok-number`},{tag:[D.regexp,D.escape,D.special(D.string)],class:`tok-string2`},{tag:D.variableName,class:`tok-variableName`},{tag:D.local(D.variableName),class:`tok-variableName tok-local`},{tag:D.definition(D.variableName),class:`tok-variableName tok-definition`},{tag:D.special(D.variableName),class:`tok-variableName2`},{tag:D.definition(D.propertyName),class:`tok-propertyName tok-definition`},{tag:D.typeName,class:`tok-typeName`},{tag:D.namespace,class:`tok-namespace`},{tag:D.className,class:`tok-className`},{tag:D.macroName,class:`tok-macroName`},{tag:D.propertyName,class:`tok-propertyName`},{tag:D.operator,class:`tok-operator`},{tag:D.comment,class:`tok-comment`},{tag:D.meta,class:`tok-meta`},{tag:D.invalid,class:`tok-invalid`},{tag:D.punctuation,class:`tok-punctuation`}]);export{Tag,O as classHighlighter,d as getStyleTags,u as highlightCode,l as highlightTree,a as styleTags,s as tagHighlighter,D as tags};
5

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.