Here's a solution that replaces HTML5 block tags while keeping the style in divs replacing HTML5 tags. Simple tag substitution leaves attributes behind.
$('article, aside, figcaption, figure, footer, header, nav, section, source') .each(function(){ var el = $(this), html = el.html(), attrs = { "id": el.attr('id'), "classes": el.attr('class'), "styles": el.attr('style') }; console.log('Replacing ' + el.prop('tagName') + ', classes: ' + attrs.classes); el.replaceWith($('<div></div>').html(html).attr(attrs)); });
(it may take a little more work with the original tag, which has the attributes "src" and "type")
source share