Ticket #6610 (closed defect (bug): fixed)

Opened 4 years ago

Last modified 4 years ago

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

Reported by: asandler Owned by: azaozz
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

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

Change History

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

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

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

azaozz4 years ago

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

comment:5   ryan4 years ago

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

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

comment:6   ryan4 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.