'Do not inserting paragraphs where should be linebreaks when copying from word
I have a clueless person as editor on a wordpress site of mine. This person creates their text using MS Word (don't ask me why) they he proceeds to copy from word into Tiny MCE Editor on Wordpress.
His big complain is that everything that was linebreaks on word becomes paragraps on wordpress.
So a text that is like that on word...
The quick brown
fox jumps over
the lazy dog
that should be pasted as
<p>The quick brown<br>
fox jumps over<br>
the lazy dog</p>
is pasted like
<p>The quick brown</p>
<p>fox jumps over</p>
<p>the lazy dog</p>
it that something that can be done to fix that? (No, he doesn't want to paste a clean text and having to reformat the whole thing).
Solution 1:[1]
Well wpautop might be what you're looking for. Tho in your example there is no actual difference in the end result. 3 lines in both cases.
wpautop()
Replaces double line breaks with paragraph elements.
<?php
remove_filter( 'the_content', 'wpautop' );
Solution 2:[2]
The issue here is likely how the document is created in Word. When you press Enter in Word you are creating a new block (e.g. Paragraph). If you press SHIFT+Enter you are inserting a line break.
When you copy the Word doc it makes an HTML representation of the content and uses blocks (paragraphs) or line breaks (<br> tags) based on how the document was created.
If you want to change this once it is pasted you could use a variety of the configuration options for the paste plugin:
https://www.tiny.cloud/docs/plugins/opensource/paste/
The most likely candidate is the paste_postprocess option which allows you to transform the data however you like via code after the paste plugin has completed its work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | amarinediary |
| Solution 2 | Michael Fromin |
