Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this questionI've run into a problem. Someone on our team edited a HTML/P开发者_高级运维HP file, and the entire contents of the file ended up on a single line. All line breaks and tabs were completely removed from the file. Its a very large file, so trying to edit it manually would take forever.
Does anyone know of a tool I can use to re-format the code?
Use the NetBeans IDE, for the development purpose. Then open the file in that IDE and press these keys at the same time - Alt + Shift + F.
The file will get formatted nicely, and also will show you if there are any errors in that file.
You could use DOMDocument
to tidy the HTML.
$dom = new DOMDocument();
$dom->preserveWhiteSpace = FALSE;
$dom->loadHTML($html);
$dom->formatOutput = TRUE;
echo $dom->saveHTML();
You can use tidy (html only) or codecleaner
(First link removed per comment below.)
http://www.phpformatter.com/ is an option.
Visual Studio. Open the HTML file then press ctrl k then ctrl d (or use the edit menu).
In Aptana or Zend Studio or Eclipse PHP, you can press CTRL + SHIFT + F to auto format your code. Remember to fix all syntax errors before.
精彩评论