I’ll write it if I have to but I’m hoping someone else has already done this. In today’s online world, most users prefer to input HTML directly into online discussion forums, comment boxes, and various other text areas. Additionally , remote sources of information often contain HTML (such as RSS feeds and the like). The problem is that the “tag soup” that some people choose to use barely resembles HTML at all.
I’m looking for a PHP function that cleans up other people’s mess. The most basic example would simply be something that closed all open tags in order to prevent styling from bleeding into other portions of the page that holds the external or user supplied information. A more advanced script might convert sloppy code into valid XHTML making guesses when the code is so bad that is can be easily decided where one style stops and another begins.
Does anyone have any code, or know of an existing piece of code that does this?
Perhaps the LazyWeb can help?