src/pyams_skin/resources/js/ext/ace/ext-beautify.min.js
changeset 501 2f0eb9a77324
child 504 fb5a531cddbe
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_skin/resources/js/ext/ace/ext-beautify.min.js	Thu Dec 20 18:41:40 2018 +0100
@@ -0,0 +1,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)});