MCPcopy Create free account
hub / github.com/idank/explainshell / V

Function V

explainshell/web/static/js/highlight.min.js:124–171  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

122 K
123 ;if("object"!=typeof e.endScope||null===e.endScope)throw W("endScope must be object"),
124 K;F(e,e.end,{key:"endScope"}),e.end=m(e.end,{joinWith:""})}})(e)}function V(e){
125 function t(t,n){
126 return RegExp(l(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(n?"g":""))
127 }class n{constructor(){
128 this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}
129 addRule(e,t){
130 t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),
131 this.matchAt+=p(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null)
132 ;const e=this.regexes.map((e=>e[1]));this.matcherRe=t(m(e,{joinWith:"|"
133 }),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex
134 ;const t=this.matcherRe.exec(e);if(!t)return null
135 ;const n=t.findIndex(((e,t)=>t>0&&void 0!==e)),i=this.matchIndexes[n]
136 ;return t.splice(0,n),Object.assign(t,i)}}class s{constructor(){
137 this.rules=[],this.multiRegexes=[],
138 this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){
139 if(this.multiRegexes[e])return this.multiRegexes[e];const t=new n
140 ;return this.rules.slice(e).forEach((([e,n])=>t.addRule(e,n))),
141 t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){
142 return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){
143 this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){
144 const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex
145 ;let n=t.exec(e)
146 ;if(this.resumingScanAtSamePosition())if(n&&n.index===this.lastIndex);else{
147 const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,n=t.exec(e)}
148 return n&&(this.regexIndex+=n.position+1,
149 this.regexIndex===this.count&&this.considerAll()),n}}
150 if(e.compilerExtensions||(e.compilerExtensions=[]),
151 e.contains&&e.contains.includes("self"))throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.")
152 ;return e.classNameAliases=i(e.classNameAliases||{}),function n(o,r){const a=o
153 ;if(o.isCompiled)return a
154 ;[I,B,Z,D].forEach((e=>e(o,r))),e.compilerExtensions.forEach((e=>e(o,r))),
155 o.__beforeBegin=null,[T,L,P].forEach((e=>e(o,r))),o.isCompiled=!0;let c=null
156 ;return"object"==typeof o.keywords&&o.keywords.$pattern&&(o.keywords=Object.assign({},o.keywords),
157 c=o.keywords.$pattern,
158 delete o.keywords.$pattern),c=c||/\w+/,o.keywords&&(o.keywords=$(o.keywords,e.case_insensitive)),
159 a.keywordPatternRe=t(c,!0),
160 r&&(o.begin||(o.begin=/\B|\b/),a.beginRe=t(a.begin),o.end||o.endsWithParent||(o.end=/\B|\b/),
161 o.end&&(a.endRe=t(a.end)),
162 a.terminatorEnd=l(a.end)||"",o.endsWithParent&&r.terminatorEnd&&(a.terminatorEnd+=(o.end?"|":"")+r.terminatorEnd)),
163 o.illegal&&(a.illegalRe=t(o.illegal)),
164 o.contains||(o.contains=[]),o.contains=[].concat(...o.contains.map((e=>(e=>(e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((t=>i(e,{
165 variants:null},t)))),e.cachedVariants?e.cachedVariants:q(e)?i(e,{
166 starts:e.starts?i(e.starts):null
167 }):Object.isFrozen(e)?i(e):e))("self"===e?o:e)))),o.contains.forEach((e=>{n(e,a)
168 })),o.starts&&n(o.starts,r),a.matcher=(e=>{const t=new s
169 ;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"
170 }))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"
171 }),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t})(a),a}(e)}function q(e){
172 return!!e&&(e.endsWithParent||q(e.starts))}class J extends Error{
173 constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}
174 const Y=n,Q=i,ee=Symbol("nomatch"),te=n=>{

Callers 1

EFunction · 0.70

Calls 8

addRuleMethod · 0.95
iFunction · 0.70
eFunction · 0.70
$Function · 0.70
tFunction · 0.70
lFunction · 0.70
qFunction · 0.70
nFunction · 0.70

Tested by

no test coverage detected