Search code examples
csswysihtml5

How Can WYSIHTML5 output inline CSS?


I am running WYSIHTML5 to allow myself to enter email text and format it for sending as HTML. However when I view HTML of the formatted text I get classes associated with elements for Colors. This is expected behavior but since I need to send the output in an email hence I would like to have those colors to be in Inline CSS, since I cannot attach CSS files with the email like that. Example here

<span class="wysiwyg-color-green">Testing</span>

That is if I select green color for text: Testing. Is there any way to modify that green to become part of html itself like

<span style="color:green">Testing</span>

I have tried to search for this but could not find, so I am not asking without first looking for it. If anybody could please just point somewhere. Even a link to any guide to this, will do. I do not wish that you spend time writing code for me.


Solution

  • You could do it with php :

    str_replace ( 'class="wysiwyg-color-green"', 'style="color:green"' ,$html)
    

    You can do the same with javascript, altrough it's always safer to do everything server-side. http://www.w3schools.com/jsref/jsref_replace.asp