Is there any open source library that can turn malform HTML into well formatted (not just pretty printed) HTML , like what firebug does?
For example,
<tr class=row><td>content</tr>
may become
<tr class="row"><td>content</td></tr>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t use javascript to fix a broken DOM, because javascript is dependant on the DOM being valid in the first place. You really need to be looking into the server-side portion of your system instead, if that’s outputting invalid HTML then that’s the part of the system you need to fix.
If you actually mean that you want your markup to be pretty-printed, and assuming you’re using PHP, you could install the Tidy extension (http://php.net/manual/en/book.tidy.php). If you can’t or don’t want to install extensions, or aren’t running PHP but are using a scripting language that can run shell commands, then you could use an external shell command such as htmltidy (http://en.wikipedia.org/wiki/HTML_Tidy)