I'm aware that I can use filter()
to select html elements from the DOM. In order to make sure that the html is following current html5 standards, I would like to replace elements like <u>
or a bit more exotic <strike />
with their current standard counterparts or remove them at all, where appropriate. So I could do
$('strike, s').each(function(index){
$(this).replaceWith('<span>'+$(this).contents()+'</span>').css('text-decoration','line-through');
});
My question: Is there a way to select non-valid or deprecated without explictly enumerating them in the selector? Which would be impossible if somebody uses a custom tag like <mytag />
or so? I was thinking of making use of DTD's but wouldn't really know an efficient way to do so?
This is to be used with node server-side to optimize html.