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.