I need to sanitize HTML submitted by the user by closing any open tags with correct nesting order. I have been looking for an algorithm or Python code to do this but haven\'
Run it through Tidy or one of its ported libraries.
Try to code it by hand and you will want to gouge your eyes out.