• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item4789: Wysiwyg edit breaks %EDITTABLE{}%

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine WysiwygPlugin Normal No Action Required   n/a  

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

The %EDITTABLE{}% tag must be directly adjacent to a table for it to work. '<p>' tags are inserted along with newlines at some point in the HTML2TML conversion. These newlines are not always removed. Since newlines have no structural significance in HTML, it is safe (and correct) to remove all newlines at the beginning of conversion, as long as care is taken not to join words previously seperated by a newline.

Use case:

 #!/bin/env perl
use lib "/apps/backed_up/twiki/run/twiki/lib";
use lib "/apps/backed_up/twiki/run/twiki/lib/CPAN/lib";

use TWiki::Plugins::WysiwygPlugin;

$tml = "\%EDITTABLE{}\%\n| 1 | 2 |\n| 3 | 4 |";
print "TML:\n".$tml."\n";

$html = TWiki::Plugins::WysiwygPlugin::TranslateTML2HTML($tml, "", "");
print "\nHTML:\n".$html."\n";

$tml = TWiki::Plugins::WysiwygPlugin::TranslateHTML2TML($html, "", "");
print "\nBACK TO TML:\n".$tml."\n";

print "\n\n\n";
$html = "This is one\nsentence.";
print "\nHTML:\n".$html."\n";

$tml = TWiki::Plugins::WysiwygPlugin::TranslateHTML2TML($html, "", "");
print "\nTML:\n".$tml."\n";

Patch: HTML2TML/Node.pl

diff:
--- Node.pm.orig        2007-09-17 14:08:02.000000000 -0700
+++ Node.pm.current     2007-10-02 11:51:07.000000000 -0700
@@ -187,6 +187,8 @@
         }
                                                                                                                                                    
+       $tml =~ s/\n/$WC::CHECKw/go unless ($protect);
+
         # isolate whitespace checks and convert to $NBSP
         $tml =~ s/$WC::CHECKw$WC::CHECKw+/$WC::CHECKw/go;
         $tml =~ s/(?<=[$WC::CHECKn$WC::CHECKs$WC::NBSP $WC::TAB$WC::NBBR])$WC::CHECKw//go;
@@ -203,8 +205,6 @@
                                                                                                                                                    
         # isolate $NBBR and convert to \n.
         unless ($protect) {
-            $tml =~ s/\n$WC::NBBR/$WC::NBBR$WC::NBBR/go;
-            $tml =~ s/$WC::NBBR\n/$WC::NBBR$WC::NBBR/go;
             $tml =~ s/$WC::NBBR( |$WC::NBSP)+$WC::NBBR/$WC::NBBR$WC::NBBR/go;
             $tml =~ s/ +$WC::NBBR/$WC::NBBR/go;
             $tml =~ s/$WC::NBBR +/$WC::NBBR/go;


Ah, if only it were that simple. Unfortunately that patch breaks four unit testcases, all related to PRE.

Tthe specific example you gave above works without any code changes. Here's proof (edit this topic and save it):

1 2 3

CC

If you could please point me to the unit tests, I'll run future patches against it and make unit tests for my bugs.

--Buck

-- TWiki:Main.BuckGolemon - 09 Oct 2007

Confirmed this is not an issue with current code, but shows up after changing options from VERY_CLEAN to KEEP_WS, as described in http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item4790.

If you could please point me to the unit tests, I'll run future patches against it and make unit tests for my bugs.

-- TWiki:Main.BuckGolemon - 09 Oct 2007

TWiki:Codev.TestCasesTutorial smile

-- TWiki:Main.SvenDowideit - 11 Oct 2007

Buck, I confess I haven't kept the unit tests up to date for all values of options. The unit tests will pass for current values of the options, but I expect you will see a lot of failures if you flip to KEEP_WS.

CC

ItemTemplate
Summary Wysiwyg edit breaks %EDITTABLE{}%
ReportedBy TWiki:Main.BuckGolemon
Codebase

SVN Range TWiki-4.3.0, Sat, 06 Oct 2007, build 15172
AppliesTo Engine
Component WysiwygPlugin
Priority Normal
CurrentState No Action Required
WaitingFor

Checkins

TargetRelease n/a
ReleasedIn

Edit | Attach | Watch | Print version | History: r10 < r9 < r8 < r7 < r6 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r10 - 2007-10-15 - CrawfordCurrie
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback