Item6068: WYSIWYG removes linebreaks from pre-tag

pencil
Priority: Normal
Current State: Closed
Released In: 1.1.0
Target Release: minor
Applies To: Extension
Component: WysiwygPlugin
Branches:
Reported By: TWiki:Main.CedricWeber
Waiting For:
Last Change By: KennethLavrsen
After editing a topic that contains pre-Tags with wysiwyg all linebreaks are deleted.

e.g. create a topic with raw-edit

<pre>
Test
Test
Test
</pre>

edit and save with wysiwyg:

<pre>test test test</pre>

-- TWiki:Main/CedricWeber - 14 Oct 2008

Closing.

Same as http://foswiki.com/Tasks/Item6068

-- MartinCleaver - 08 Jan 2009

MMM. Martin you point the bug to itself and closes the bug???

Re-opening

-- KennethLavrsen - 04 Jul 2009

Okay guys, any ideas? Any flash of inspiration what causes this bug?

-- SvenHess - 15 Jul 2009

I believe I solved the problem in my 1.0.6 installation with the patch below. I would be grateful for a confirmation or a correction to my approach.
diff -ur WysiwygPlugin/TML2HTML.pm WysiwygPlugin-patched/TML2HTML.pm
--- WysiwygPlugin/TML2HTML.pm   2009-06-21 23:22:23.000000000 +0200
+++ WysiwygPlugin-patched/TML2HTML.pm   2009-08-02 16:22:47.000000000 +0200
@@ -493,7 +493,7 @@
         }
     }
 
-    $this->_putBackBlocks( $text, 'pre' );
+    $this->_putBackBlocks( $text, 'pre', 'pre', \&_protectVerbatimChars );
 
     $this->_putBackBlocks( $text, 'literal', 'div' );
 

-- FulvioScapin - 02 Aug 2009

@FulvioScapin: I tried your patch and it does honor linefeeds and spaces, but HTML entities are shown as &entity;:
<pre>
 &lt;-- at the beginning
two spaces here --&gt;[  ]
</pre>
looks like this in TinyMCE:

 &lt;-- at the beginning
two spaces here --&gt;[  ]
Note the additional linefeed at the beginning. Is this OK?
Plus, the PRE box is rendered 2 lines tall in Firefox 3.5, but that happened before your patch.

-- ArielCornejo - 11 Sep 2009

This works on trunk, except that TMCE itself eats the newline after the <pre> tag, so
<pre>
Test
Test
Test
</pre>
becomes
<pre>Test
Test
Test
</pre>
However, the presentation is the same before and after removal of the newline so I do not think that is a problem.

I have added unit tests to ensure that this stays fixed. Changing state to "waiting for release". (If you disagree, please change it back smile )

-- MichaelTempest - 13 Jun 2010

ItemTemplate edit

Summary WYSIWYG removes linebreaks from pre-tag
ReportedBy TWiki:Main.CedricWeber
Codebase
SVN Range TWiki-5.0.0, Sun, 05 Oct 2008, build 17588
AppliesTo Extension
Component WysiwygPlugin
Priority Normal
CurrentState Closed
WaitingFor
Checkins distro:7ab0c84a0192
TargetRelease minor
ReleasedIn 1.1.0
Topic revision: r9 - 04 Oct 2010, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy