Ignore:
Timestamp:
11/18/09 06:27:14 (3 years ago)
Author:
MichaelTempest
Message:

Item2369: Add rowspan support to the WYSIWYG editor
This also fixed a bug in how Web.WikiWord links are rendered, if the link is the only text in the table cell.

Tables are no longer "normalised" when converting from HTML to TML by appending |'s so that every row has the same number of |'s. The logic to do so when supporting rowspans is complex (read: likely to be buggy) and the "normalisation" feature is seldom used (it only had any effect if the HTML has a table with a hole in it.) Taking out the normalisation does not result in loss of content.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/WysiwygPlugin/test/unit/WysiwygPlugin/ExtendedTranslatorTests.pm

    r5240 r5573  
    3636# Bits for test type 
    3737# Fields in test records: 
    38 my $TML2HTML  = 1 << 0;        # test tml => html 
    39 my $HTML2TML  = 1 << 1;        # test html => finaltml (default tml) 
    40 my $ROUNDTRIP = 1 << 2;        # test tml => => finaltml 
     38my $TML2HTML      = 1 << 0;    # test tml => html 
     39my $HTML2TML      = 1 << 1;    # test html => finaltml (default tml) 
     40my $ROUNDTRIP     = 1 << 2;    # test tml => => finaltml 
    4141my $CANNOTWYSIWYG = 1 << 3;    # test that notWysiwygEditable returns true 
    4242                               #   and make the ROUNDTRIP test expect failure 
     
    6161# is "WysiwygEditable". 
    6262# 
    63 # Use CANNOTWYSIWYG without ROUNDTRIP *only* with an appropriate  
    64 # explanation. For example:  
     63# Use CANNOTWYSIWYG without ROUNDTRIP *only* with an appropriate 
     64# explanation. For example: 
    6565#   Can't ROUNDTRIP this TML because perl on the SMURF platform 
    6666#   automagically replaces all instances of 'blue' with 'beautiful'. 
     
    8585# Each testcase is a subhash with fields as follows: 
    8686# exec => $TML2HTML to test TML -> HTML, $HTML2TML to test HTML -> TML, 
    87 #   $ROUNDTRIP to test TML-> ->TML, $CANNOTWYSIWYG to test  
     87#   $ROUNDTRIP to test TML-> ->TML, $CANNOTWYSIWYG to test 
    8888#   notWysiwygEditable, all other bits are ignored. 
    8989#   They may be OR'd togoether to perform multiple tests. 
     
    102102my $data = [ 
    103103    { 
    104         exec => $TML2HTML | $ROUNDTRIP, 
    105         name => 'UnspecifiedCustomXmlTag', 
    106         setup => sub { 
    107             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     104        exec  => $TML2HTML | $ROUNDTRIP, 
     105        name  => 'UnspecifiedCustomXmlTag', 
     106        setup => sub { 
     107            $extraTML2HTMLOptions{xmltag} = 
     108              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    108109        }, 
    109110        html => '<p>' 
     
    122123        name  => 'DisabledCustomXmlTag', 
    123124        setup => sub { 
    124             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     125            $extraTML2HTMLOptions{xmltag} = 
     126              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    125127            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 
    126128                sub { 0 } ); 
     
    141143        name  => 'CustomXmlTag', 
    142144        setup => sub { 
    143             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     145            $extraTML2HTMLOptions{xmltag} = 
     146              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    144147            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 
    145148                sub { 1 } ); 
     
    155158        name  => 'CustomXmlTagCallbackChangesText', 
    156159        setup => sub { 
    157             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     160            $extraTML2HTMLOptions{xmltag} = 
     161              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    158162            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 
    159163                sub { $_[0] =~ s/some/different/; return 1; } ); 
     
    170174        name  => 'CustomXmlTagDefaultCallback', 
    171175        setup => sub { 
    172             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    173             Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag' ); 
     176            $extraTML2HTMLOptions{xmltag} = 
     177              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     178            Foswiki::Plugins::WysiwygPlugin::addXMLTag('customtag'); 
    174179        }, 
    175180        html => '<p>' 
     
    183188        name  => 'CustomXmlTagWithAttributes', 
    184189        setup => sub { 
    185             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     190            $extraTML2HTMLOptions{xmltag} = 
     191              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    186192            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 
    187193                sub { 1 } ); 
     
    201207        name  => 'NestedCustomXmlTagWithAttributes', 
    202208        setup => sub { 
    203             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     209            $extraTML2HTMLOptions{xmltag} = 
     210              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    204211            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 
    205212                sub { 1 } ); 
     
    226233    { 
    227234        exec => $CANNOTWYSIWYG, 
     235 
    228236        # Do not perform ROUNDTRIP on this TML, because ROUNDTRIP passes. 
    229         # The problem with this TML is that the special handling of  
    230         # <verbatim> in the conversion to HTML messes up the contents  
    231         # of this custom XML  tag, so that the HTML is not representative  
     237        # The problem with this TML is that the special handling of 
     238        # <verbatim> in the conversion to HTML messes up the contents 
     239        # of this custom XML  tag, so that the HTML is not representative 
    232240        # of the TML in terms of intellectual content. 
    233         name => 'VerbatimInsideDot', 
    234         setup => sub { 
    235             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    236             Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'dot', 
    237                 sub { 1 } ); 
     241        name  => 'VerbatimInsideDot', 
     242        setup => sub { 
     243            $extraTML2HTMLOptions{xmltag} = 
     244              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     245            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'dot', sub { 1 } ); 
    238246        }, 
    239247        tml => <<'DOT', 
     
    249257    }, 
    250258    { 
    251         exec => $TML2HTML | $ROUNDTRIP, 
    252         name => 'CustomtagInsideSticky', 
    253         setup => sub { 
    254             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     259        exec  => $TML2HTML | $ROUNDTRIP, 
     260        name  => 'CustomtagInsideSticky', 
     261        setup => sub { 
     262            $extraTML2HTMLOptions{xmltag} = 
     263              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    255264            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 
    256265                sub { 1 } ); 
    257266        }, 
    258         tml => "<sticky><customtag>this & that\n >   the other </customtag></sticky>", 
     267        tml => 
     268"<sticky><customtag>this & that\n >   the other </customtag></sticky>", 
    259269        html => '<p>' 
    260270          . '<div class="WYSIWYG_STICKY">' 
     
    262272          . 'this&nbsp;&amp;&nbsp;that<br />&nbsp;&gt;&nbsp;&nbsp;&nbsp;the&nbsp;other&nbsp;' 
    263273          . '&lt;/customtag&gt;' 
    264           . '</div>' 
    265           . '</p>' 
    266     }, 
    267     { 
    268         exec => $ROUNDTRIP | $CANNOTWYSIWYG, #SMELL: fix this case 
    269         name => 'StickyInsideCustomtag', 
    270         setup => sub { 
    271             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     274          . '</div>' . '</p>' 
     275    }, 
     276    { 
     277        exec  => $ROUNDTRIP | $CANNOTWYSIWYG,    #SMELL: fix this case 
     278        name  => 'StickyInsideCustomtag', 
     279        setup => sub { 
     280            $extraTML2HTMLOptions{xmltag} = 
     281              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    272282            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 
    273283                sub { 1 } ); 
    274284        }, 
    275         tml => "<customtag>this <sticky>& that\n >   the</sticky> other </customtag>", 
     285        tml => 
     286"<customtag>this <sticky>& that\n >   the</sticky> other </customtag>", 
    276287        html => '<p>' 
    277288          . $protecton 
     
    283294          . '&nbsp;other&nbsp;' 
    284295          . '&lt;/customtag&gt;' 
    285           . $protectoff 
    286           . '</p>' 
    287     }, 
    288     { 
    289         exec => $TML2HTML | $ROUNDTRIP, 
    290         name => 'StickyInsideUnspecifiedCustomtag', 
    291         setup => sub { 
    292             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    293         }, 
    294         tml => "<customtag>this <sticky>& that\n >   the</sticky> other </customtag>", 
     296          . $protectoff . '</p>' 
     297    }, 
     298    { 
     299        exec  => $TML2HTML | $ROUNDTRIP, 
     300        name  => 'StickyInsideUnspecifiedCustomtag', 
     301        setup => sub { 
     302            $extraTML2HTMLOptions{xmltag} = 
     303              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     304        }, 
     305        tml => 
     306"<customtag>this <sticky>& that\n >   the</sticky> other </customtag>", 
    295307        html => '<p>' 
    296308          . $protecton 
    297309          . '&lt;customtag&gt;' 
    298           . $protectoff 
    299           . 'this' 
     310          . $protectoff . 'this' 
    300311          . '<div class="WYSIWYG_STICKY">' 
    301312          . '&amp;&nbsp;that<br />&nbsp;&gt;&nbsp;&nbsp;&nbsp;the' 
    302           . '</div>' 
    303           . 'other' 
     313          . '</div>' . 'other' 
    304314          . $protecton 
    305315          . '&lt;/customtag&gt;' 
    306           . $protectoff 
    307           . '</p>' 
    308     }, 
    309     { 
    310         exec => $ROUNDTRIP, 
    311         name => 'UnspecifiedCustomtagInsideSticky', 
    312         setup => sub { 
    313             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    314         }, 
    315         tml => "<sticky><customtag>this & that\n >   the other </customtag></sticky>" 
    316     }, 
    317     { 
    318         exec => $TML2HTML | $ROUNDTRIP, 
    319         name => 'CustomtagInsideLiteral', 
    320         setup => sub { 
    321             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     316          . $protectoff . '</p>' 
     317    }, 
     318    { 
     319        exec  => $ROUNDTRIP, 
     320        name  => 'UnspecifiedCustomtagInsideSticky', 
     321        setup => sub { 
     322            $extraTML2HTMLOptions{xmltag} = 
     323              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     324        }, 
     325        tml => 
     326          "<sticky><customtag>this & that\n >   the other </customtag></sticky>" 
     327    }, 
     328    { 
     329        exec  => $TML2HTML | $ROUNDTRIP, 
     330        name  => 'CustomtagInsideLiteral', 
     331        setup => sub { 
     332            $extraTML2HTMLOptions{xmltag} = 
     333              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    322334            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 
    323335                sub { 1 } ); 
    324336        }, 
    325         tml => '<literal><customtag>this & that >   the other </customtag></literal>', 
     337        tml => 
     338'<literal><customtag>this & that >   the other </customtag></literal>', 
    326339        html => '<p>' 
    327340          . '<div class="WYSIWYG_LITERAL">' 
    328341          . '<customtag>this & that >   the other </customtag>' 
    329           . '</div>' 
    330           . '</p>' 
    331     }, 
    332     { 
    333         exec => $TML2HTML | $ROUNDTRIP, 
    334         name => 'UnspecifiedCustomtagInsideLiteral', 
    335         setup => sub { 
    336             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    337         }, 
    338         tml => '<literal><customtag>this & that >   the other </customtag></literal>', 
     342          . '</div>' . '</p>' 
     343    }, 
     344    { 
     345        exec  => $TML2HTML | $ROUNDTRIP, 
     346        name  => 'UnspecifiedCustomtagInsideLiteral', 
     347        setup => sub { 
     348            $extraTML2HTMLOptions{xmltag} = 
     349              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     350        }, 
     351        tml => 
     352'<literal><customtag>this & that >   the other </customtag></literal>', 
    339353        html => '<p>' 
    340354          . '<div class="WYSIWYG_LITERAL">' 
    341355          . '<customtag>this & that >   the other </customtag>' 
    342           . '</div>' 
    343           . '</p>' 
    344     }, 
    345     { 
    346         exec => $ROUNDTRIP | $CANNOTWYSIWYG, #SMELL: Fix this case 
    347         name => 'LiteralInsideCustomtag', 
    348         setup => sub { 
    349             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     356          . '</div>' . '</p>' 
     357    }, 
     358    { 
     359        exec  => $ROUNDTRIP | $CANNOTWYSIWYG,    #SMELL: Fix this case 
     360        name  => 'LiteralInsideCustomtag', 
     361        setup => sub { 
     362            $extraTML2HTMLOptions{xmltag} = 
     363              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    350364            Foswiki::Plugins::WysiwygPlugin::addXMLTag( 'customtag', 
    351365                sub { 1 } ); 
    352366        }, 
    353         tml => '<customtag>this <literal>& that > the</literal> other </customtag>', 
     367        tml => 
     368          '<customtag>this <literal>& that > the</literal> other </customtag>', 
    354369        html => '<p>' 
    355370          . '<div class="WYSIWYG_LITERAL">' 
    356371          . '<customtag>this & that > the other </customtag>' 
    357           . '</div>' 
    358           . '</p>' 
    359     }, 
    360     { 
    361         exec => $TML2HTML | $ROUNDTRIP, 
    362         name => 'LiteralInsideUnspecifiedCustomtag', 
    363         setup => sub { 
    364             $extraTML2HTMLOptions{xmltag} = \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
    365         }, 
    366         tml => '<customtag>this <literal>& that > the</literal> other </customtag>', 
     372          . '</div>' . '</p>' 
     373    }, 
     374    { 
     375        exec  => $TML2HTML | $ROUNDTRIP, 
     376        name  => 'LiteralInsideUnspecifiedCustomtag', 
     377        setup => sub { 
     378            $extraTML2HTMLOptions{xmltag} = 
     379              \%Foswiki::Plugins::WysiwygPlugin::xmltag; 
     380        }, 
     381        tml => 
     382          '<customtag>this <literal>& that > the</literal> other </customtag>', 
    367383        html => '<p>' 
    368384          . $protecton 
    369385          . '&lt;customtag&gt;' 
    370           . $protectoff 
    371           . 'this' 
     386          . $protectoff . 'this' 
    372387          . '<div class="WYSIWYG_LITERAL">' 
    373388          . '& that > the' 
    374           . '</div>' 
    375           .'other' 
     389          . '</div>' . 'other' 
    376390          . $protecton 
    377391          . '&lt;/customtag&gt;' 
    378           . $protectoff 
    379           . '</p>' 
    380     }, 
    381     { 
    382         # There will probably always be some markup that WysiwygPlugin cannot convert, 
    383         # but it is not always easy to say what that markup is. 
    384         # This test case checks the protection of unconvertable text 
    385         # by using valid markup and forcing the conversion to fail. 
     392          . $protectoff . '</p>' 
     393    }, 
     394    { 
     395 
     396  # There will probably always be some markup that WysiwygPlugin cannot convert, 
     397  # but it is not always easy to say what that markup is. 
     398  # This test case checks the protection of unconvertable text 
     399  # by using valid markup and forcing the conversion to fail. 
     400        exec  => $TML2HTML | $ROUNDTRIP, 
     401        name  => 'UnconvertableTextIsProtected', 
     402        setup => sub { 
     403 
     404       # Disable "dieOnError" to test the "protect unconvertable text" behaviour 
     405       # which can be exercised via the REST handler 
     406            $extraTML2HTMLOptions{dieOnError} = 0; 
     407 
     408# Override the standard expansion function to hack in an illegal character to force the conversion to fail 
     409            $extraTML2HTMLOptions{expandVarsInURL} = sub { return "\0"; }; 
     410        }, 
     411        tml => '<img src="%PUBURLPATH%">', 
     412        html => 
     413'<div class="WYSIWYG_PROTECTED">&lt;img&nbsp;src="%PUBURLPATH%"&gt;</div>' 
     414    }, 
     415    { 
     416        exec => $HTML2TML | $ROUNDTRIP, 
     417        name => 'TableWithRowSpan_NoTablePlugin', 
     418        setup => 
     419          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     420        html => <<HTML, 
     421<table cellspacing="1" cellpadding="0" border="1"> 
     422<tr><td rowspan="2">A</td><td rowspan="3">B</td><td>X</td></tr> 
     423<tr><td rowspan="2">C</td></tr> 
     424<tr><td>M</td></tr> 
     425</table> 
     426HTML 
     427        tml => <<TML, 
     428<table cellspacing="1" cellpadding="0" border="1"> <tr><td rowspan="2">A</td><td rowspan="3">B</td><td>X</td></tr> <tr><td rowspan="2">C</td></tr> <tr><td>M</td></tr> </table> 
     429TML 
     430    }, 
     431    { 
    386432        exec => $TML2HTML | $ROUNDTRIP, 
    387         name => 'UnconvertableTextIsProtected', 
    388         setup => sub { 
    389             # Disable "dieOnError" to test the "protect unconvertable text" behaviour 
    390             # which can be exercised via the REST handler 
    391             $extraTML2HTMLOptions{dieOnError} = 0; 
    392  
    393             # Override the standard expansion function to hack in an illegal character to force the conversion to fail 
    394             $extraTML2HTMLOptions{expandVarsInURL} = sub { return "\0"; }; 
    395         }, 
    396         tml => '<img src="%PUBURLPATH%">', 
    397         html => '<div class="WYSIWYG_PROTECTED">&lt;img&nbsp;src="%PUBURLPATH%"&gt;</div>' 
     433        name => 'simpleTable_NoTablePlugin', 
     434        setup => 
     435          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     436        html => <<'HERE', 
     437<p> 
     438Before 
     439</p> 
     440<table border="1" cellpadding="0" cellspacing="1"><tr><th>L</th><th>C</th><th>R</th></tr><tr><td> A2</td><td style="text-align: center" class="align-center"> 2</td><td style="text-align: right" class="align-right"> 2</td></tr><tr><td> A3</td><td style="text-align: center" class="align-center"> 3</td><td style="text-align: left" class="align-left"> 3</td></tr><tr><td> A4-6</td><td> four</td><td> four</td></tr><tr><td>^</td><td> five</td><td> five</td></tr></table><p /><table border="1" cellpadding="0" cellspacing="1"><tr><td>^</td><td> six</td><td> six</td></tr></table> 
     441After 
     442HERE 
     443        tml => <<'HERE', 
     444Before 
     445| *L* | *C* | *R* | 
     446| A2 |  2  |  2 | 
     447| A3 |  3  | 3  | 
     448| A4-6 | four | four | 
     449|^| five | five | 
     450 
     451|^| six | six | 
     452After 
     453 
     454HERE 
     455        finaltml => <<'HERE', 
     456Before 
     457| *L* | *C* | *R* | 
     458| A2 |  2  |  2 | 
     459| A3 |  3  | 3  | 
     460| A4-6 | four | four | 
     461| ^ | five | five | 
     462 
     463| ^ | six | six | 
     464After 
     465HERE 
     466    }, 
     467    { 
     468        exec => $HTML2TML, 
     469        name => 'ttClassInTable_NoTablePlugin', 
     470        setup => 
     471          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     472        html => '<table><tr><td class="WYSIWYG_TT">Code</td></tr></table>', 
     473        tml  => '| =Code= |' 
     474    }, 
     475    { 
     476        exec => $TML2HTML | $ROUNDTRIP, 
     477        name => 'tmlInTable_NoTablePlugin', 
     478        setup => 
     479          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     480        html => <<'BLAH', 
     481<table cellspacing="1" cellpadding="0" border="1"> 
     482<tr><td> <span class="WYSIWYG_TT">Code</span> </td></tr> 
     483<tr><td> <span class="WYSIWYG_TT">code</span> at start</td></tr> 
     484<tr><td>ends with <span class="WYSIWYG_TT">code</span> </td></tr> 
     485 
     486<tr><td> <b><span class="WYSIWYG_TT">Code</span></b> </td></tr> 
     487<tr><td> <b><span class="WYSIWYG_TT">code</span></b> at start</td></tr> 
     488<tr><td>ends with <b><span class="WYSIWYG_TT">code</span></b> </td></tr> 
     489 
     490<tr><td> <i>Emphasis</i> </td></tr> 
     491<tr><td> <i>emphasis</i> at start</td></tr> 
     492<tr><td>ends with <i>emphasis</i> </td></tr> 
     493 
     494<tr><td> <b><i>Emphasis</i></b> </td></tr> 
     495<tr><td> <b><i>emphasis</i></b> at start</td></tr> 
     496<tr><td>ends with <b><i>emphasis</i></b> </td></tr> 
     497 
     498<tr><td> <b>bold</b> at start</td></tr> 
     499<tr><td>ends with <b>bold</b> </td></tr> 
     500</table> 
     501BLAH 
     502        tml => <<'BLAH', 
     503| =Code= | 
     504| =code= at start | 
     505| ends with =code= | 
     506| ==Code== | 
     507| ==code== at start | 
     508| ends with ==code== | 
     509| _Emphasis_ | 
     510| _emphasis_ at start | 
     511| ends with _emphasis_ | 
     512| __Emphasis__ | 
     513| __emphasis__ at start | 
     514| ends with __emphasis__ | 
     515| *bold* at start | 
     516| ends with *bold* | 
     517BLAH 
     518    }, 
     519    { 
     520        exec => $HTML2TML, 
     521        name => 'kupuTable_NoTablePlugin', 
     522        setup => 
     523          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     524        html => 
     525'<table cellspacing="0" cellpadding="8" border="1" class="plain" _moz_resizing="true"> 
     526<tbody> 
     527<tr>a0<td>a1</td><td>a2</td><td>a3</td></tr> 
     528<tr>b0<td colspan="2">b1</td><td>b3</td></tr> 
     529<tr>c0<td>c1</td><td>c2</td><td>c3</td></tr> 
     530</tbody> 
     531</table>', 
     532        tml => '| a1 | a2 | a3 | 
     533| b1 || b3 | 
     534| c1 | c2 | c3 | 
     535', 
     536    }, 
     537    { 
     538        exec => $TML2HTML | $ROUNDTRIP, 
     539        name => 'tableWithColSpans_NoTablePlugin', 
     540        setup => 
     541          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     542        html => '<p>abcd 
     543</p> 
     544<table cellspacing="1" cellpadding="0" border="1"> 
     545<tr><td colspan="2">efg</td><td>&nbsp;</td></tr> 
     546<tr><td colspan="3"></td></tr></table> 
     547hijk', 
     548        tml => 'abcd 
     549| efg || | 
     550|||| 
     551hijk', 
     552        finaltml => 'abcd 
     553| efg || | 
     554| ||| 
     555hijk', 
     556    }, 
     557    { 
     558        exec => $ROUNDTRIP, 
     559        name => 'Item4410_NoTablePlugin', 
     560        setup => 
     561          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     562        tml => <<'HERE', 
     563   * x 
     564| Y | 
     565HERE 
     566        html => 
     567'<ul><li>x</li></ul><table cellspacing="1" cellpadding="0" border="1"><tr><td>Y</td></tr></table>', 
     568    }, 
     569    { 
     570        exec => $HTML2TML, 
     571        name => 'tableInnaBun_NoTablePlugin', 
     572        setup => 
     573          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     574        html => <<'JUNK', 
     575<ul> 
     576<li> List item</li><li><table><tbody><tr><td>&nbsp;11</td><td>&nbsp;21</td></tr><tr><td>12&nbsp;</td><td>&nbsp;22</td></tr></tbody></table></li><li>crap</li> 
     577</ul> 
     578JUNK 
     579        tml => <<JUNX, 
     580   * List item 
     581   * <table><tbody><tr><td> 11</td><td> 21</td></tr><tr><td>12 </td><td> 22</td></tr></tbody></table> 
     582   * crap 
     583JUNX 
     584    }, 
     585    { 
     586        exec => $TML2HTML | $HTML2TML, 
     587        name => 'Item4700_NoTablePlugin', 
     588        setup => 
     589          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     590        tml => <<EXPT, 
     591| ex | per | iment | 
     592| exper | iment || 
     593| expe || riment | 
     594|| exper | iment | 
     595EXPT 
     596        finaltml => <<EXPT, 
     597| ex | per | iment | 
     598| exper | iment || 
     599| expe || riment | 
     600| | exper | iment | 
     601EXPT 
     602        html => <<HEXPT, 
     603<table cellspacing="1" cellpadding="0" border="1"> 
     604<tr><td>ex</td><td>per</td><td>iment</td></tr> 
     605<tr><td>exper</td><td colspan="2">iment</td></tr> 
     606<tr><td colspan="2">expe</td><td>riment</td></tr> 
     607<tr><td></td><td>exper</td><td>iment</td></tr> 
     608</table> 
     609HEXPT 
     610    }, 
     611    { 
     612        exec => $ROUNDTRIP, 
     613        name => 'Item4700_2_NoTablePlugin', 
     614        setup => 
     615          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     616        tml => <<EXPT, 
     617| ex | per | iment | 
     618| exper | iment || 
     619| expe || riment | 
     620| | exper | iment | 
     621EXPT 
     622        html => <<HEXPT, 
     623<table cellspacing="1" cellpadding="0" border="1"> 
     624<tr><td>ex</td><td>per</td><td>iment</td></tr> 
     625<tr><td>exper</td><td colspan="2">iment</td></tr> 
     626<tr><td colspan="2">expe</td><td>riment</td></tr> 
     627<tr><td></td><td>exper</td><td>iment</td></tr> 
     628</table> 
     629HEXPT 
     630    }, 
     631    { 
     632        name => 'Item4855_NoTablePlugin', 
     633        setup => 
     634          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     635        exec => $TML2HTML, 
     636        tml  => <<HERE, 
     637| [[LegacyTopic1]] | Main.SomeGuy | 
     638%TABLESEP% 
     639%SEARCH{"legacy" nonoise="on" format="| [[\$topic]] | [[\$wikiname]] |"}% 
     640HERE 
     641        html => <<THERE, 
     642<table cellspacing="1" cellpadding="0" border="1"> 
     643<tr><td><span class="WYSIWYG_LINK">[[LegacyTopic1]]</span></td><td><span class="WYSIWYG_LINK">Main.SomeGuy</span></td></tr> 
     644</table> 
     645<span class="WYSIWYG_PROTECTED"><br />%TABLESEP%</span> 
     646<span class="WYSIWYG_PROTECTED"><br />%SEARCH{"legacy" nonoise="on" format="| [[\$topic]] | [[\$wikiname]] |"}%</span> 
     647THERE 
     648    }, 
     649    { 
     650        name => 'Item1798_NoTablePlugin', 
     651        setup => 
     652          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     653        exec => $ROUNDTRIP | $TML2HTML, 
     654        tml  => <<HERE, 
     655| [[LegacyTopic1]] | Main.SomeGuy | 
     656%SEARCH{"legacy" nonoise="on" format="| [[\$topic]] | [[\$wikiname]] |"}% 
     657HERE 
     658        html => <<THERE, 
     659<table cellspacing="1" cellpadding="0" border="1"> 
     660<tr><td><span class="WYSIWYG_LINK">[[LegacyTopic1]]</span></td><td><span class="WYSIWYG_LINK">Main.SomeGuy</span></td></tr> 
     661</table> 
     662<span class="WYSIWYG_PROTECTED"><br />%SEARCH{"legacy" nonoise="on" format="| [[\$topic]] | [[\$wikiname]] |"}%</span> 
     663THERE 
     664    }, 
     665    { 
     666        exec => $HTML2TML | $ROUNDTRIP, 
     667        name => 'colorClassInTable_NoTablePlugin', 
     668        setup => 
     669          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     670        html => <<'BLAH', 
     671<table> 
     672<tr><th class="WYSIWYG_COLOR" style="color:#FF0000;">Red Heading</th></tr> 
     673<tr><td class="WYSIWYG_COLOR" style="color:#FF0000;">Red herring</td></tr> 
     674</table> 
     675BLAH 
     676        tml => <<'BLAH', 
     677| *%RED%Red Heading%ENDCOLOR%* | 
     678| %RED%Red herring%ENDCOLOR% | 
     679BLAH 
     680    }, 
     681    { 
     682        exec => $HTML2TML | $ROUNDTRIP, 
     683        name => 'colorAndTtClassInTable_NoTablePlugin', 
     684        setup => 
     685          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     686        html => <<'BLAH', 
     687<table> 
     688<tr><th class="WYSIWYG_COLOR WYSIWYG_TT" style="color:#FF0000;">Redder code</th></tr> 
     689<tr><td class="WYSIWYG_COLOR WYSIWYG_TT" style="color:#FF0000;">Red code</td></tr> 
     690</table> 
     691BLAH 
     692        tml => <<'BLAH', 
     693| *%RED% =Redder code= %ENDCOLOR%* | 
     694| %RED% =Red code= %ENDCOLOR% | 
     695BLAH 
     696    }, 
     697    { 
     698        name => 'Item4969_NoTablePlugin', 
     699        setup => 
     700          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     701        exec => $HTML2TML, 
     702        html => <<HERE, 
     703<table cellspacing="1" cellpadding="0" border="1"> 
     704<tr><td>table element with a <hr /> horizontal rule</td></tr> 
     705</table> 
     706Mad Fish 
     707HERE 
     708        tml => '| table element with a <hr /> horizontal rule | 
     709Mad Fish', 
     710    }, 
     711    { 
     712        name => 'Item5076_NoTablePlugin', 
     713        setup => 
     714          sub { Foswiki::Func::getContext()->{'TablePluginEnabled'} = 0; }, 
     715        exec => $HTML2TML, 
     716        html => <<HERE, 
     717<table border="0"><tbody><tr><td><h2>Argh</h2><ul><li>Ergh&nbsp;</li></ul></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td></tr></tbody></table> 
     718HERE 
     719        tml => '<table border="0"><tbody><tr><td> 
     720---++ Argh 
     721   * Ergh  
     722</td><td> </td></tr><tr><td> </td><td> </td></tr></tbody></table>', 
    398723    }, 
    399724]; 
     
    409734            my $fn = 'ExtendedTranslatorTests::testTML2HTML_' . $datum->{name}; 
    410735            no strict 'refs'; 
    411             *$fn = sub {  
    412                 my $this = shift;  
    413                 $this->testSpecificSetup($datum);  
    414                 $this->compareTML_HTML($datum);  
     736            *$fn = sub { 
     737                my $this = shift; 
     738                $this->testSpecificSetup($datum); 
     739                $this->compareTML_HTML($datum); 
    415740                $this->testSpecificCleanup($datum); 
    416741            }; 
     
    420745            my $fn = 'ExtendedTranslatorTests::testHTML2TML_' . $datum->{name}; 
    421746            no strict 'refs'; 
    422             *$fn = sub {  
     747            *$fn = sub { 
    423748                my $this = shift; 
    424                 $this->testSpecificSetup($datum);  
     749                $this->testSpecificSetup($datum); 
    425750                $this->compareHTML_TML($datum); 
    426751                $this->testSpecificCleanup($datum); 
     
    433758            *$fn = sub { 
    434759                my $this = shift; 
    435                 $this->testSpecificSetup($datum);  
     760                $this->testSpecificSetup($datum); 
    436761                $this->compareRoundTrip($datum); 
    437762                $this->testSpecificCleanup($datum); 
     
    442767            my $fn = 'TranslatorTests::testCANNOTWYSIWYG_' . $datum->{name}; 
    443768            no strict 'refs'; 
    444             *$fn = sub {  
     769            *$fn = sub { 
    445770                my $this = shift; 
    446                 $this->testSpecificSetup($datum);  
     771                $this->testSpecificSetup($datum); 
    447772                $this->compareNotWysiwygEditable($datum); 
    448773                $this->testSpecificCleanup($datum); 
     
    455780sub testSpecificSetup { 
    456781    my ( $this, $args ) = @_; 
     782 
    457783    # Reset the extendable parts of WysiwygPlugin 
    458784    %Foswiki::Plugins::WysiwygPlugin::xmltag       = (); 
     
    474800} 
    475801 
    476 sub TML_HTMLconverterOptions 
    477 { 
    478     my $this = shift; 
     802sub TML_HTMLconverterOptions { 
     803    my $this    = shift; 
    479804    my $options = $this->SUPER::TML_HTMLconverterOptions(@_); 
    480     for my $extraOptionName (keys %extraTML2HTMLOptions) { 
     805    for my $extraOptionName ( keys %extraTML2HTMLOptions ) { 
    481806        $options->{$extraOptionName} = $extraTML2HTMLOptions{$extraOptionName}; 
    482807    } 
Note: See TracChangeset for help on using the changeset viewer.