用于自动缩进 Java 和 HTML 文件的脚本或程序
我想知道您是否有一些自动缩进一些 Java 和 HTML 文件的想法。 HTML 文件可以包含 JavaScript 和 JSP 代码。
理想的程序应该通过命令行同时对所有文件执行。
编辑:还有其他解决方案吗?
谢谢你,
蝙蝠
I'd like to know if you have some idea for indenting automatically some Java and HTML files. The HTML files could contain JavaScript and JSP code.
The ideal program should be executed through the command line on all files in the same time.
Edit : Any other solution?
Thank you,
Bat
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
HtmlTidy 至少应该可以解决 HTML 文件的问题。
下面是一个示例:
如果您希望
tidy
实际修改文件,请添加-m
。 (是的,您可以一次提供多个文件:-)HtmlTidy should do the trick for HTML files at least.
Here's an example:
Add
-m
if you wanttidy
to actually modify the files. (And yes, you can supply multiple files at once :-)使用 eclipse 之类的 IDE。它有一个源清理选项,您可以使用它来设置自己的自定义规则(或使用默认值)来格式化代码。
如果您正在寻找命令行调用,请阅读此链接。复制粘贴以供参考:
类似地用于格式化其他源,如 HTML、XML 等
Use an IDE like eclipse. It has a source cleanup option that you could use to set your own custom rule(or use default) for formatting code.
If you are looking for command line invocation, read this link. Copy pasting for reference:
Similarly use for formatting other source like HTML, XML etc
如果我没记错的话,DrJava( http://drjava.org/ ) 有一个用于缩进 java 文件的命令行工具。
是的,http://drjava.org/docs/user/apc.html
DrJava( http://drjava.org/ ) has a command line tool for indenting java files if I remember right.
Yes it does http://drjava.org/docs/user/apc.html
您可以尝试 checkstyle http://checkstyle.sourceforge.net/cmdline.html。我不确定它是否适用于 html。然而,对于java来说它就像一个魅力,你还可以添加可定制的规则。
You can try checkstyle http://checkstyle.sourceforge.net/cmdline.html. I am not sure if it would work for html. However, for java it works like a charm and you can also add customizable rules.
一个 IDE。 以及 Javascript 扩展。
An IDE. And extensions for Javascript.