I wonder if this should be a part of HTML Janitor? We already use that in a formatter. (See code comment above.)