MCPcopy Create free account
hub / github.com/danvk/webdiff / j

Function j

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

Source from the content-addressed store, hash-verified

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

Callers 1

TFunction · 0.85

Calls 8

addRuleMethod · 0.95
eFunction · 0.85
YFunction · 0.85
XFunction · 0.85
aClass · 0.85
rFunction · 0.70
tFunction · 0.70
dFunction · 0.70

Tested by

no test coverage detected