Nice md, but sorry, that does NOT take in any consideration whatsoever the essential issue - which is <whatever> properly followed by a </whatever>.

There is no logic at all to deal with determining if a tag is properly closed. Yes it lists them..which is good I suppose, but there is no logic to deal with incorrect ones. I mean if you want to get the list, simply extract all text strings that are between < and >. Would be much simpler.