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>
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>
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)