0

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.

Nicolas Zimmer
  • 424
  • 4
  • 10
  • Nope, there's no way to select deprecated tagNames, and old'ish IE won't even select them until you've created an element with the same invalid tagname etc. – adeneo Sep 10 '14 at 16:53
  • [There is no HTML5 DTD](http://stackoverflow.com/questions/4053917/where-is-the-html5-document-type-definition). And even if there were one (you can use [this](http://blogs.msdn.com/b/webdevtools/archive/2009/11/18/html-5-intellisense-and-validation-schema-for-visual-studio-2008-and-visual-web-developer.aspx), after all), you'd still have to map all the 'missing' elements to some specific decorators. – raina77ow Sep 10 '14 at 16:55
  • @raina77ow Thanks for pointing me there, so it would have to be some kind of other schema then. – Nicolas Zimmer Sep 10 '14 at 17:01
  • 1
    custom tags are just now starting to work. and you want to break them on purpose? – dandavis Sep 10 '14 at 17:48
  • actually I must since the html documents are required to be strict standard (if you can say so for html5) - don't blame me, blame http://idpf.org to include only this set in epub 3.0 standard... – Nicolas Zimmer Sep 10 '14 at 22:16

0 Answers0