Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#6610 closed defect (bug) (fixed)

When saving in Firefox, TinyMCE alters the inside of <pre> and <code> tags.

Reported by: asandler Owned by: azaozz
Milestone: 2.5.1 Priority: normal
Severity: normal Version: 2.5
Component: TinyMCE Keywords: tinymce, has-patch
Focuses: Cc:

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 (1)

editor.patch (3.9 KB) - added by azaozz 14 years ago.
Protect the <pre> and <script> tags when switching editors

Download all attachments as: .zip

Change History (7)

#1 @azaozz
14 years ago

  • Owner changed from anonymous to azaozz
  • Status changed from new to assigned

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.

#2 @asandler
14 years ago

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).

#3 @dara_masala
14 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:

  1. Browse to write a new post.
  2. Switch to HTML view.
  3. Write something with several lines between pre tags.
  4. 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

@azaozz
14 years ago

Protect the <pre> and <script> tags when switching editors

#4 @azaozz
14 years ago

  • Keywords has-patch added; editor firefox space indentation pre code indent tab tabulation removed

#5 @ryan
14 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [7716]) Protect the <pre> and <script> tags when switching editors. Props azaozz. fixes #6610 for trunk

#6 @ryan
14 years ago

(In [7717]) Protect the <pre> and <script> tags when switching editors. Props azaozz. fixes #6610 for 2.5

Note: See TracTickets for help on using tickets.