jslint
[ckeditor.git] / skins / ckeditor / plugins / codemirror / js / codemirror.addons.min.js
1 (function(){function n(n,t){var i=n.getRange(CodeMirror.Pos(t.line,t.ch-1),CodeMirror.Pos(t.line,t.ch+1));return i.length==2?i:null}function u(t){for(var u={name:"autoCloseBrackets",Backspace:function(i){if(i.somethingSelected())return CodeMirror.Pass;var r=i.getCursor(),u=n(i,r);if(u&&t.indexOf(u)%2==0)i.replaceRange("",CodeMirror.Pos(r.line,r.ch-1),CodeMirror.Pos(r.line,r.ch+1));else return CodeMirror.Pass}},f="",i=0;i<t.length;i+=2)(function(n,t){function e(i){var r=i.getSelection();i.replaceSelection(n+r+t)}function i(n){var i=n.getCursor(),r=n.getRange(i,CodeMirror.Pos(i.line,i.ch+1));if(r!=t||n.somethingSelected())return CodeMirror.Pass;n.execCommand("goCharRight")}n!=t&&(f+=t),u["'"+n+"'"]=function(u){if(n=="'"&&u.getTokenAt(u.getCursor()).type=="comment")return CodeMirror.Pass;if(u.somethingSelected())return e(u);if(n!=t||i(u)==CodeMirror.Pass){var o=u.getCursor(),h=CodeMirror.Pos(o.line,o.ch+1),s=u.getLine(o.line),c=s.charAt(o.ch),l=o.ch>0?s.charAt(o.ch-1):"";if(n==t&&CodeMirror.isWordChar(l))return CodeMirror.Pass;if(s.length==o.ch||f.indexOf(c)>=0||r.test(c))u.replaceSelection(n+t,{head:h,anchor:h});else return CodeMirror.Pass}},n!=t&&(u["'"+t+"'"]=i)})(t.charAt(i),t.charAt(i+1));return u}function f(t){return function(i){var r=i.getCursor(),u=n(i,r);if(!u||t.indexOf(u)%2!=0)return CodeMirror.Pass;i.operation(function(){var n=CodeMirror.Pos(r.line+1,0);i.replaceSelection("\n\n",{anchor:n,head:n},"+input"),i.indentLine(r.line+1,null,!0),i.indentLine(r.line+2,null,!0)})}}var t="()[]{}''\"\"",i="[]{}",r=/\s/;CodeMirror.defineOption("autoCloseBrackets",!1,function(n,r,e){var o,s,h;(e!=CodeMirror.Init&&e&&n.removeKeyMap("autoCloseBrackets"),r)&&(o=t,s=i,typeof r=="string"?o=r:typeof r=="object"&&(r.pairs!=null&&(o=r.pairs),r.explode!=null&&(s=r.explode)),h=u(o),s&&(h.Enter=f(s)),n.addKeyMap(h))})})(),function(){function r(r){var f=r.getCursor(),u=r.getTokenAt(f),h=CodeMirror.innerMode(r.getMode(),u.state),c=h.state,l,s,a;if(h.mode.name!="xml"||!c.tagName)return CodeMirror.Pass;var o=r.getOption("autoCloseTags"),v=h.mode.configuration=="html",y=typeof o=="object"&&o.dontCloseTags||v&&t,p=typeof o=="object"&&o.indentTags||v&&i,e=c.tagName;if(u.end>f.ch&&(e=e.slice(0,e.length-u.end+f.ch)),l=e.toLowerCase(),u.type=="string"&&(u.end!=f.ch||!/[\"\']/.test(u.string.charAt(u.string.length-1))||u.string.length==1)||u.type=="tag"&&c.type=="closeTag"||u.string.indexOf("/")==u.string.length-1||y&&n(y,l)>-1)return CodeMirror.Pass;s=p&&n(p,l)>-1,a=s?CodeMirror.Pos(f.line+1,0):CodeMirror.Pos(f.line,f.ch+1),r.replaceSelection(">"+(s?"\n\n":"")+"<\/"+e+">",{head:a,anchor:a}),s&&(r.indentLine(f.line+1),r.indentLine(f.line+2))}function u(n){var r=n.getCursor(),t=n.getTokenAt(r),u=CodeMirror.innerMode(n.getMode(),t.state),f=u.state,i;if(t.type=="string"||t.string.charAt(0)!="<"||t.start!=r.ch-1||u.mode.name!="xml")return CodeMirror.Pass;i=f.context&&f.context.tagName,i&&n.replaceSelection("/"+i+">","end")}function n(n,t){if(n.indexOf)return n.indexOf(t);for(var i=0,r=n.length;i<r;++i)if(n[i]==t)return i;return-1}CodeMirror.defineOption("autoCloseTags",!1,function(n,t,i){if(i!=CodeMirror.Init&&i&&n.removeKeyMap("autoCloseTags"),t){var f={name:"autoCloseTags"};(typeof t!="object"||t.whenClosing)&&(f["'/'"]=function(n){return u(n)}),(typeof t!="object"||t.whenOpening)&&(f["'>'"]=function(n){return r(n)}),n.addKeyMap(f)}});var t=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],i=["applet","blockquote","body","button","div","dl","fieldset","form","frameset","h1","h2","h3","h4","h5","h6","head","html","iframe","layer","legend","object","ol","p","select","table","ul"]}(),function(){function i(n){var e=n.getCursor(),t=n.getTokenAt(e),i=CodeMirror.innerMode(n.getMode(),t.state).mode,r,o,u,f,s;if(t.type=="comment"&&i.blockCommentStart&&(o=t.string.indexOf(i.blockCommentEnd),u=n.getRange(CodeMirror.Pos(e.line,0),CodeMirror.Pos(e.line,t.end)),o==-1||o!=t.string.length-i.blockCommentEnd.length))if(t.string.indexOf(i.blockCommentStart)==0){if(r=u.slice(0,t.start),!/^\s*$/.test(r))for(r="",s=0;s<t.start;++s)r+=" "}else(f=u.indexOf(i.blockCommentContinue))!=-1&&f+i.blockCommentContinue.length>t.start&&/^\s*$/.test(u.slice(0,f))&&(r=u.slice(0,f));if(r!=null)n.replaceSelection("\n"+r+i.blockCommentContinue,"end");else return CodeMirror.Pass}for(var t=["clike","css","javascript"],n=0;n<t.length;++n)CodeMirror.extendMode(t[n],{blockCommentStart:"/*",blockCommentEnd:"*/",blockCommentContinue:" * "});CodeMirror.defineOption("continueComments",null,function(n,t,r){r&&r!=CodeMirror.Init&&n.removeKeyMap("continueComment");var u={name:"continueComment"};u[typeof t=="string"?t:"Enter"]=i,n.addKeyMap(u)})}(),function(){function r(t,r,u){function w(r,u,f){var e,c,s,h;if(r.text){if(e=o?0:r.text.length-1,c=o?r.text.length:-1,r.text.length>k)return null;for(f!=null&&(e=f+a);e!=c;e+=a)if(s=r.text.charAt(e),g.test(s)&&t.getTokenTypeAt(n(u,e+1))==d)if(h=i[s],h.charAt(1)==">"==o)v.push(s);else{if(v.pop()!=h.charAt(0))return{pos:e,match:!1};if(!v.length)return{pos:e,match:!0}}}}var c=t.state.matchBrackets,k=c&&c.maxScanLineLength||1e4,y=c&&c.maxScanLines||100,s=r||t.getCursor(),l=t.getLineHandle(s.line),e=s.ch-1,p=e>=0&&i[l.text.charAt(e)]||i[l.text.charAt(++e)],o,a,f,h,b;if(!p||(o=p.charAt(1)==">",a=o?1:-1,u&&o!=(e==s.ch)))return null;var d=t.getTokenTypeAt(n(s.line,e+1)),v=[l.text.charAt(e)],g=/[(){}[\]]/;for(f=s.line,b=o?Math.min(f+y,t.lineCount()):Math.max(-1,f-y);f!=b;f+=a)if(h=f==s.line?w(l,f,e):w(t.getLineHandle(f),f),h)break;return{from:n(s.line,e),to:h&&n(f,h.pos),match:h&&h.match,forward:o}}function u(t,i){var o=t.state.matchBrackets.maxHighlightLineLength||1e3,u=r(t),f;if(u&&!(t.getLine(u.from.line).length>o)&&(!u.to||!(t.getLine(u.to.line).length>o))){var s=u.match?"CodeMirror-matchingbracket":"CodeMirror-nonmatchingbracket",c=t.markText(u.from,n(u.from.line,u.from.ch+1),{className:s}),h=u.to&&t.markText(u.to,n(u.to.line,u.to.ch+1),{className:s});if(e&&t.state.focused&&t.display.input.focus(),f=function(){t.operation(function(){c.clear(),h&&h.clear()})},i)setTimeout(f,800);else return f}}function f(n){n.operation(function(){t&&(t(),t=null),n.somethingSelected()||(t=u(n,!1))})}var e=/MSIE \d/.test(navigator.userAgent)&&(document.documentMode==null||document.documentMode<8),n=CodeMirror.Pos,i={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<"},t=null;CodeMirror.defineOption("matchBrackets",!1,function(n,t,i){if(i&&i!=CodeMirror.Init&&n.off("cursorActivity",f),t){n.state.matchBrackets=typeof t=="object"?t:{};n.on("cursorActivity",f)}}),CodeMirror.defineExtension("matchBrackets",function(){u(this,!0)}),CodeMirror.defineExtension("findMatchingBracket",function(n,t){return r(this,n,t)})}(),function(){"use strict";function t(n){n.state.tagHit&&n.state.tagHit.clear(),n.state.tagOther&&n.state.tagOther.clear(),n.state.tagHit=n.state.tagOther=null}function n(n){n.state.failedTagMatch=!1,n.operation(function(){var u,r,i,f,e;(t(n),n.somethingSelected())||(u=n.getCursor(),r=n.getViewport(),r.from=Math.min(r.from,u.line),r.to=Math.max(u.line+1,r.to),i=CodeMirror.findMatchingTag(n,u,r),i)&&(n.state.matchBothTags&&(f=i.at=="open"?i.open:i.close,f&&(n.state.tagHit=n.markText(f.from,f.to,{className:"CodeMirror-matchingtag"}))),e=i.at=="close"?i.open:i.close,e?n.state.tagOther=n.markText(e.from,e.to,{className:"CodeMirror-matchingtag"}):n.state.failedTagMatch=!0)})}function i(t){t.state.failedTagMatch&&n(t)}CodeMirror.defineOption("matchTags",!1,function(r,u,f){if(f&&f!=CodeMirror.Init&&(r.off("cursorActivity",n),r.off("viewportChange",i),t(r)),u){r.state.matchBothTags=typeof u=="object"&&u.bothTags;r.on("cursorActivity",n);r.on("viewportChange",i);n(r)}}),CodeMirror.commands.toMatchingTag=function(n){var t=CodeMirror.findMatchingTag(n,n.getCursor()),i;t&&(i=t.at=="close"?t.open:t.close,i&&n.setSelection(i.to,i.from))}}(),CodeMirror.defineOption("showTrailingSpace",!1,function(n,t,i){i==CodeMirror.Init&&(i=!1),i&&!t?n.removeOverlay("trailingspace"):!i&&t&&n.addOverlay({token:function(n){for(var i=n.string.length,t=i;t&&/\s/.test(n.string.charAt(t-1));--t);return t>n.pos?(n.pos=t,null):(n.pos=i,"trailingspace")},name:"trailingspace"})}),function(){"use strict";function n(n,i,r,u){function c(t){var r=e(n,i),o,f;if(!r||r.to.line-r.from.line<h)return null;for(o=n.findMarksAt(r.from),f=0;f<o.length;++f)if(o[f].__isFold&&u!=="fold"){if(!t)return null;r.cleared=!0,o[f].clear()}return r}var e=r&&(r.call?r:r.rangeFinder),h,f,o,s;if(e||(e=n.getHelper(i,"fold")),e){if(typeof i=="number"&&(i=CodeMirror.Pos(i,0)),h=r&&r.minFoldSize||0,f=c(!0),r&&r.scanUp)while(!f&&i.line>n.firstLine())i=CodeMirror.Pos(i.line-1,0),f=c(!1);if(f&&!f.cleared&&u!=="unfold"){o=t(r);CodeMirror.on(o,"mousedown",function(){s.clear()});s=n.markText(f.from,f.to,{replacedWith:o,clearOnEnter:!0,__isFold:!0});s.on("clear",function(t,i){CodeMirror.signal(n,"unfold",n,t,i)});CodeMirror.signal(n,"fold",n,f.from,f.to)}}}function t(n){var t=n&&n.widget||"",i;return typeof t=="string"&&(i=document.createTextNode(t),t=document.createElement("span"),t.appendChild(i),t.className="CodeMirror-foldmarker"),t}CodeMirror.newFoldFunction=function(t,i){return function(r,u){n(r,u,{rangeFinder:t,widget:i})}},CodeMirror.defineExtension("foldCode",function(t,i,r){n(this,t,i,r)}),CodeMirror.registerHelper("fold","combine",function(){var n=Array.prototype.slice.call(arguments,0);return function(t,i){for(var u,r=0;r<n.length;++r)if(u=n[r](t,i),u)return u}})}(),CodeMirror.registerHelper("fold","brace",function(n,t){function y(i){for(var r,u=t.ch,e=0;;){if(r=u<=0?-1:v.lastIndexOf(i,u-1),r==-1){if(e==1)break;e=1,u=v.length;continue}if(e==1&&r<t.ch)break;if(c=n.getTokenTypeAt(CodeMirror.Pos(f,r+1)),!/^(comment|string)/.test(c))return r+1;u=r-1}}var f=t.line,v=n.getLine(f),c,p="{",w="}",r=y("{"),l,b,s,a,u,e,i,o,h;if(r==null&&(p="[",w="]",r=y("[")),r!=null){l=1,b=n.lastLine();n:for(u=f;u<=b;++u)for(e=n.getLine(u),i=u==f?r:0;;){if(o=e.indexOf(p,i),h=e.indexOf(w,i),o<0&&(o=e.length),h<0&&(h=e.length),i=Math.min(o,h),i==e.length)break;if(n.getTokenTypeAt(CodeMirror.Pos(u,i+1))==c)if(i==o)++l;else if(!--l){s=u,a=i;break n}++i}if(s!=null&&(f!=s||a!=r))return{from:CodeMirror.Pos(f,r),to:CodeMirror.Pos(s,a)}}}),CodeMirror.braceRangeFinder=CodeMirror.fold.brace,CodeMirror.registerHelper("fold","import",function(n,t){function i(t){var i,r,f,e,u;if(t<n.firstLine()||t>n.lastLine()||(i=n.getTokenAt(CodeMirror.Pos(t,1)),/\S/.test(i.string)||(i=n.getTokenAt(CodeMirror.Pos(t,i.end+1))),i.type!="keyword"||i.string!="import"))return null;for(r=t,f=Math.min(n.lastLine(),t+10);r<=f;++r)if(e=n.getLine(r),u=e.indexOf(";"),u!=-1)return{startCh:i.end,end:CodeMirror.Pos(r,u)}}var t=t.line,u=i(t),e,r,f;if(!u||i(t-1)||(e=i(t-2))&&e.end.line==t-1)return null;for(r=u.end;;){if(f=i(r.line+1),f==null)break;r=f.end}return{from:n.clipPos(CodeMirror.Pos(t,u.startCh+1)),to:r}}),CodeMirror.importRangeFinder=CodeMirror.fold["import"],CodeMirror.registerHelper("fold","include",function(n,t){function r(t){if(t<n.firstLine()||t>n.lastLine())return null;var i=n.getTokenAt(CodeMirror.Pos(t,1));return/\S/.test(i.string)||(i=n.getTokenAt(CodeMirror.Pos(t,i.end+1))),i.type=="meta"&&i.string.slice(0,8)=="#include"?i.start+8:void 0}var t=t.line,u=r(t),i,f;if(u==null||r(t-1)!=null)return null;for(i=t;;){if(f=r(i+1),f==null)break;++i}return{from:CodeMirror.Pos(t,u+1),to:n.clipPos(CodeMirror.Pos(i))}}),CodeMirror.includeRangeFinder=CodeMirror.fold.include,function(){"use strict";function a(n,t){return n.line-t.line||n.ch-t.ch}function t(n,t,i,r){this.line=t,this.ch=i,this.cm=n,this.text=n.getLine(t),this.min=r?r.from:n.firstLine(),this.max=r?r.to-1:n.lastLine()}function r(t,i){var r=t.cm.getTokenTypeAt(n(t.line,i));return r&&/\btag\b/.test(r)}function s(n){if(!(n.line>=n.max))return n.ch=0,n.text=n.cm.getLine(++n.line),!0}function h(n){if(!(n.line<=n.min))return n.text=n.cm.getLine(--n.line),n.ch=n.text.length,!0}function u(n){for(var t,i,u;;){if(t=n.text.indexOf(">",n.ch),t==-1)if(s(n))continue;else return;if(!r(n,t+1)){n.ch=t+1;continue}return i=n.text.lastIndexOf("/",t),u=i>-1&&!/\S/.test(n.text.slice(i+1,t)),n.ch=t+1,u?"selfClose":"regular"}}function f(n){for(var t,u;;){if(t=n.ch?n.text.lastIndexOf("<",n.ch-1):-1,t==-1)if(h(n))continue;else return;if(!r(n,t+1)){n.ch=t;continue}if(i.lastIndex=t,n.ch=t,u=i.exec(n.text),u&&u.index==t)return u}}function c(n){for(;;){i.lastIndex=n.ch;var t=i.exec(n.text);if(!t)if(s(n))continue;else return;if(!r(n,t.index+1)){n.ch=t.index+1;continue}return n.ch=t.index+t[0].length,t}}function y(n){for(var t,i,u;;){if(t=n.ch?n.text.lastIndexOf(">",n.ch-1):-1,t==-1)if(h(n))continue;else return;if(!r(n,t+1)){n.ch=t;continue}return i=n.text.lastIndexOf("/",t),u=i>-1&&!/\S/.test(n.text.slice(i+1,t)),n.ch=t+1,u?"selfClose":"regular"}}function e(t,i){for(var e=[],f;;){var r=c(t),o,s=t.line,h=t.ch-(r?r[0].length:0);if(!r||!(o=u(t)))return;if(o!="selfClose")if(r[1]){for(f=e.length-1;f>=0;--f)if(e[f]==r[2]){e.length=f;break}if(f<0&&(!i||i==r[2]))return{tag:r[2],from:n(s,h),to:n(t.line,t.ch)}}else e.push(r[2])}}function l(t,i){for(var e=[],o,u;;){if(o=y(t),!o)return;if(o=="selfClose"){f(t);continue}var s=t.line,h=t.ch,r=f(t);if(!r)return;if(r[1])e.push(r[2]);else{for(u=e.length-1;u>=0;--u)if(e[u]==r[2]){e.length=u;break}if(u<0&&(!i||i==r[2]))return{tag:r[2],from:n(t.line,t.ch),to:n(s,h)}}}}var n=CodeMirror.Pos,o="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",v=o+"-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",i=new RegExp("<(/?)(["+o+"]["+v+"]*)","g");CodeMirror.registerHelper("fold","xml",function(i,r){for(var f=new t(i,r.line,0),o,h,r,s;;){if(o=c(f),!o||f.line!=r.line||!(h=u(f)))return;if(!o[1]&&h!="selfClose")return r=n(f.line,f.ch),s=e(f,o[2]),s&&{from:r,to:s.from}}}),CodeMirror.tagRangeFinder=CodeMirror.fold.xml,CodeMirror.findMatchingTag=function(i,r,o){var s=new t(i,r.line,r.ch,o),y;if(s.text.indexOf(">")!=-1||s.text.indexOf("<")!=-1){var c=u(s),v=c&&n(s.line,s.ch),h=c&&f(s);if(c&&c!="selfClose"&&h&&!(a(s,r)>0))return y={from:n(s.line,s.ch),to:v,tag:h[2]},h[1]?{open:l(s,h[2]),close:y,at:"close"}:(s=new t(i,v.line,v.ch,o),{open:y,close:e(s,h[2]),at:"open"})}},CodeMirror.findEnclosingTag=function(n,i,r){for(var s=new t(n,i.line,i.ch,r),u,o,f;;){if(u=l(s),!u)break;if(o=new t(n,i.line,i.ch,r),f=e(o,u.tag),f)return{open:u,close:f}}}}(),function(){CodeMirror.defineExtension("autoFormatAll",function(n,t){function v(){h+="\n",e=!0,++a}for(var r=this,f=r.getMode(),o=r.getRange(n,t).split("\n"),s=CodeMirror.copyState(f,r.getTokenAt(n).state),y=r.getOption("tabSize"),h="",a=0,e=n.ch==0,i,u=0;u<o.length;++u){for(i=new CodeMirror.StringStream(o[u],y);!i.eol();){var c=CodeMirror.innerMode(f,s),p=f.token(i,s),l=i.current();i.start=i.pos,(!e||/\S/.test(l))&&(h+=l,e=!1),!e&&c.mode.newlineAfterToken&&c.mode.newlineAfterToken(p,l,i.string.slice(i.pos)||o[u+1]||"",c.state)&&v()}!i.pos&&f.blankLine&&f.blankLine(s),!e&&u<o.length-1&&v()}r.operation(function(){r.replaceRange(h,n,t);for(var i=n.line+1,u=n.line+a;i<=u;++i)r.indentLine(i,"smart");r.setCursor({line:0,ch:0})})})}(),function(){function n(n){for(var f=[/for\s*?\((.*?)\)/g,/&#?[a-z0-9]+;[\s\S]/g,/\"(.*?)((\")|$)/g,/\/\*(.*?)(\*\/|$)/g,/^\/\/.*/g],u=[],i,t,r=0;r<f.length;r++)for(i=0;i<n.length;)if(t=n.substr(i).match(f[r]),t!=null)u.push({start:i+t.index,end:i+t.index+t[0].length}),i+=t.index+Math.max(1,t[0].length);else break;return u.sort(function(n,t){return n.start-t.start}),u}CodeMirror.extendMode("css",{commentStart:"/*",commentEnd:"*/",newlineAfterToken:function(n,t){return/^[;{}]$/.test(t)}}),CodeMirror.extendMode("javascript",{commentStart:"/*",commentEnd:"*/",wordWrapChars:[";","\\{","\\}"],autoFormatLineBreaks:function(t){var r=0,e=this.jsonMode?function(n){return n.replace(/([,{])/g,"$1\n").replace(/}/g,"\n}")}:function(n){return n.replace(/(;|\{|\})([^\r\n;])/g,"$1\n$2")},u=n(t),f="",i;if(u!=null){for(i=0;i<u.length;i++)u[i].start>r&&(f+=e(t.substring(r,u[i].start)),r=u[i].start),u[i].start<=r&&u[i].end>=r&&(f+=t.substring(r,u[i].end),r=u[i].end);r<t.length&&(f+=e(t.substr(r)))}else f=e(t);return f.replace(/^\n*|\n*$/,"")}});CodeMirror.extendMode("xml",{commentStart:"<!--",commentEnd:"-->",noBreak:!1,noBreakEmpty:null,tagType:"",tagName:"",isXML:!1,newlineAfterToken:function(n,t,i){var o="a|b|bdi|bdo|big|center|cite|del|em|font|i|img|ins|s|small|span|strike|strong|sub|sup|u",e="label|li|option|textarea|title|"+o,f=!1,r=null,u="",s;if(this.isXML=this.configuration=="xml"?!0:!1,n=="comment"||/<!--/.test(i))return!1;if(n=="tag"){if(t.indexOf("<")==0&&!t.indexOf("<\/")==0&&(this.tagType="open",r=t.match(/^<\s*?([\w]+?)$/i),this.tagName=r!=null?r[1]:"",u=this.tagName.toLowerCase(),("|"+e+"|").indexOf("|"+u+"|")!=-1&&(this.noBreak=!0)),t.indexOf(">")==0&&this.tagType=="open")return(this.tagType="",s=this.isXML?"[^<]*?":"",RegExp("^"+s+"<\/s*?"+this.tagName+"s*?>","i").test(i))?(this.noBreak=!1,this.isXML||(this.tagName=""),!1):(f=this.noBreak,this.noBreak=!1,f?!1:!0);if(t.indexOf("<\/")==0&&(this.tagType="close",r=t.match(/^<\/\s*?([\w]+?)$/i),r!=null&&(u=r[1].toLowerCase()),("|"+o+"|").indexOf("|"+u+"|")!=-1&&(this.noBreak=!0)),t.indexOf(">")==0&&this.tagType=="close")return(this.tagType="",i.indexOf("<")==0&&(r=i.match(/^<\/?\s*?([\w]+?)(\s|>)/i),u=r!=null?r[1].toLowerCase():"",("|"+e+"|").indexOf("|"+u+"|")==-1))?(this.noBreak=!1,!0):(f=this.noBreak,this.noBreak=!1,f?!1:!0)}return i.indexOf("<")==0?(this.noBreak=!1,this.isXML&&this.tagName!="")?(this.tagName="",!1):(r=i.match(/^<\/?\s*?([\w]+?)(\s|>)/i),u=r!=null?r[1].toLowerCase():"",("|"+e+"|").indexOf("|"+u+"|")!=-1?!1:!0):!1}}),CodeMirror.defineExtension("commentRange",function(n,t,i){var r=this,u=CodeMirror.innerMode(r.getMode(),r.getTokenAt(t).state).mode;r.operation(function(){if(n)r.replaceRange(u.commentEnd,i),r.replaceRange(u.commentStart,t),t.line==i.line&&t.ch==i.ch&&r.setCursor(t.line,t.ch+u.commentStart.length);else{var f=r.getRange(t,i),e=f.indexOf(u.commentStart),o=f.lastIndexOf(u.commentEnd);e>-1&&o>-1&&o>e&&(f=f.substr(0,e)+f.substring(e+u.commentStart.length,o)+f.substr(o+u.commentEnd.length)),r.replaceRange(f,t,i)}})}),CodeMirror.defineExtension("autoIndentRange",function(n,t){var i=this;this.operation(function(){for(var r=n.line;r<=t.line;r++)i.indentLine(r,"smart")})}),CodeMirror.defineExtension("autoFormatRange",function(n,t){function v(){h+="\n",e=!0,++a}for(var i=this,f=i.getMode(),o=i.getRange(n,t).split("\n"),s=CodeMirror.copyState(f,i.getTokenAt(n).state),y=i.getOption("tabSize"),h="",a=0,e=n.ch==0,r,u=0;u<o.length;++u){for(r=new CodeMirror.StringStream(o[u],y);!r.eol();){var c=CodeMirror.innerMode(f,s),p=f.token(r,s),l=r.current();r.start=r.pos,(!e||/\S/.test(l))&&(h+=l,e=!1),!e&&c.mode.newlineAfterToken&&c.mode.newlineAfterToken(p,l,r.string.slice(r.pos)||o[u+1]||"",c.state)&&v()}!r.pos&&f.blankLine&&f.blankLine(s),!e&&u<o.length-1&&v()}i.operation(function(){i.replaceRange(h,n,t);for(var r=n.line+1,u=n.line+a;r<=u;++r)i.indentLine(r,"smart");i.setSelection(n,i.getCursor(!1))})})}(),function(){function e(n){typeof n=="object"&&(this.minChars=n.minChars,this.style=n.style,this.showToken=n.showToken,this.delay=n.delay),this.style==null&&(this.style=u),this.minChars==null&&(this.minChars=r),this.delay==null&&(this.delay=f),this.overlay=this.timeout=null}function n(n){var i=n.state.matchHighlighter;clearTimeout(i.timeout),i.timeout=setTimeout(function(){t(n)},i.delay)}function t(n){n.operation(function(){var t=n.state.matchHighlighter,o;if(t.overlay&&(n.removeOverlay(t.overlay),t.overlay=null),!n.somethingSelected()&&t.showToken){for(var e=t.showToken===!0?/[\w$]/:t.showToken,s=n.getCursor(),f=n.getLine(s.line),r=s.ch,u=r;r&&e.test(f.charAt(r-1));)--r;while(u<f.length&&e.test(f.charAt(u)))++u;r<u&&n.addOverlay(t.overlay=i(f.slice(r,u),e,t.style));return}n.getCursor("head").line==n.getCursor("anchor").line&&(o=n.getSelection().replace(/^\s+|\s+$/g,""),o.length>=t.minChars&&n.addOverlay(t.overlay=i(o,!1,t.style)))})}function o(n,t){return(!n.start||!t.test(n.string.charAt(n.start-1)))&&(n.pos==n.string.length||!t.test(n.string.charAt(n.pos)))}function i(n,t,i){return{token:function(r){if(r.match(n)&&(!t||o(r,t)))return i;r.next(),r.skipTo(n.charAt(0))||r.skipToEnd()}}}var r=2,u="matchhighlight",f=100;CodeMirror.defineOption("highlightSelectionMatches",!1,function(i,r,u){if(u&&u!=CodeMirror.Init){var f=i.state.matchHighlighter.overlay;f&&i.removeOverlay(f),clearTimeout(i.state.matchHighlighter.timeout),i.state.matchHighlighter=null,i.off("cursorActivity",n)}if(r){i.state.matchHighlighter=new e(r),t(i);i.on("cursorActivity",n)}})}()