Changeset 8123


Ignore:
Timestamp:
07/11/10 16:47:51 (23 months ago)
Author:
MichaelTempest
Message:

Item2074: Changed the removal code in TML2HTMLto use a single mechanism for removing all chunks of TML. This eliminates stray $TT0 in the HTML after conversion, which were always associated with topic corruption, without completely disabling WYSIWYG editing.

Expanded the tests covering one form of markup inside another, and consolidated tests when there was duplication

Location:
trunk/WysiwygPlugin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin.pm

    r8111 r8123  
    169169    # Look for combinations of sticky and other markup that cause 
    170170    # problems together 
    171     for my $tag ( 'literal', keys %xmltag ) { 
     171    for my $tag ( 'literal' ) { 
    172172        while ( $text =~ /<$tag\b[^>]*>(.*?)<\/$tag>/gsi ) { 
    173173            my $inner = $1; 
     
    190190    # Look for combinations of verbatim and other markup that cause 
    191191    # problems together 
    192     for my $tag ( 'literal', keys %xmltag ) { 
     192    for my $tag ( 'literal') { 
    193193        while ( $text =~ /<$tag\b[^>]*>(.*?)<\/$tag>/gsi ) { 
    194194            my $inner = $1; 
  • trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm

    r8111 r8123  
    129129        $content = $this->_getRenderedVersion($content); 
    130130 
    131         # Substitute back in protected elements 
    132         $content = $this->_dropBack($content); 
    133  
    134         if ( $content =~ /[$TT0$TT1$TT2]/o ) { 
     131        my $fail = ''; 
     132        $fail .= "TT0:[$1|TT0|$2]" if $content =~ /(.{0,10})[$TT0](.{0,10})/o; 
     133        $fail .= "TT1:[$1|TT1|$2]" if $content =~ /(.{0,10})[$TT1](.{0,10})/o; 
     134        $fail .= "TT2:[$1|TT2|$2]" if $content =~ /(.{0,10})[$TT2](.{0,10})/o; 
     135        if ($fail) { 
    135136 
    136137            # There should never be any of these in the text at this point. 
    137138            # If there are, then the conversion failed. 
    138             die("Invalid characters in HTML after conversion") 
     139            die("Invalid characters in HTML after conversion: $fail") 
    139140              if $options->{dieOnError}; 
    140141 
     
    157158 
    158159sub _liftOut { 
    159     my ( $this, $text, $type, $encoding ) = @_; 
    160     $text = $this->_unLift($text); 
     160    my ( $this, $text, $type ) = @_; 
     161    my %options; 
     162    if ( $type and $type =~ /^(?:PROTECTED|STICKY|VERBATIM)$/ ) { 
     163        $options{protect} = 1; 
     164    } 
     165    $options{class} = 'WYSIWYG_' . $type; 
     166    return $this->_liftOutGeneral( $text, \%options ); 
     167} 
     168 
     169sub _liftOutGeneral { 
     170    my ( $this, $text, $options ) = @_; 
     171 
     172    #$text = $this->_unLift($text); 
     173 
     174    $options = {} unless ref($options); 
     175 
    161176    my $n = scalar( @{ $this->{refs} } ); 
    162177    push( 
    163178        @{ $this->{refs} }, 
    164179        { 
    165             type     => $type, 
    166             encoding => $encoding || 'span', 
    167             text     => $text 
     180            tag => $options->{tag} || 'span', 
     181            text    => $text, 
     182            tmltag  => $options->{tmltag}, 
     183            params  => $options->{params}, 
     184            class   => $options->{class}, 
     185            protect => $options->{protect}, 
    168186        } 
    169187    ); 
     188 
    170189    return $TT1 . $n . $TT2; 
    171190} 
     
    181200 
    182201sub _dropBack { 
    183     my ( $this, $text ) = @_; 
     202    my ( $this, $text, $protecting ) = @_; 
    184203 
    185204    # Restore everything that was lifted out 
    186     while ( $text =~ s#$TT1([0-9]+)$TT2#$this->_dropIn($1)#ge ) { 
     205    while ( $text =~ s#$TT1([0-9]+)$TT2#$this->_dropIn($1, $protecting)#ge ) { 
    187206    } 
    188207    return $text; 
     
    190209 
    191210sub _dropIn { 
    192     my ( $this, $n ) = @_; 
     211    my ( $this, $n, $protecting ) = @_; 
    193212    my $thing = $this->{refs}->[$n]; 
    194     return $thing->{text} if $thing->{encoding} eq 'NONE'; 
    195     my $method = 'CGI::' . $thing->{encoding}; 
    196     my $text   = $thing->{text}; 
     213 
     214    my $text = $thing->{text}; 
     215 
     216    # Drop back recursively 
     217    $text = $this->_dropBack( $text, $protecting || $thing->{protect} ); 
     218 
     219    # Only protect at the outer-most level applicable 
    197220    $text = _protectVerbatimChars($text) 
    198       if $thing->{type} =~ /^(PROTECTED|STICKY|VERBATIM)$/; 
     221      if $thing->{protect} and not $protecting; 
     222 
     223    if ($protecting) { 
     224        if ( $thing->{tmltag} ) { 
     225            return 
     226"<$thing->{tmltag}$thing->{params}>$thing->{text}</$thing->{tmltag}>"; 
     227        } 
     228        else { 
     229            return $thing->{text}; 
     230        } 
     231    } 
     232    return $thing->{text} if $thing->{tag} eq 'NONE'; 
     233 
     234    my $method = 'CGI::' . $thing->{tag}; 
     235 
     236    $thing->{params} ||= {}; 
     237    $thing->{params} = _parseParams( $thing->{params} ) 
     238      if not ref $thing->{params}; 
     239    _addClass( $thing->{params}->{class}, $thing->{class} ) if $thing->{class}; 
     240 
    199241    no strict 'refs'; 
    200     return &$method( { class => 'WYSIWYG_' . $thing->{type} }, $text ); 
     242    return &$method( $thing->{params}, $text ); 
    201243    use strict 'refs'; 
    202244} 
     
    299341 
    300342    # Do sticky first; it can't be ignored 
    301     $text = $this->_takeOutBlocks( $text, 'sticky' ); 
    302  
    303     $text = $this->_takeOutBlocks( $text, 'verbatim' ); 
    304  
    305     $text = $this->_takeOutBlocks( $text, 'literal' ); 
     343    $text = $this->_liftOutBlocks( 
     344        $text, 'sticky', 
     345        { 
     346            tag     => 'div', 
     347            protect => 1, 
     348            class   => 'WYSIWYG_STICKY' 
     349        } 
     350    ); 
     351 
     352    $text = $this->_liftOutBlocks( 
     353        $text, 
     354        'verbatim', 
     355        { 
     356            tag     => 'pre', 
     357            protect => 1, 
     358            class   => 'TMLverbatim' 
     359        } 
     360    ); 
     361 
     362    $text = $this->_liftOutBlocks( 
     363        $text, 
     364        'literal', 
     365        { 
     366            tag   => 'div', 
     367            class => 'WYSIWYG_LITERAL' 
     368        } 
     369    ); 
    306370 
    307371    $text = $this->_takeOutSets($text); 
     
    313377 
    314378    # Remove PRE to prevent TML interpretation of text inside it 
    315     $text = $this->_takeOutBlocks( $text, 'pre' ); 
     379    $text = $this->_liftOutBlocks( $text, 'pre', {} ); 
    316380 
    317381    # Protect comments 
     
    367431 
    368432    # other entities 
     433    # SMELL - international characters are not allowed in entity names 
    369434    $text =~ s/&([$Foswiki::regex{mixedAlphaNum}]+;)/$TT0$1/g;    # "&abc;" 
    370435    $text =~ s/&(#[0-9]+;)/$TT0$1/g;                              # "&#123;" 
     
    632697s/$WC::STARTWW(($Foswiki::regex{webNameRegex}\.)?$Foswiki::regex{wikiWordRegex}($Foswiki::regex{anchorRegex})?)/$this->_liftOut($1, 'LINK')/geom; 
    633698 
    634     while ( my ( $placeholder, $val ) = each %{ $this->{removed} } ) { 
    635         if ( $placeholder =~ /^verbatim/i ) { 
    636             _addClass( $val->{params}->{class}, 'TMLverbatim' ); 
    637         } 
    638         elsif ( $placeholder =~ /^literal/i ) { 
    639             _addClass( $val->{params}->{class}, 'WYSIWYG_LITERAL' ); 
    640         } 
    641         elsif ( $placeholder =~ /^sticky/i ) { 
    642             _addClass( $val->{params}->{class}, 'WYSIWYG_STICKY' ); 
    643         } 
    644     } 
    645  
    646     $this->_putBackBlocks( $text, 'pre' ); 
    647  
    648     $this->_putBackBlocks( $text, 'literal', 'div' ); 
    649  
    650     # replace verbatim with pre in the final output, with encoded entities 
    651     $this->_putBackBlocks( $text, 'verbatim', 'pre', \&_protectVerbatimChars ); 
    652  
    653     $this->_putBackBlocks( $text, 'sticky', 'div', \&_protectVerbatimChars ); 
    654  
    655699    $text =~ s/(<nop>)/$this->_liftOut($1, 'PROTECTED')/ge; 
     700 
     701    # Substitute back in protected elements 
     702    $text = $this->_dropBack($text); 
    656703 
    657704    # Item1417: Insert a paragraph at the start of the document if the first tag 
     
    920967    $text =~ s:([^/])>$:$1 />:;    # close the tag XHTML style 
    921968 
    922     return $this->_liftOut( $text, '', 'NONE' ); 
     969    return $this->_liftOutGeneral( $text, { tag => 'NONE' } ); 
    923970} 
    924971 
     
    9891036} 
    9901037 
    991 sub _takeOutBlocks { 
    992  
    993     # my ( $this, $intext, $tag ) = @_; 
    994  
    995     sub _takeOutBlocksProcess { 
     1038sub _liftOutBlocks { 
     1039 
     1040    my ( $this, $intext, $tag, $commonOptions ) = @_; 
     1041 
     1042    $commonOptions = {} unless ref($commonOptions); 
     1043    $commonOptions->{tag} ||= $tag; 
     1044 
     1045    my %allBlocksOptions = ( tmltag => $tag ); 
     1046    for my $option (qw/ tag class protect /) { 
     1047        $allBlocksOptions{$option} = $commonOptions->{$option} 
     1048          if $commonOptions->{$option}; 
     1049    } 
     1050 
     1051    my $liftOutBlocksProcess = sub { 
    9961052        my ( $this, $state, $scoop ) = @_; 
    997         my $placeholder = $state->{tag} . $state->{n}; 
    998         $this->{removed}->{$placeholder} = { 
    999             params => _parseParams( $state->{tagParams} ), 
    1000             text   => $scoop, 
    1001         }; 
    1002         return $TT0 . $placeholder . $TT0; 
    1003     } 
    1004  
    1005     return _takeOutXml( @_, \&_takeOutBlocksProcess ); 
     1053 
     1054        my %oneBlockOptions = %allBlocksOptions; 
     1055        $oneBlockOptions{params} = $state->{tagParams}; 
     1056 
     1057        my $params = $state->{tagParams}; 
     1058        return $this->_liftOutGeneral( $scoop, \%oneBlockOptions ); 
     1059    }; 
     1060 
     1061    return _takeOutXml( $this, $intext, $tag, $liftOutBlocksProcess ); 
    10061062} 
    10071063 
     
    10621118 
    10631119    return $out; 
    1064 } 
    1065  
    1066 sub _putBackBlocks { 
    1067     my ( $this, $text, $tag, $newtag, $callback ) = @_; 
    1068     $newtag ||= $tag; 
    1069     my $fn; 
    1070     while ( my ( $placeholder, $val ) = each %{ $this->{removed} } ) { 
    1071         if ( $placeholder =~ /^$tag\d+$/ ) { 
    1072             my $params = $val->{params}; 
    1073             my $val    = $val->{text}; 
    1074             $val = &$callback($val) if ( defined($callback) ); 
    1075  
    1076             # Use div instead of span if the block contains block HTML 
    1077             if ( $newtag eq 'span' && $val =~ m#</?($WC::ALWAYS_BLOCK_S)\b#io ) 
    1078             { 
    1079                 $fn = 'CGI::div'; 
    1080             } 
    1081             else { 
    1082                 $fn = 'CGI::' . $newtag; 
    1083             } 
    1084             no strict 'refs'; 
    1085             $_[1] =~ s/$TT0$placeholder$TT0/&$fn($params, $val)/e; 
    1086             use strict 'refs'; 
    1087             delete( $this->{removed}->{$placeholder} ); 
    1088         } 
    1089     } 
    10901120} 
    10911121 
  • trunk/WysiwygPlugin/test/unit/WysiwygPlugin/ExtendedTranslatorTests.pm

    r8114 r8123  
    221221    }, 
    222222    { 
    223         exec => $CANNOTWYSIWYG, 
    224  
    225         # Do not perform ROUNDTRIP on this TML, because ROUNDTRIP passes. 
    226         # The problem with this TML is that the special handling of 
    227         # <verbatim> in the conversion to HTML messes up the contents 
    228         # of this custom XML  tag, so that the HTML is not representative 
    229         # of the TML in terms of intellectual content. 
     223        exec => $TML2HTML | $ROUNDTRIP, 
    230224        name  => 'VerbatimInsideDot', 
    231225        setup => sub { 
     
    245239</dot> 
    246240DOT 
     241        html => '<p>' 
     242            . $protecton 
     243            . '&lt;dot&gt;<br />' 
     244            . 'digraph&nbsp;G&nbsp{<br />' 
     245            . '&nbsp;&nbsp;&nbsp;&nbsp;open&nbsp;[label="&lt;verbatim&gt;"];<br />' 
     246            . '&nbsp;&nbsp;&nbsp;&nbsp;content&nbsp;[label="Put&nbsp;arbitrary&nbsp;content&nbsp;here"];<br />' 
     247            . '&nbsp;&nbsp;&nbsp;&nbsp;close&nbsp;[label="&lt;/verbatim&gt;"];<br />' 
     248            . '&nbsp;&nbsp;&nbsp;&nbsp;open&nbsp;-&gt;&nbsp;content&nbsp-&gt;&nbsp;close;<br />' 
     249            . '}<br />' 
     250            . '&lt;/dot&gt;' 
     251            . $protectoff . '</p>', 
    247252    }, 
    248253    { 
     
    265270    }, 
    266271    { 
    267         exec  => $ROUNDTRIP | $CANNOTWYSIWYG,    #SMELL: fix this case 
     272        exec  =>  $TML2HTML | $ROUNDTRIP, 
    268273        name  => 'StickyInsideCustomtag', 
    269274        setup => sub { 
     
    279284          . '&lt;customtag&gt;' 
    280285          . 'this&nbsp;' 
    281           . '<div class="WYSIWYG_STICKY">' 
     286          . '&lt;sticky&gt;' 
    282287          . '&amp;&nbsp;that<br />&nbsp;&gt;&nbsp;&nbsp;&nbsp;the' 
    283           . '</div>' 
     288          . '&lt;/sticky&gt;' 
    284289          . '&nbsp;other&nbsp;' 
    285290          . '&lt;/customtag&gt;' 
     
    347352    }, 
    348353    { 
    349         exec  => $ROUNDTRIP | $CANNOTWYSIWYG,    #SMELL: Fix this case 
    350         name  => 'LiteralInsideCustomtag', 
     354        exec  => $TML2HTML | $ROUNDTRIP, 
     355        name  => 'insideCustomtag', 
    351356        setup => sub { 
    352357            $extraTML2HTMLOptions{xmltag} = 
     
    355360                sub { 1 } ); 
    356361        }, 
    357         tml => 
    358           '<customtag>this <literal>& that > the</literal> other </customtag>', 
    359         html => '<p>' 
    360           . '<div class="WYSIWYG_LITERAL">' 
    361           . '<customtag>this & that > the other </customtag>' 
    362           . '</div>' . '</p>' 
     362        tml => <<'HERE', 
     363<customtag> 
     364%MACRO{"<b>X</b>"}% 
     365this <literal>& that > the</literal> other 
     366<verbatim>V</verbatim> 
     367<sticky>S</sticky> 
     368<pre>P</pre> 
     369<!--C--> 
     370   * Set foo=bar 
     371http://google.com/#q=foswiki 
     372WikiWord [[some link]] 
     373<mytag attr="value">my content</mytag> 
     374<img src="http://mysite.org/logo.png" alt="Alternate text" /> 
     375</customtag> 
     376HERE 
     377        html => '<p>' 
     378          . $protecton 
     379          . '&lt;customtag&gt;<br />' 
     380          . '%MACRO{"&lt;b&gt;X&lt;/b&gt;"}%<br />' 
     381          . 'this&nbsp;&lt;literal&gt;&amp;&nbsp;that&nbsp;&gt;&nbsp;the&lt;/literal&gt;&nbsp;other<br />' 
     382          . '&lt;verbatim&gt;V&lt;/verbatim&gt;<br />' 
     383          . '&lt;sticky&gt;S&lt;/sticky&gt;<br />' 
     384          . '&lt;pre&gt;P&lt;/pre&gt;<br />' 
     385          . '&lt;!--C--&gt;<br />' 
     386          . '&nbsp;&nbsp;&nbsp;*&nbsp;Set&nbsp;foo=bar<br />' 
     387          . 'http://google.com/#q=foswiki<br />' 
     388          . 'WikiWord&nbsp;[[some&nbsp;link]]<br />' 
     389          . '&lt;mytag&nbsp;attr="value"&gt;my&nbsp;content&lt;/mytag&gt;<br />' 
     390          . '&lt;img&nbsp;src=&quot;http://mysite.org/logo.png&quot;&nbsp;alt=&quot;Alternate&nbsp;text&quot;&nbsp;/&gt;<br />' 
     391          . '&lt;/customtag&gt;' 
     392          . $protectoff 
     393          . '</p>' 
    363394    }, 
    364395    { 
  • trunk/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm

    r8113 r8123  
    13031303     </break> 
    13041304   * %FLIBBLE% 
     1305   * Set Other=stuff 
     1306   <sticky><font color="blue"> *|B|* </font></sticky> 
     1307   <!-- hidden --> 
     1308   http://google.com/#q=foswiki 
     1309   %FOO% WikiWord [[some link]] 
     1310   <img src="http://mysite.org/logo.png" alt="Alternate text" /> 
     1311   <verbatim class="tml">%H%<!--?--></verbatim> 
     1312   <literal><font color="blue"> *|B|* </font></literal> 
     1313   <mytag attr="value">my content</mytag> 
     1314   <sticky> block </sticky> 
     1315   <pre> 
     1316     123 
     1317    456 
     1318   </pre> 
    13051319      * Set FLEEGLE = easy gum 
    13061320HERE 
    1307         html => '<ul> 
    1308 <li> Set FLIBBLE =<span class="WYSIWYG_PROTECTED">&nbsp;&#60;break&#62;&nbsp;&#60;cake/&#62;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#60;/break&#62;</span></li><li><span class="WYSIWYG_PROTECTED">%FLIBBLE%</span><ul><li>Set FLEEGLE =<span class="WYSIWYG_PROTECTED">&nbsp;easy&nbsp;gum</span></li></ul></li></ul>', 
     1321        html => '<ul>'. 
     1322                '<li> Set FLIBBLE =<span class="WYSIWYG_PROTECTED">&nbsp;&#60;break&#62;&nbsp;&#60;cake/&#62;<br />'. 
     1323                '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#60;/break&#62;</span></li>'. 
     1324                '<li><span class="WYSIWYG_PROTECTED">%FLIBBLE%</span></li>'. 
     1325                '<li> Set Other=<span class="WYSIWYG_PROTECTED">stuff<br />'. 
     1326                '&nbsp;&nbsp;&nbsp;&lt;sticky&gt;&#60;font&nbsp;color="blue"&#62;&nbsp;*|B|*&nbsp;&#60;/font&#62;&lt;/sticky&gt;<br />'. 
     1327                '&nbsp;&nbsp;&nbsp;&lt;!--&nbsp;hidden&nbsp;--&gt;<br />'. 
     1328                '&nbsp;&nbsp;&nbsp;http://google.com/#q=foswiki<br />'. 
     1329                '&nbsp;&nbsp;&nbsp;%FOO%&nbsp;WikiWord&nbsp;[[some&nbsp;link]]<br />'. 
     1330                '&nbsp;&nbsp;&nbsp;&lt;img&nbsp;src=&quot;http://mysite.org/logo.png&quot;&nbsp;alt=&quot;Alternate&nbsp;text&quot;&nbsp;/&gt;<br />'. 
     1331                '&nbsp;&nbsp;&nbsp;&lt;verbatim&nbsp;class=&quot;tml&quot;&gt;%H%&lt;!--?--&gt;&lt;/verbatim&gt;<br />'. 
     1332                '&nbsp;&nbsp;&nbsp;&lt;literal&gt;&lt;font&nbsp;color="blue"&gt;&nbsp;*|B|*&nbsp;&lt;/font&gt;&lt;/literal&gt;<br />'. 
     1333                '&nbsp;&nbsp;&nbsp;&lt;mytag&nbsp;attr="value"&gt;my&nbsp;content&lt;/mytag&gt;<br />'. 
     1334                '&nbsp;&nbsp;&nbsp;&lt;sticky&gt;&nbsp;block&nbsp;&lt;/sticky&gt;<br />'. 
     1335                '&nbsp;&nbsp;&nbsp;&lt;pre&gt;<br />'. 
     1336                '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;123<br />'. 
     1337                '&nbsp;&nbsp;&nbsp;&nbsp;456<br />'. 
     1338                '&nbsp;&nbsp;&nbsp;&lt;/pre&gt;'. 
     1339                '</span>'. 
     1340                '<ul><li>Set FLEEGLE =<span class="WYSIWYG_PROTECTED">&nbsp;easy&nbsp;gum</span></li></ul></li></ul>', 
    13091341    }, 
    13101342    { 
     
    19712003        name => 'sticky', 
    19722004        tml  => <<GLUED, 
    1973 <sticky><font color="blue"> *|B|* </font></sticky> 
     2005<sticky><font color="blue"> *|B|* </font> 
     2006 
     2007<!-- hidden --> 
     2008http://google.com/#q=foswiki 
     2009%FOO% WikiWord [[some link]] 
     2010   * Set bar=baz 
     2011<img src="%!page!%/logo.png" alt="Alternate text" /> 
     2012 
     2013<verbatim class="tml">%H%<!--?--></verbatim> 
     2014<literal><font color="blue"> *|B|* </font></literal> 
     2015<mytag attr="value">my content</mytag> 
     2016 
     2017nested <sticky> block </sticky> 
     2018 
     2019<pre> 
     2020  123 
     2021 456 
     2022</pre></sticky> 
    19742023GLUED 
    1975         html => '<p> 
    1976 <div class="WYSIWYG_STICKY">&#60;font&nbsp;color="blue"&#62;&nbsp;*|B|*&nbsp;&#60;/font&#62;</div> 
    1977 </p> 
    1978 ' 
     2024        html => '<p>'. 
     2025                '<div class="WYSIWYG_STICKY">&#60;font&nbsp;color="blue"&#62;&nbsp;*|B|*&nbsp;&#60;/font&#62;<br />'. 
     2026                '<br />'. 
     2027                '&lt;!--&nbsp;hidden&nbsp;--&gt;<br />'. 
     2028                'http://google.com/#q=foswiki<br />'. 
     2029                '%FOO%&nbsp;WikiWord&nbsp;[[some&nbsp;link]]<br />'. 
     2030                '&nbsp;&nbsp;&nbsp;*&nbsp;Set&nbsp;bar=baz<br />'. 
     2031                '&lt;img&nbsp;src=&quot;%!page!%/logo.png&quot;&nbsp;alt=&quot;Alternate&nbsp;text&quot;&nbsp;/&gt;<br />'. 
     2032                '<br />'. 
     2033                '&lt;verbatim&nbsp;class=&quot;tml&quot;&gt;%H%&lt;!--?--&gt;&lt;/verbatim&gt;<br />'. 
     2034                '&lt;literal&gt;&lt;font&nbsp;color="blue"&gt;&nbsp;*|B|*&nbsp;&lt;/font&gt;&lt;/literal&gt;<br />'. 
     2035                '&lt;mytag&nbsp;attr="value"&gt;my&nbsp;content&lt;/mytag&gt;<br />'. 
     2036                '<br />'. 
     2037                'nested&nbsp;&lt;sticky&gt;&nbsp;block&nbsp;&lt;/sticky&gt;<br />'. 
     2038                '<br />'. 
     2039                '&lt;pre&gt;<br />'. 
     2040                '&nbsp;&nbsp;123<br />'. 
     2041                '&nbsp;456<br />'. 
     2042                '&lt;/pre&gt;</div>'. 
     2043                '</p>' 
     2044    }, 
     2045    { 
     2046        exec => $TML2HTML | $ROUNDTRIP | $HTML2TML, 
     2047        name => 'verbatim', 
     2048        tml  => <<GLUED, 
     2049<verbatim><font color="blue"> *|B|* </font> 
     2050 
     2051<!-- hidden --> 
     2052http://google.com/#q=foswiki 
     2053%FOO% WikiWord [[some link]] 
     2054   * Set bar=baz 
     2055<img src="http://mysite.org/logo.png" alt="Alternate text" /> 
     2056 
     2057nested <verbatim class="tml">%H%<!--?--></verbatim> 
     2058<literal><font color="blue"> *|B|* </font></literal> 
     2059<mytag attr="value">my content</mytag> 
     2060 
     2061<sticky> block </sticky> 
     2062 
     2063<pre> 
     2064  123 
     2065 456 
     2066</pre></verbatim> 
     2067GLUED 
     2068        html => '<p>'. 
     2069                '<pre class="TMLverbatim">&#60;font&nbsp;color="blue"&#62;&nbsp;*|B|*&nbsp;&#60;/font&#62;<br />'. 
     2070                '<br />'. 
     2071                '&lt;!--&nbsp;hidden&nbsp;--&gt;<br />'. 
     2072                'http://google.com/#q=foswiki<br />'. 
     2073                '%FOO%&nbsp;WikiWord&nbsp;[[some&nbsp;link]]<br />'. 
     2074                '&nbsp;&nbsp;&nbsp;*&nbsp;Set&nbsp;bar=baz<br />'. 
     2075                '&lt;img&nbsp;src=&quot;http://mysite.org/logo.png&quot;&nbsp;alt=&quot;Alternate&nbsp;text&quot;&nbsp;/&gt;<br />'. 
     2076                '<br />'. 
     2077                'nested&nbsp;&lt;verbatim&nbsp;class=&quot;tml&quot;&gt;%H%&lt;!--?--&gt;&lt;/verbatim&gt;<br />'. 
     2078                '&lt;literal&gt;&lt;font&nbsp;color="blue"&gt;&nbsp;*|B|*&nbsp;&lt;/font&gt;&lt;/literal&gt;<br />'. 
     2079                '&lt;mytag&nbsp;attr="value"&gt;my&nbsp;content&lt;/mytag&gt;<br />'. 
     2080                '<br />'. 
     2081                '&lt;sticky&gt;&nbsp;block&nbsp;&lt;/sticky&gt;<br />'. 
     2082                '<br />'. 
     2083                '&lt;pre&gt;<br />'. 
     2084                '&nbsp;&nbsp;123<br />'. 
     2085                '&nbsp;456<br />'. 
     2086                '&lt;/pre&gt;</pre>'. 
     2087                '</p>' 
     2088    }, 
     2089    { 
     2090        exec => $TML2HTML | $HTML2TML | $ROUNDTRIP, 
     2091        name => 'comment', 
     2092        tml  => <<GLUED, 
     2093<!--<font color="blue"> *|B|* </font> 
     2094 
     2095http://google.com/#q=foswiki 
     2096%FOO% WikiWord [[some link]] 
     2097   * Set bar=baz 
     2098<img src="%!page!%/logo.png" alt="Alternate text" /> 
     2099 
     2100<verbatim class="tml">%H%<!--?--></verbatim> 
     2101<literal><font color="blue"> *|B|* </font></literal> 
     2102<mytag attr="value">my content</mytag> 
     2103 
     2104<sticky> block </sticky> 
     2105 
     2106<pre> 
     2107  123 
     2108 456 
     2109</pre>--> 
     2110GLUED 
     2111        html => '<p>'.$protecton. 
     2112                '&lt;!--&#60;font&nbsp;color="blue"&#62;&nbsp;*|B|*&nbsp;&#60;/font&#62;<br />'. 
     2113                '<br />'. 
     2114                'http://google.com/#q=foswiki<br />'. 
     2115                '%FOO%&nbsp;WikiWord&nbsp;[[some&nbsp;link]]<br />'. 
     2116                '&nbsp;&nbsp;&nbsp;*&nbsp;Set&nbsp;bar=baz<br />'. 
     2117                '&lt;img&nbsp;src=&quot;%!page!%/logo.png&quot;&nbsp;alt=&quot;Alternate&nbsp;text&quot;&nbsp;/&gt;<br />'. 
     2118                '<br />'. 
     2119                '&lt;verbatim&nbsp;class=&quot;tml&quot;&gt;%H%&lt;!--?--&gt;&lt;/verbatim&gt;<br />'. 
     2120                '&lt;literal&gt;&lt;font&nbsp;color="blue"&gt;&nbsp;*|B|*&nbsp;&lt;/font&gt;&lt;/literal&gt;<br />'. 
     2121                '&lt;mytag&nbsp;attr="value"&gt;my&nbsp;content&lt;/mytag&gt;<br />'. 
     2122                '<br />'. 
     2123                '&lt;sticky&gt;&nbsp;block&nbsp;&lt;/sticky&gt;<br />'. 
     2124                '<br />'. 
     2125                '&lt;pre&gt;<br />'. 
     2126                '&nbsp;&nbsp;123<br />'. 
     2127                '&nbsp;456<br />'. 
     2128                '&lt;/pre&gt;--&gt;'. 
     2129                $protectoff.'</p>', 
     2130    }, 
     2131    { 
     2132        # SMELL: The macro, the *Set value and the comment  
     2133        #        should be in WYSIWYG_PROTECTED spans 
     2134        #        but HTML2TML doesn't yet cater for that 
     2135        # So this test captures current (long-standing) behaviour,  
     2136        # but the behaviour isn't really correct 
     2137        exec => $TML2HTML | $HTML2TML | $ROUNDTRIP, 
     2138        name => 'literal', 
     2139        tml  => <<'HERE', 
     2140<literal> 
     2141<font color="blue"> *|B|* </font> 
     2142http://google.com/#q=foswiki WikiWord [[some link]] 
     2143%FOO{"<b>html in macro param</b>"}% <!-- hidden --> 
     2144<pre> 
     2145  123 
     2146 456 
     2147</pre> 
     2148   * Set bar=baz 
     2149<mytag attr="value">my content</mytag> 
     2150</literal> 
     2151HERE 
     2152        html => <<"HERE", 
     2153<p> 
     2154<div class="WYSIWYG_LITERAL"> 
     2155<font color="blue"> *|B|* </font> 
     2156http://google.com/#q=foswiki WikiWord [[some link]] 
     2157%FOO{"<b>html in macro param</b>"}% <!-- hidden --> 
     2158<pre> 
     2159  123 
     2160 456 
     2161</pre> 
     2162   * Set bar=baz 
     2163<mytag attr="value">my content</mytag> 
     2164</div> 
     2165</p> 
     2166HERE 
     2167        finaltml => <<'HERE', 
     2168<literal> 
     2169<font color='blue'> *|B|* </font> 
     2170http://google.com/#q=foswiki WikiWord [[some link]] 
     2171%FOO{"<b>html in macro param</b>"}% <!-- hidden --> 
     2172<pre> 
     2173  123 
     2174 456 
     2175</pre> 
     2176   * Set bar=baz 
     2177<mytag attr='value'>my content</mytag> 
     2178</literal> 
     2179HERE 
    19792180    }, 
    19802181    { 
     
    19982199    }, 
    19992200    { 
    2000         exec => $HTML2TML | $ROUNDTRIP, 
    2001         name => 'stickyInsideVerbatimItem1980', 
    2002         tml  => <<'GLUED', 
    2003 <verbatim><sticky>banana</sticky></verbatim> 
    2004 GLUED 
    2005         html => <<'BLAH', 
    2006 <p> 
    2007 <pre class="TMLverbatim">&lt;sticky&gt;banana&lt;/sticky&gt;</pre> 
    2008 </p> 
    2009 BLAH 
    2010     }, 
    2011     { 
    2012         exec => $ROUNDTRIP, 
    2013         name => 'literalInsideVerbatimItem1980', 
    2014         tml  => <<'GLUED', 
    2015 <verbatim><literal><font color="blue"> *|B|* </font></literal></verbatim> 
    2016 GLUED 
    2017     }, 
    2018     { 
    20192201        exec => $ROUNDTRIP, 
    20202202        name => 'verbatimInsideLiteralItem1980', 
     
    20222204<literal><font color="blue"> *|B|*<verbatim>%H%</verbatim> </font></literal> 
    20232205GLUED 
    2024     }, 
    2025     { 
    2026         exec => $TML2HTML | $ROUNDTRIP, 
    2027         name => 'verbatimInsideStickyItem1980', 
    2028         tml  => <<'GLUED', 
    2029 <sticky><font color="blue"> *|B|*<verbatim>%H%</verbatim> </font></sticky> 
    2030 GLUED 
    2031         html => <<'STUCK' 
    2032 <p> 
    2033 <div class="WYSIWYG_STICKY">&#60;font&nbsp;color="blue"&#62;&nbsp;*|B|*&lt;verbatim&gt;%H%&lt;/verbatim&gt;&nbsp;&#60;/font&#62;</div> 
    2034 </p> 
    2035 STUCK 
    2036     }, 
    2037     { 
    2038         exec => $TML2HTML | $ROUNDTRIP, 
    2039         name => 'literalInsideSticky', 
    2040         tml  => <<'GLUED', 
    2041 <sticky><literal><font color="blue"> *|B|* </font></literal></sticky> 
    2042 GLUED 
    2043         html => <<'STUCK' 
    2044 <p> 
    2045 <div class="WYSIWYG_STICKY">&#60;literal&#62;&#60;font&nbsp;color="blue"&#62;&nbsp;*|B|*&nbsp;&#60;/font&#62;&#60;/literal&#62;</div> 
    2046 </p> 
    2047 STUCK 
    20482206    }, 
    20492207    { 
     
    24162574    { 
    24172575        name => "Item2222", 
    2418         exec => $ROUNDTRIP | $CANNOTWYSIWYG, 
     2576        exec => $ROUNDTRIP, 
    24192577        tml  => '<!-- <sticky></sticky> -->', 
    24202578    }, 
     
    24732631<p><span class="WYSIWYG_PROTECTED">%JQPLUGINS{"scrollto"<br />&nbsp;&nbsp;format="<br />&nbsp;&nbsp;&nbsp;&nbsp;Homepage:&nbsp;$homepage&nbsp;&lt;br&nbsp;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;Author(s):&nbsp;$author&nbsp;&lt;br&nbsp;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;Version:&nbsp;$version<br />&nbsp;&nbsp;"<br />}%</span></p> 
    24742632HERE 
    2475     } 
     2633    }, 
     2634    { 
     2635        name => "stuffInMacro", 
     2636        exec => $TML2HTML | $ROUNDTRIP, 
     2637        tml => <<'HERE', 
     2638%MACRO{" 
     2639a%ANOTHER% 
     2640<verbatim>V</verbatim> 
     2641<sticky>S</sticky> 
     2642<literal>L</literal> 
     2643<pre>P</pre> 
     2644<!--C--> 
     2645   * Set foo=bar 
     2646http://google.com/#q=foswiki 
     2647WikiWord [[some link]] 
     2648<mytag attr="value">my content</mytag> 
     2649<img src="http://mysite.org/logo.png" alt="Alternate text" /> 
     2650"}% 
     2651HERE 
     2652        html => '<p>' . 
     2653                '<span class="WYSIWYG_PROTECTED">'. 
     2654                '%MACRO{"<br />'. 
     2655                'a%ANOTHER%<br />'. 
     2656                '&lt;verbatim&gt;V&lt;/verbatim&gt;<br />'. 
     2657                '&lt;sticky&gt;S&lt;/sticky&gt;<br />'. 
     2658                '&lt;literal&gt;L&lt;/literal&gt;<br />'. 
     2659                '&lt;pre&gt;P&lt;/pre&gt;<br />'. 
     2660                '&lt;!--C--&gt;<br />'. 
     2661                '&nbsp;&nbsp;&nbsp;*&nbsp;Set&nbsp;foo=bar<br />'. 
     2662                'http://google.com/#q=foswiki<br />'. 
     2663                'WikiWord&nbsp;[[some&nbsp;link]]<br />'. 
     2664                '&lt;mytag&nbsp;attr="value"&gt;my&nbsp;content&lt;/mytag&gt;<br />'. 
     2665                '&lt;img&nbsp;src=&quot;http://mysite.org/logo.png&quot;&nbsp;alt=&quot;Alternate&nbsp;text&quot;&nbsp;/&gt;<br />'. 
     2666                '"}%'. 
     2667                '</span>'. 
     2668                '</p>' 
     2669    }, 
     2670    { 
     2671        name => "failsTML2HTML", 
     2672        exec => 0,#$TML2HTML | $HTML2TML | $ROUNDTRIP, 
     2673        tml  => <<'HERE', 
     2674%MACRO{" 
     2675%ANOTHERMACRO%"}% 
     2676HERE 
     2677        html => <<'HERE', 
     2678<p><span class="WYSIWYG_PROTECTED">%MACRO{"<br />%ANOTHERMACRO%"}%</span></p> 
     2679HERE 
     2680    }, 
    24762681]; 
    24772682 
Note: See TracChangeset for help on using the changeset viewer.