Ticket #6610 (closed defect (bug): fixed)
When saving in Firefox, TinyMCE alters the inside of <pre> and <code> tags.
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 2.5.1 |
| Component: | TinyMCE | Version: | 2.5 |
| Severity: | normal | Keywords: | tinymce,has-patch |
| Cc: | alexander.sandler@… |
Description
When saving a post or a page in Firefox, tinymce removes tabulation characters used for indentation. It also removes extra space characters.
Seen on Firefox 2.0.0.13 and Firefox 3b5.
Attachments
Change History
- Owner changed from anonymous to azaozz
- Status changed from new to assigned
You're right. <code> and <pre> are two different tags. I assumed same problem would happen with <code>. Anyway, I am interested in <pre> tag because this is the tag that tinymce inserts when using "preformatted" style. And I've seen at least four people reporting this problem, so it's not only me.
Another part of this problem is that tinymce removes tabulation (one you normally get by pressing TAB button on your keyboard) symbols as well. Actually, you cannot use TAB directly - it changes focused element of the page (it is another bug, because it works in IE7. only you have to press TAB twice for the first time). However you can paste it from another editor and this is usually what people do with the code (people don't yet write programs in tinymce lol).
comment:3
dara_masala — 4 years ago
The editor also adds an empty line after each line. This empty line disappears after saving and comes back again when editing the post. To reproduce:
- Browse to write a new post.
- Switch to HTML view.
- Write something with several lines between pre tags.
- Switch to Visual view - there is an empty line after each line.
This happens in firefox and ie6 (I didn't test with other browsers).
Doron
-
attachment
editor.patch
added
Protect the <pre> and <script> tags when switching editors
- Keywords tinymce,has-patch added; tinymce,editor,firefox,space,indentation,pre,code,indent,tab,tabulation removed
- Status changed from assigned to closed
- Resolution set to fixed

The <pre> and <code> tags are quite different. Generally <code> is an inline phrase element like <strong> and <em>, so it doesn't preserve white space or line breaks.
The only HTML tag that preserves white space is <pre>, however there's a small bug in the js wpautop that eventually will remove some spaces if you switch Visual to HTML mode and back several times. I'm working on a patch for this for 2.5.1, until then, for best results format the inside of the <pre> tags from HTML mode prior to saving the post.