CodeMirror.tagRangeFinder=function(e,n){for(var r="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",i=new RegExp("^["+r+"][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]*"),u=e.getLine(n.line),t=!1,o=null,l=n.ch;!t;){if(-1==(l=u.indexOf("<",l)))return;if(l+1<u.length&&"/"==u[l+1])l++;else if(u.substr(l+1).match(i)){var f=u.indexOf(">",l+1);if(-1==f){for(var a=n.line+1,F=!1,c=e.lineCount();a<c&&!F;){var d=e.getLine(a);if(-1!=(f=d.indexOf(">"))){F=!0;var s=d.lastIndexOf("/",f);if(-1!=s&&s<f){if(!u.substr(s,f-s+1).match(/\/\s*\>/))return}}a++}t=!0}else{var h=u.lastIndexOf("/",f);if(-1==h)t=!0;else{u.substr(h,f-h+1).match(/\/\s*\>/)||(t=!0)}}if(t){(o=u.substr(l+1).match(i))?(o=o[0],-1!=u.indexOf("</"+o+">",l)&&(t=!1)):t=!1}t||l++}else l++}if(t){var g="(\\<\\/"+o+"\\>)|(\\<"+o+"\\>)|(\\<"+o+"\\s)|(\\<"+o+"$)",m=new RegExp(g),C="</"+o+">",v=1;for(a=n.line+1,c=e.lineCount();a<c;){var D=(u=e.getLine(a)).match(m);if(D)for(var x=0;x<D.length;x++)if(D[x]==C?v--:v++,!v)return{from:{line:n.line,ch:f+1},to:{line:a,ch:D.index}};a++}}else;},CodeMirror.braceRangeFinder=function(e,n){for(var r,i,u=n.line,t=e.getLine(u),o=t.length;;){var l=t.lastIndexOf("{",o);if(l<n.ch)break;if(i=e.getTokenAt({line:u,ch:l}).type,!/^(comment|string)/.test(i)){r=l;break}o=l-1}if(!(null==r||t.lastIndexOf("}")>r)){var f,a,F=1,c=e.lineCount();e:for(var d=u+1;d<c;++d)for(var s=e.getLine(d),h=0;;){var g=s.indexOf("{",h),m=s.indexOf("}",h);if(g<0&&(g=s.length),m<0&&(m=s.length),(h=Math.min(g,m))==s.length)break;if(e.getTokenAt({line:d,ch:h+1}).type==i)if(h==g)++F;else if(!--F){f=d,a=h;break e}++h}if(null!=f&&f!=u+1)return{from:{line:u,ch:r+1},to:{line:f,ch:a}}}},CodeMirror.indentRangeFinder=function(e,n){for(var r=e.getOption("tabSize"),i=e.getLine(n.line),u=CodeMirror.countColumn(i,null,r),t=n.line+1,o=e.lineCount();t<o;++t){var l=e.getLine(t);if(CodeMirror.countColumn(l,null,r)<u)return{from:{line:n.line,ch:i.length},to:{line:t,ch:l.length}}}},CodeMirror.newFoldFunction=function(e,n){if(null==n&&(n="↔"),"string"==typeof n){var r=document.createTextNode(n);(n=document.createElement("span")).appendChild(r),n.className="CodeMirror-foldmarker"}return function(r,i){"number"==typeof i&&(i={line:i,ch:0});var u=e(r,i);if(u){for(var t=r.findMarksAt(u.from),o=0,l=0;l<t.length;++l)t[l].__isFold&&(++o,t[l].clear());if(!o){var f=n.cloneNode(!0);CodeMirror.on(f,"mousedown",function(){a.clear()});var a=r.markText(u.from,u.to,{replacedWith:f,clearOnEnter:!0,__isFold:!0})}}}};