0

I'm searching a java library that formats/beautifies a given source code snippet. The library should support at least PHP and JavaScript source files.

The reason why i'm searching this is because the code that i generate with my Java application from a REST API description looks not to appealing. I am generating the source files with FreeMarker template engine and i don't want to implement all the formatting logic in the template files. It should be possible that way, but it makes the template files a lot harder to maintain.

2
  • Do you want to do it as part of the build process or is it OK if you run this beautifier at will? Commented May 6, 2013 at 12:42
  • It should be sufficient to run the beautifier as a build process. Commented May 14, 2013 at 8:45

1 Answer 1

2

EDIT. After reading your comment, I would say: invoke the external beautifier from within you build script.

For Javascript, this SO question may help. Disclosure: I'm the coauthor of JSBeautifier described in the answer (actually, I work on the Python modules). Essentially, use rhino as the interpreter for JSBeautifier.

For PHP, a quick search brought PHP Beautifier to my attention.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.