I've used both TinyMCE and CKEditor, and can always replicate this bug very easily.

Every time I enable or disable the editor (clicking the toggle below the editor area), an empty paragraph (<p>&nbsp;</p>) is added before any <hr /> (horizontal rule) on the page. Also, if the

is mixed in with a block of text, another <p>&nbsp;</p> is added in after that block of text...

If I keep toggling the rich text editor on and off, on and off, then I get a very large gap in the content anywhere there's an HR...

Is there some way I can quickly fix this problem?


geerlingguy’s picture

Possibly related topic on the TinyMCE forum:

Also, a possibly related topic here (although not exactly the same): #550428: Tags like "&nbsp;" or "<p>&nbsp;</p>" or "<br />" added to empty textareas.

[Edit: Even if I simply go to view HTML in TinyMCE, or toggle the 'Source' view in CKEditor, the extra lines are added in with more &nbsp;'s).

geerlingguy’s picture

Status: Active » Closed (fixed)

Nevermind... I found this to be a problem caused by the linebreaks.js file... moved discussion to here: #513998: Plugin to convert p- and br-tags to newlines

cangeceiro’s picture

Version: 6.x-2.x-dev » 7.x-2.1
Status: Closed (fixed) » Active

This bug is active in the 7.x branch as well. And I also see this happen when adding content and doing the initial save.

Steps to reproduce:

* Author content
* save
* toggle disable rich text editor

each time an additional


is added

here is a paste of content i have created after toggling several times

<strong>Kids &amp; Teens (19 &amp; under)</strong></p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>
<meta charset="utf-8">
TwoD’s picture

Status: Active » Closed (won't fix)

I tried pasting the source you posted into the Source view on http://ckeditor.com/demo and toggling back and forth between WYSIWYG and Source views. It kept adding <p>&nbsp;</p> until I removed the meta tag from the content.
Meta tags are invalid in anything but the head tag so I can see why this edge case could confuse the editor.
SO: What happens if the meta tags are present in the document body?.

I'm changing this to "won't fix" since both instances of this problem involves invalid markup and the last example was also reproducible on the official editor demo.

cangeceiro’s picture

Ah i see, i can confirm your findings as well. However isn't there an option to strip out these tags? I switched to the ckeditor drupal module and it seems to be stripping out the meta tag thus preventing this issue.