MCPcopy Create free account
hub / github.com/aboutcode-org/vulnerablecode / f

Function f

vulnerablecode/static/js/highlight-10.6.0.min.js:181–237  ·  view source on GitHub ↗
(e,t,r,o)

Source from the content-addressed store, hash-verified

179return g.noHighlightRe.test(e)}function h(e,t,n,s){const r={code:t,language:e}
180;M("before:highlight",r);const a=r.result?r.result:f(r.language,r.code,n,s)
181;return a.code=r.code,M("after:highlight",a),a}function f(e,t,r,o){const c=t
182;function u(e,t){const n=w.case_insensitive?t[0].toLowerCase():t[0]
183;return Object.prototype.hasOwnProperty.call(e.keywords,n)&&e.keywords[n]}
184function d(){null!=R.subLanguage?(()=>{if(""===M)return;let e=null
185;if("string"==typeof R.subLanguage){
186if(!n[R.subLanguage])return void O.addText(M)
187;e=f(R.subLanguage,M,!0,k[R.subLanguage]),k[R.subLanguage]=e.top
188}else e=p(M,R.subLanguage.length?R.subLanguage:null)
189;R.relevance>0&&(A+=e.relevance),O.addSublanguage(e.emitter,e.language)
190})():(()=>{if(!R.keywords)return void O.addText(M);let e=0
191;R.keywordPatternRe.lastIndex=0;let t=R.keywordPatternRe.exec(M),n="";for(;t;){
192n+=M.substring(e,t.index);const s=u(R,t);if(s){const[e,r]=s
193;O.addText(n),n="",A+=r;const a=w.classNameAliases[e]||e;O.addKeyword(t[0],a)
194}else n+=t[0];e=R.keywordPatternRe.lastIndex,t=R.keywordPatternRe.exec(M)}
195n+=M.substr(e),O.addText(n)})(),M=""}function h(e){
196return e.className&&O.openNode(w.classNameAliases[e.className]||e.className),
197R=Object.create(e,{parent:{value:R}}),R}function m(e,t,n){let r=((e,t)=>{
198const n=e&&e.exec(t);return n&&0===n.index})(e.endRe,n);if(r){if(e["on:end"]){
199const n=new s(e);e["on:end"](t,n),n.ignore&&(r=!1)}if(r){
200for(;e.endsParent&&e.parent;)e=e.parent;return e}}
201if(e.endsWithParent)return m(e.parent,t,n)}function b(e){
202return 0===R.matcher.regexIndex?(M+=e[0],1):(I=!0,0)}function x(e){
203const t=e[0],n=c.substr(e.index),s=m(R,e,n);if(!s)return G;const r=R
204;r.skip?M+=t:(r.returnEnd||r.excludeEnd||(M+=t),d(),r.excludeEnd&&(M=t));do{
205R.className&&O.closeNode(),R.skip||R.subLanguage||(A+=R.relevance),R=R.parent
206}while(R!==s.parent)
207;return s.starts&&(s.endSameAsBegin&&(s.starts.endRe=s.endRe),
208h(s.starts)),r.returnEnd?0:t.length}let E={};function v(t,n){const a=n&&n[0]
209;if(M+=t,null==a)return d(),0
210;if("begin"===E.type&&"end"===n.type&&E.index===n.index&&""===a){
211if(M+=c.slice(n.index,n.index+1),!i){const t=Error("0 width match regex")
212;throw t.languageName=e,t.badRule=E.rule,t}return 1}
213if(E=n,"begin"===n.type)return function(e){
214const t=e[0],n=e.rule,r=new s(n),a=[n.__beforeBegin,n["on:begin"]]
215;for(const n of a)if(n&&(n(e,r),r.ignore))return b(t)
216;return n&&n.endSameAsBegin&&(n.endRe=RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"m")),
217n.skip?M+=t:(n.excludeBegin&&(M+=t),
218d(),n.returnBegin||n.excludeBegin||(M=t)),h(n),n.returnBegin?0:t.length}(n)
219;if("illegal"===n.type&&!r){
220const e=Error('Illegal lexeme "'+a+'" for mode "'+(R.className||"<unnamed>")+'"')
221;throw e.mode=R,e}if("end"===n.type){const e=x(n);if(e!==G)return e}
222if("illegal"===n.type&&""===a)return 1
223;if(B>1e5&&B>3*n.index)throw Error("potential infinite loop, way more iterations than matches")
224;return M+=a,a.length}const w=_(e)
225;if(!w)throw H(l.replace("{}",e)),Error('Unknown language: "'+e+'"')
226;const N=T(w,{plugins:a});let y="",R=o||N;const k={},O=new g.__emitter(g);(()=>{
227const e=[];for(let t=R;t!==w;t=t.parent)t.className&&e.unshift(t.className)
228;e.forEach((e=>O.openNode(e)))})();let M="",A=0,L=0,B=0,I=!1;try{
229for(R.matcher.considerAll();;){
230B++,I?I=!1:R.matcher.considerAll(),R.matcher.lastIndex=L
231;const e=R.matcher.exec(c);if(!e)break;const t=v(c.substring(L,e.index),e)
232;L=e.index+t}return v(c.substr(L)),O.closeAllNodes(),O.finalize(),y=O.toHTML(),{
233relevance:Math.floor(A),value:y,language:e,illegal:!1,emitter:O,top:R}}catch(t){
234if(t.message&&t.message.includes("Illegal"))return{illegal:!0,illegalBy:{
235msg:t.message,context:c.slice(L-100,L+100),mode:t.mode},sofar:y,relevance:0,
236value:z(c),emitter:O};if(i)return{illegal:!1,relevance:0,value:z(c),emitter:O,
237language:e,top:R,errorRaised:t};throw t}}function p(e,t){
238t=t||g.languages||Object.keys(n);const s=(e=>{const t={relevance:0,

Callers 3

hFunction · 0.85
dFunction · 0.85
pFunction · 0.85

Calls 10

_Function · 0.85
HFunction · 0.85
TFunction · 0.85
vFunction · 0.85
considerAllMethod · 0.80
closeAllNodesMethod · 0.80
finalizeMethod · 0.80
toHTMLMethod · 0.80
openNodeMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected