Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to break lines properly which contain both CJK and english characters in WordPress?

I found that CJK article in my wordpress4.7 can't break lines properly,which contain both CJK and english characters.
Here is the article before publish.

enter image description here

All the lines breaked properly before publish.

enter image description here

Now it displayed as below after published. All lines messed ,breaked bad-formatted as unexpected way.

enter image description here

I had tried to fix it this way.

vim  /var/www/html/wp/wp-content/themes/twentysixteen/style.css 
.site-inner {
    margin: 0 auto;
    max-width: 1320px;
    position: relative;
}

.site-content {
    word-wrap: break-word;overflow:hidden;
    word-break:break-all;white-space:pre-wrap;
}

To restart apache and wordpress,no effect at all.
My wordpress version is 4.7,theme is twentysixteen.

like image 949
showkey Avatar asked Dec 11 '16 15:12

showkey


2 Answers

try to add this code in your functions.php theme file

    function my_tinymce_fix( $init )
    {
        // html elements being stripped
        $init['extended_valid_elements'] = 'div[*], article[*]';

        // don't remove line breaks
        $init['remove_linebreaks'] = false;

        // convert newline characters to BR
        $init['convert_newlines_to_brs'] = true;

        // don't remove redundant BR
        $init['remove_redundant_brs'] = false;

        // pass back to wordpress
        return $init;
    }
    add_filter('tiny_mce_before_init', 'my_tiny_mce_fix');
like image 58
Sofiane Achouba Avatar answered Oct 27 '22 14:10

Sofiane Achouba


Try word press plugin. TinyMCE Advanced

There is option to disable automatically remove of br tag and p tag from setting page of plugin.

like image 43
Ash Patel Avatar answered Oct 27 '22 14:10

Ash Patel