• joneiseman

    (@joneiseman)


    For many years I have been able to paste from Word and TinyMCE will automatically strip out the Word specific tags from the html and just leave simple stuff like bold and italic. However, in the last few weeks it has stopped stripping these tags and that can cause problems with formatting on the WordPress site. So, now I have to go into Text mode and manually remove these tags. I’m using Firefox but I also see this problem when using IE. Any ideas what could be causing this problem?

    The inserted code looks something like this:

    <!--[if gte mso 9]><xml>
    <mso:CustomDocumentProperties>
    <mso:ContentType msdt:dt="string">Document</mso:ContentType>
    <mso:Dept. msdt:dt="string">;#All Departments;#</mso:Dept.>
    </mso:CustomDocumentProperties>
    </xml><![endif]-->

Viewing 8 replies - 1 through 8 (of 8 total)
  • esmi

    (@esmi)

    We have always said that you should not paste content from Microsoft Word into WordPress as the pasted text will also contain Word’s own formatting. Sooner or later, this formatting will stop your pages from being displayed correctly (if at all) in Internet Explorer. If you cannot possibly manage without Word, paste your text into NotePad (or another text editor) first, then copy from NotePad into WordPress. Or use Windows LiveWriter or another local blogging tool

    Justin

    (@jgwpk)

    No a good idea to begin with but have you changed the Word version you are using? Have you updated anything? Also I know plugins like TinyMCE Advanced has a feature built in.

    Krishna

    (@1nexus)

    You can try pasting into notepad and then cut and paste from there to the editor.

    Thread Starter joneiseman

    (@joneiseman)

    I knew about “don’t paste from Word into WordPress” as a “solution”. But my question is really why this suddenly stopped working. I don’t think this was a change in Word behavior because Word always included this stuff in the clipboard when you do a copy. TinyMCE always stripped it out until now. The TinyMCE editor does have a feature for Paste from Word but it no longer strips these tags. Pasting into Notepad doesn’t work because you lose all of the formatting information including bold and italic. LiveWriter and other blogging tools don’t work because they convert smartquotes into regular quotes and em dash into a regular dash (and I would like to avoid that).
    The only good workaround I found is to use the http://word2cleanhtml.com/ website to remove the tags and then copy and paste from there into WordPress.

    esmi

    (@esmi)

    hy this suddenly stopped working

    It has never worked properly and the problem has become worse with each update of MS Word. I’ve have seen whole sites brought down in IE 3 and 4 years ago for precisely this problem.

    croakingtoad

    (@croakingtoad)

    You can use “CTRL + SHIFT + V” to paste it without any formatting.

    You’ll lose all formatting but you also won’t get those Microsoft droppings.

    Thread Starter joneiseman

    (@joneiseman)

    If I use Chrome instead of Firefox then it works fine. Apparently Chrome does a better job of removing the Microsoft tags.

    Thread Starter joneiseman

    (@joneiseman)

    I found that I could paste from Word and keep the simple formatting (e.g., bold and italic) but get rid of all the Microsoft Word specific formatting by adding the following to the functions.php (in my theme).

    function change_mce_options( $init ) {
     $init['extended_valid_elements'] = 'span[!class]';
     $init['paste_auto_cleanup_on_paste'] = true;
     $init['paste_strip_class_attributes'] = all;
     $init['paste_remove_styles'] = true;
     return $init;
    }
    add_filter('tiny_mce_before_init', 'change_mce_options');
    
    function get_rid_of_mso_junk( $content ){
      return preg_replace( '/<!--\[if gte mso.*?-->/ms', '', $content );
    }
    add_filter( 'content_save_pre', 'get_rid_of_mso_junk' );

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Paste from Word Problem’ is closed to new replies.