1

About to kick-off an 1.x to 2.x upgrade.

For the most part the site is in decent shape. Unfortunately though we're dealing with some WYSIWYG fields where content that's been pasted from Word and other horrible places where the HTML is pretty ridiculous.

I've already ran it through a tag stripper for XML import but we still have a host of classes on p tags and inline styles.

I had thought about using XSLT to strip the crap from the XML but not sure where I'd even start here.

Any suggestions or known methods?

1

So, I'm not sure if this would be sufficient or even what you're looking for (if there's loads of content this will be tedious), but first thing I thought of was just doing it frontend with jQuery:

$('#textDiv').find('*').each(function() {
    $(this).removeAttr('class').removeAttr('style');
});

And then copy the HTML from Firebug.

Then I got really self-conscious about my suggestion and searched a little, and found this: HTML Purifier that seems to be exactly what you're looking for.

2
  • yeah, I really want the content cleansed before it even gets into EE. The content import is an XML feed. The HTML Purifier tool has an EE plugin but it still left the classes and style attributes because they're both valid. Mar 15 '13 at 17:08
  • There is a setting for allowed attributes, here, could probably be set to Null to strip all attributes.
    – megatrond
    Mar 15 '13 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.