0

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?

Quad6
  • 385
  • 2
  • 5
  • 19
  • 1
    What does *"it doesn't always clean the input on paste"* mean? – Madbreaks Jan 23 '13 at 23:19
  • 2
    Does it really create a tag like this ` – PeeHaa Jan 23 '13 at 23:21
  • @Madbreaks, it has a setting to automatically clean any formatting when you paste text but this doesn't always work (depending on browser, source copied from etc). It's when text is copy/pasted that these inline styles creep in. – Quad6 Jan 24 '13 at 01:39

1 Answers1

0

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.

Community
  • 1
  • 1
elboletaire
  • 5,180
  • 2
  • 36
  • 46