Seditio Source
Root |
./othercms/xenForo 2.2.8/js/vendor/codemirror/addon/fold/xml-fold.min.js
(function(h){"object"==typeof exports&&"object"==typeof module?h(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],h):h(CodeMirror)})(function(h){function l(a,b,d,c){this.line=b;this.ch=d;this.cm=a;this.text=a.getLine(b);this.min=c?Math.max(c.from,a.firstLine()):a.firstLine();this.max=c?Math.min(c.to-1,a.lastLine()):a.lastLine()}function m(a,b){return(a=a.cm.getTokenTypeAt(k(a.line,b)))&&/\btag\b/.test(a)}function t(a){if(!(a.line>=a.max))return a.ch=
0,a.text=a.cm.getLine(++a.line),!0}function u(a){if(!(a.line<=a.min))return a.text=a.cm.getLine(--a.line),a.ch=a.text.length,!0}function q(a){for(;;){var b=a.text.indexOf(">",a.ch);if(-1==b)if(t(a))continue;else break;if(m(a,b+1)){var d=a.text.lastIndexOf("/",b);d=-1<d&&!/\S/.test(a.text.slice(d+1,b));a.ch=b+1;return d?"selfClose":"regular"}a.ch=b+1}}function r(a){for(;;){var b=a.ch?a.text.lastIndexOf("<",a.ch-1):-1;if(-1==b)if(u(a))continue;else break;if(m(a,b+1)){n.lastIndex=b;a.ch=b;var d=n.exec(a.text);
if(d&&d.index==b)return d}else a.ch=b}}function v(a){for(;;){n.lastIndex=a.ch;var b=n.exec(a.text);if(!b)if(t(a))continue;else break;if(m(a,b.index+1))return a.ch=b.index+b[0].length,b;a.ch=b.index+1}}function p(a,b){for(var d=[];;){var c=v(a),f,e=a.line,g=a.ch-(c?c[0].length:0);if(!c||!(f=q(a)))break;if("selfClose"!=f)if(c[1]){for(var h=d.length-1;0<=h;--h)if(d[h]==c[2]){d.length=h;break}if(0>h&&(!b||b==c[2]))return{tag:c[2],from:k(e,g),to:k(a.line,a.ch)}}else d.push(c[2])}}function w(a,b){for(var d=
[];;){var c;a:for(c=a;;){var f=c.ch?c.text.lastIndexOf(">",c.ch-1):-1;if(-1==f)if(u(c))continue;else{c=void 0;break a}if(m(c,f+1)){var e=c.text.lastIndexOf("/",f);e=-1<e&&!/\S/.test(c.text.slice(e+1,f));c.ch=f+1;c=e?"selfClose":"regular";break a}else c.ch=f}if(!c)break;if("selfClose"==c)r(a);else{c=a.line;f=a.ch;e=r(a);if(!e)break;if(e[1])d.push(e[2]);else{for(var g=d.length-1;0<=g;--g)if(d[g]==e[2]){d.length=g;break}if(0>g&&(!b||b==e[2]))return{tag:e[2],from:k(a.line,a.ch),to:k(c,f)}}}}}var k=h.Pos,
n=/<(\/?)([A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD-:.0-9\u00B7\u0300-\u036F\u203F-\u2040]*)/g;h.registerHelper("fold","xml",function(a,b){for(a=new l(a,b.line,0);;){var d=v(a);if(!d||a.line!=b.line)break;var c=q(a);if(!c)break;if(!d[1]&&"selfClose"!=
c){b=k(a.line,a.ch);if(d=a=p(a,d[2]))d=a.from,d=0<(d.line-b.line||d.ch-b.ch);return d?{from:b,to:a.from}:null}}});h.findMatchingTag=function(a,b,d){var c=new l(a,b.line,b.ch,d);if(-1!=c.text.indexOf(">")||-1!=c.text.indexOf("<")){var f=q(c),e=f&&k(c.line,c.ch),g=f&&r(c);if(f&&g&&!(0<(c.line-b.line||c.ch-b.ch))){b={from:k(c.line,c.ch),to:e,tag:g[2]};if("selfClose"==f)return{open:b,close:null,at:"open"};if(g[1])return{open:w(c,g[2]),close:b,at:"close"};c=new l(a,e.line,e.ch,d);return{open:b,close:p(c,
g[2]),at:"open"}}}};h.findEnclosingTag=function(a,b,d,c){for(var f=new l(a,b.line,b.ch,d);;){var e=w(f,c);if(!e)break;var g=new l(a,b.line,b.ch,d);if(g=p(g,e.tag))return{open:e,close:g}}};h.scanForClosingTag=function(a,b,d,c){a=new l(a,b.line,b.ch,c?{from:0,to:c}:null);return p(a,d)}});