Background:-
Am using a JS editor on my site. Now when I copy paste external text content on it, there are a few invalid/incomplete html tags that get pasted. ( But it is not made visible on the editor)

Problem:-
Now when this data is posted, the alignment of the entire page gets screwed. How can I detect and change incomplete html tags if any. Should I use a html parser for this purpose ?
As you can see the edit and delete buttons have come out of the div. (The description or data has been copy pasted)
You could try the fantastic Beautiful Soup library for all your parsing needs. Buy now!