This project aims to provide a Java-based code syntax formatter for a diverse range of web languages, including:
- HTML
- Javascript
- PHP
- CSS
- JSP
It allows you to format complex, messy web application code into a more structured format.
To achieve this, it uses specialised reader/writer implementations and a custom parser. As a result, this formatter is quite fragile, so use at your own risk! However, it does come with a set of automated test cases, to ensure that it generally outputs suitable code. It is also used in the IAML project extensively as a code cleaner to its generated code.
Version 0.3 of iacleaner has been released (October 2009).
Quick Start
iacleaner can be installed through an Eclipse update site, or you can checkout the source from SVN and build a JAR file yourself.
File source = new File("script.php");
IACleaner cleaner = new IAInlineCleaner();
String formatted = cleaner.cleanScript(source);
// rewrite the file
FileWriter fh = new FileWriter(source);
fh.write(formatted);
fh.close();Future Work
If a web script cannot be handled properly by iacleaner, please submit it to the issue tracker so this can be resolved.
It would be nice to use an actual syntax parser (e.g. JavaCC) to implement the formatting, but this is easier said than done. Feel free to contribute ;)
Future work may include basic support for code compression.