I’m using the Redactor WYSIWYG editor but I’m finding it doesn’t always clean the input on paste as it should.
So we’re ending up with things like:
<p><span style="font:12px arial; margin: 10px">blah blah blah</span></p>
<pstyle="font-family:Georgia: font-size:14px">more blah blah</span></p>
I would just like to clean the attributes, specifically style="" on p, a, div or span tags.
Is there a solid class or regex out there I can use?
Try DOMDocument:
Parse HTML with PHP's HTML DOMDocument
http://php.net/manual/en/class.domdocument.php
Edit: btw, you maybe also should reconsider the WYSIWYIG editor you’re using.. I’ve been working with ckeditor, tinymce and, lately, with aloha editor and all three parse the data as expected. In addition, all three have methods to parse the on-paste-data at your liking.