Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
Clean Word Formatting not cleaning styles
posted

Hi, 

We've been facing some problems with our application because the Clean Word Formatting does not clean style and class attributes.

Here you can see a piece of html before cleaning:

<P style="MARGIN: 0in 0in 0pt 0.25in; TEXT-INDENT: -0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1"><SPAN style="FONT-SIZE: 12pt; LINE-HEIGHT: 115%"><FONT face=Calibri><B style="mso-bidi-font-weight: normal"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></B></FONT></SPAN></P>  <P style="MARGIN: 0in 0in 10pt"><SPAN style="FONT-SIZE: 12pt; LINE-HEIGHT: 115%"><FONT face=Calibri>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean in arcu neque, <B style="mso-bidi-font-weight: normal">quis ornare mauris</B>.<o:p></o:p></FONT></SPAN></P>

And after cleaning:

<p style="margin: 0in 0in 0pt 0.25in; text-indent: -0.25in; mso-add-space: auto; mso-list: l0 level1 lfo1;" class="MsoListParagraphCxSpFirst"> <font face="Calibri"><b style="mso-bidi-font-weight: normal;"></b></font></p>
<p style="margin: 0in 0in 10pt;" class="MsoNormal"> <font face="Calibri">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean in arcu neque, <b style="mso-bidi-font-weight: normal;">quis ornare mauris</b>.</font></p>

Is there any way to get a cleaner code?

We noticed that the code is cleaner when using FireFox or Chrome. Here the code after cleaning in FireFox:

<p> <font face="Calibri"><b style="mso-bidi-font-weight: normal"><!--?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /--></b></font></p> &nbsp; <p> <font face="Calibri">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean in arcu neque, <b style="mso-bidi-font-weight: normal">quis ornare mauris</b>.</font></p>

Thanks, 

Alejandro

  • 13438
    posted

    Hello Alejandro,

    This property is used to remove all the tags  inserted while pasting from word. Each browser may have interpret copy-from-Word differently and use different tags. WebHtmlEditor can do nothing about that. That is not only one difference between IE and standard browsers. For example, while doing font formatting (execCommand) the IE inserts <font>, but the two webkit browsers – FF and Chrome insert </span>. If you want to clear more tags you should do it manually.