admin管理员组文章数量:1401783
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 mand line on all files in the same time.
Edit : Any other solution?
Thank you,
Bat
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 mand line on all files in the same time.
Edit : Any other solution?
Thank you,
Bat
5 Answers
Reset to default 3HtmlTidy should do the trick for HTML files at least.
Here's an example:
#$ cat test.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html><head><title>Test page
</title></head><body><b>Hello World</b>
</body>
</html>
#$ tidy -i -q test.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Linux (vers 25 March 2009), see www.w3">
<title>Test page</title>
</head>
<body>
<b>Hello World</b>
</body>
</html>
aioobe@e6510:~/tmp$
Add -m
if you want tidy
to actually modify the files. (And yes, you can supply multiple files at once :-)
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 mand line invocation, read this link. Copy pasting for reference:
<path-to-eclipse>\eclipse.exe -vm <path-to-vm>\java.exe -application org.eclipse.jdt.core.JavaCodeFormatter -verbose -config <path-to-config-file>\org.eclipse.jdt.core.prefs <path-to-your-source-files>\*.java
Similarly use for formatting other source like HTML, XML etc
DrJava( http://drjava/ ) has a mand line tool for indenting java files if I remember right.
Yes it does http://drjava/docs/user/apc.html
You can try checkstyle http://checkstyle.sourceforge/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.
An IDE. And extensions for Javascript.
本文标签: javascriptScript or program for indenting automatically Java and HTML filesStack Overflow
版权声明:本文标题:javascript - Script or program for indenting automatically Java and HTML files - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744328900a2600865.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论