Linux automated code formatting (PHP, JavaScript, HTML, CSS, MySQL)

帅比萌擦擦* 提交于 2019-12-12 13:07:31

问题


I am seeking a Linux or PHP program to automate code formatting. Optimally it would handle many languages, but the priority is (highest first): PHP, JavaScript, HTML, CSS and MySQL. Comparability is nice, but not the most important feature.

Context / use: automation via Subversion post-commit. I'm working with teams and want to always follow a single method of formatting.


回答1:


Astyle is the canonical answer if you insist on just one.

You likely cannot get a single formatter for many langauges that understands their syntax, and you can't afford to get the syntax wrong, because you don't want the formatter to break code (especially after it has just been checked in!) [Astyle works on several because it accepts only C-like langauges]. See Semantic Designs Formatters for such tools for many langauges that do understand syntax accurately and can't make such mistakes.




回答2:


Check out Geany. It is in the Ubuntu repos and its the best PHP IDE I've used yet.

EDIT: 8 year update: try VS Code. Its my main IDE for most everything these days.




回答3:


I find that using an IDE such as Eclipse or Aptana will accomplish this task very easily. It's not automated but if all developers use an IDE this is very simple



来源:https://stackoverflow.com/questions/1376958/linux-automated-code-formatting-php-javascript-html-css-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!