Any way to mass auto indent php and html code in Ubuntu?

I regularly use a tool called HTML Tidy to clean up dirty HTML. The Ubuntu package is simply called "tidy".

For PHP there seems to exist a tool called phptidy, but apart from testing if it works, I never used it.


If you have worked with Python before and the code is HTML or XML, then I would suggest using BeautifulSoup and automate the process for all files. In a Python console run this:

from bs4 import BeautifulSoup
soup = BeautifulSoup(html_doc)
print(soup.prettify())

Here html_doc is just the text of the file to be indented.

Or the non-geeky was is to use some IDE to get it done individually.

Tags:

Html

Php