src/pyams_skin/resources/js/ext/ace/ext-beautify.min.js
changeset 504 fb5a531cddbe
parent 501 2f0eb9a77324
equal deleted inserted replaced
503:a50637baf022 504:fb5a531cddbe
     1 ace.define("ace/ext/beautify",["require","exports","module","ace/token_iterator"],function(e,t,r){"use strict";function a(e,t){return e.type.lastIndexOf(t+".xml")>-1}var o=e("../token_iterator").TokenIterator;t.singletonTags=["area","base","br","col","command","embed","hr","html","img","input","keygen","link","meta","param","source","track","wbr"],t.blockTags=["article","aside","blockquote","body","div","dl","fieldset","footer","form","head","header","html","nav","ol","p","script","section","style","table","tbody","tfoot","thead","ul"],t.beautify=function(e){for(var r,s,n,i=new o(e,0,0),c=i.getCurrentToken(),u=e.getTabString(),m=t.singletonTags,l=t.blockTags,p=!1,f=!1,b=!1,d="",y="",h="",g=0,k=0,$=0,w=0,x=0,v=0,T=0,R=0,O=!1,q=!1,C=!1,I=!1,_={0:0},j={},S=function(){r&&r.value&&"string.regexp"!==r.type&&(r.value=r.value.trim())},B=function(){d=d.replace(/ +$/,"")},F=function(){d=d.trimRight(),p=!1};null!==c;){if(T=i.getCurrentTokenRow(),i.$rowTokens,r=i.stepForward(),void 0!==c){if(y=c.value,x=0,C="style"===h||"ace/mode/css"===e.$modeId,a(c,"tag-open")?(q=!0,r&&(I=-1!==l.indexOf(r.value)),"</"===y&&(I&&!p&&R<1&&R++,C&&(R=1),x=1,I=!1)):a(c,"tag-close")?q=!1:a(c,"comment.start")?I=!0:a(c,"comment.end")&&(I=!1),!q&&!R&&"paren.rparen"===c.type&&"}"===c.value.substr(0,1)&&R++,T!==s&&(R=T,s&&(R-=s)),R){for(F();R>0;R--)d+="\n";p=!0,!a(c,"comment")&&!c.type.match(/^(comment|string)$/)&&(y=y.trimLeft())}if(y){if("keyword"===c.type&&y.match(/^(if|else|elseif|for|foreach|while|switch)$/)?(j[g]=y,S(),b=!0,y.match(/^(else|elseif)$/)&&d.match(/\}[\s]*$/)&&(F(),f=!0)):"paren.lparen"===c.type?(S(),"{"===y.substr(-1)&&(b=!0,O=!1,q||(R=1)),"{"===y.substr(0,1)&&(f=!0,"["!==d.substr(-1)&&"["===d.trimRight().substr(-1)?(F(),f=!1):")"===d.trimRight().substr(-1)?F():B())):"paren.rparen"===c.type?(x=1,"}"===y.substr(0,1)&&("case"===j[g-1]&&x++,"{"===d.trimRight().substr(-1)?F():(f=!0,C&&(R+=2))),"]"===y.substr(0,1)&&"}"!==d.substr(-1)&&"}"===d.trimRight().substr(-1)&&(f=!1,w++,F()),")"===y.substr(0,1)&&"("!==d.substr(-1)&&"("===d.trimRight().substr(-1)&&(f=!1,w++,F()),B()):"keyword.operator"!==c.type&&"keyword"!==c.type||!y.match(/^(=|==|===|!=|!==|&&|\|\||and|or|xor|\+=|.=|>|>=|<|<=|=>)$/)?"punctuation.operator"===c.type&&";"===y?(F(),S(),b=!0,C&&R++):"punctuation.operator"===c.type&&y.match(/^(:|,)$/)?(F(),S(),b=!0,p=!1):"support.php_tag"!==c.type||"?>"!==y||p?a(c,"attribute-name")&&d.substr(-1).match(/^\s$/)?f=!0:a(c,"attribute-equals")?(B(),S()):a(c,"tag-close")&&(B(),"/>"===y&&(f=!0)):(F(),f=!0):(F(),S(),f=!0,b=!0),p&&(!c.type.match(/^(comment)$/)||y.substr(0,1).match(/^[/#]$/))&&(!c.type.match(/^(string)$/)||y.substr(0,1).match(/^['"]$/))){if(w=$,g>k)for(w++,n=g;n>k;n--)_[n]=w;else g<k&&(w=_[g]);for(k=g,$=w,x&&(w-=x),O&&!v&&(w++,O=!1),n=0;n<w;n++)d+=u}if("keyword"===c.type&&y.match(/^(case|default)$/)&&(j[g]=y,g++),"keyword"===c.type&&y.match(/^(break)$/)&&j[g-1]&&j[g-1].match(/^(case|default)$/)&&g--,"paren.lparen"===c.type&&(v+=(y.match(/\(/g)||[]).length,g+=y.length),"keyword"===c.type&&y.match(/^(if|else|elseif|for|while)$/)?(O=!0,v=0):!v&&y.trim()&&"comment"!==c.type&&(O=!1),"paren.rparen"===c.type)for(v-=(y.match(/\)/g)||[]).length,n=0;n<y.length;n++)g--,"}"===y.substr(n,1)&&"case"===j[g]&&g--;f&&!p&&(B(),"\n"!==d.substr(-1)&&(d+=" ")),d+=y,b&&(d+=" "),p=!1,f=!1,b=!1,(a(c,"tag-close")&&(I||-1!==l.indexOf(h))||a(c,"doctype")&&">"===y)&&(R=I&&r&&"</"===r.value?-1:1),a(c,"tag-open")&&"</"===y?g--:a(c,"tag-open")&&"<"===y&&-1===m.indexOf(r.value)?g++:a(c,"tag-name")?h=y:a(c,"tag-close")&&"/>"===y&&-1===m.indexOf(h)&&g--,s=T}}c=r}d=d.trim(),e.doc.setValue(d)},t.commands=[{name:"beautify",exec:function(e){t.beautify(e.session)},bindKey:"Ctrl-Shift-B"}]}),ace.require(["ace/ext/beautify"],function(e){"object"==typeof module&&"object"==typeof exports&&module&&(module.exports=e)});
     1 ace.define("ace/ext/beautify",["require","exports","module","ace/token_iterator"],function(e,S,t){"use strict";function B(e,t){return-1<e.type.lastIndexOf(t+".xml")}var F=e("../token_iterator").TokenIterator;S.singletonTags=["area","base","br","col","command","embed","hr","html","img","input","keygen","link","meta","param","source","track","wbr"],S.blockTags=["article","aside","blockquote","body","div","dl","fieldset","footer","form","head","header","html","nav","ol","p","script","section","style","table","tbody","tfoot","thead","ul"],S.beautify=function(e){for(var t,r,a,o=new F(e,0,0),s=o.getCurrentToken(),n=e.getTabString(),i=S.singletonTags,c=S.blockTags,u=!1,m=!1,l=!1,p="",f="",b="",d=0,y=0,h=0,g=0,k=0,$=0,w=0,x=0,v=!1,T=!1,R=!1,O=!1,q={0:0},C={},I=function(){t&&t.value&&"string.regexp"!==t.type&&(t.value=t.value.trim())},_=function(){p=p.replace(/ +$/,"")},j=function(){p=p.trimRight(),u=!1};null!==s;){if(w=o.getCurrentTokenRow(),o.$rowTokens,t=o.stepForward(),void 0!==s){if(f=s.value,k=0,R="style"===b||"ace/mode/css"===e.$modeId,B(s,"tag-open")?(T=!0,t&&(O=-1!==c.indexOf(t.value)),"</"===f&&(O&&!u&&x<1&&x++,R&&(x=1),O=!(k=1))):B(s,"tag-close")?T=!1:B(s,"comment.start")?O=!0:B(s,"comment.end")&&(O=!1),!T&&!x&&"paren.rparen"===s.type&&"}"===s.value.substr(0,1)&&x++,w!==r&&(x=w,r&&(x-=r)),x){for(j();0<x;x--)p+="\n";u=!0,!B(s,"comment")&&!s.type.match(/^(comment|string)$/)&&(f=f.trimLeft())}if(f){if("keyword"===s.type&&f.match(/^(if|else|elseif|for|foreach|while|switch)$/)?(C[d]=f,I(),l=!0,f.match(/^(else|elseif)$/)&&p.match(/\}[\s]*$/)&&(j(),m=!0)):"paren.lparen"===s.type?(I(),"{"===f.substr(-1)&&(v=!(l=!0),T||(x=1)),"{"===f.substr(0,1)&&(m=!0,"["!==p.substr(-1)&&"["===p.trimRight().substr(-1)?(j(),m=!1):")"===p.trimRight().substr(-1)?j():_())):"paren.rparen"===s.type?(k=1,"}"===f.substr(0,1)&&("case"===C[d-1]&&k++,"{"===p.trimRight().substr(-1)?j():(m=!0,R&&(x+=2))),"]"===f.substr(0,1)&&"}"!==p.substr(-1)&&"}"===p.trimRight().substr(-1)&&(m=!1,g++,j()),")"===f.substr(0,1)&&"("!==p.substr(-1)&&"("===p.trimRight().substr(-1)&&(m=!1,g++,j()),_()):"keyword.operator"!==s.type&&"keyword"!==s.type||!f.match(/^(=|==|===|!=|!==|&&|\|\||and|or|xor|\+=|.=|>|>=|<|<=|=>)$/)?"punctuation.operator"===s.type&&";"===f?(j(),I(),l=!0,R&&x++):"punctuation.operator"===s.type&&f.match(/^(:|,)$/)?(j(),I(),u=!(l=!0)):"support.php_tag"!==s.type||"?>"!==f||u?B(s,"attribute-name")&&p.substr(-1).match(/^\s$/)?m=!0:B(s,"attribute-equals")?(_(),I()):B(s,"tag-close")&&(_(),"/>"===f&&(m=!0)):(j(),m=!0):(j(),I(),l=m=!0),u&&(!s.type.match(/^(comment)$/)||f.substr(0,1).match(/^[/#]$/))&&(!s.type.match(/^(string)$/)||f.substr(0,1).match(/^['"]$/))){if(g=h,y<d)for(g++,a=d;y<a;a--)q[a]=g;else d<y&&(g=q[d]);for(y=d,h=g,k&&(g-=k),v&&!$&&(g++,v=!1),a=0;a<g;a++)p+=n}if("keyword"===s.type&&f.match(/^(case|default)$/)&&(C[d]=f,d++),"keyword"===s.type&&f.match(/^(break)$/)&&C[d-1]&&C[d-1].match(/^(case|default)$/)&&d--,"paren.lparen"===s.type&&($+=(f.match(/\(/g)||[]).length,d+=f.length),"keyword"===s.type&&f.match(/^(if|else|elseif|for|while)$/)?(v=!0,$=0):!$&&f.trim()&&"comment"!==s.type&&(v=!1),"paren.rparen"===s.type)for($-=(f.match(/\)/g)||[]).length,a=0;a<f.length;a++)d--,"}"===f.substr(a,1)&&"case"===C[d]&&d--;m&&!u&&(_(),"\n"!==p.substr(-1)&&(p+=" ")),p+=f,l&&(p+=" "),l=m=u=!1,(B(s,"tag-close")&&(O||-1!==c.indexOf(b))||B(s,"doctype")&&">"===f)&&(x=O&&t&&"</"===t.value?-1:1),B(s,"tag-open")&&"</"===f?d--:B(s,"tag-open")&&"<"===f&&-1===i.indexOf(t.value)?d++:B(s,"tag-name")?b=f:B(s,"tag-close")&&"/>"===f&&-1===i.indexOf(b)&&d--,r=w}}s=t}p=p.trim(),e.doc.setValue(p)},S.commands=[{name:"beautify",exec:function(e){S.beautify(e.session)},bindKey:"Ctrl-Shift-B"}]}),ace.require(["ace/ext/beautify"],function(e){"object"==typeof module&&"object"==typeof exports&&module&&(module.exports=e)});