javascripthtmlckeditornewlinewysiwyg

Removing unwanted newline characters when adding <p> in CKEditor


When loading content with a set of paragraphs in CKEditor, it replaces my <p> tags with <p>&#x9;

That means the editor converts this:

<p>paragraph 1</p>
<p>paragraph 2</p>
<p>paragraph 3</p>

into what ends up like this:

<p>
   paragraph 1</p>
<p>
   paragraph 2</p>
<p>
   paragraph 3</p>

How do I fix it so that CKEditor doesn't add the extra newline characters when it sees the paragraph tags?


Solution

  • Add this line to the ckeditor.js configuration file:

    n.setRules('p',{indent:false,breakAfterOpen:false});
    

    More about the formatting of the HTML Writer can be found in Developers Guide: Output Formatting at CKSource Docs.