Changeset 3986


Ignore:
Timestamp:
05/27/09 19:54:07 (3 years ago)
Author:
MichaelTempest
Message:

Item1667: perltidy

Location:
trunk/WysiwygPlugin
Files:
2 edited

Legend:

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

    r3985 r3986  
    361361    return $text; 
    362362} 
     363 
    363364# collapse adjacent nodes together, if they share the same class 
    364 sub _collapseOneClass 
    365 { 
    366     my $node = shift; 
    367         my $class = shift; 
    368         if ( defined( $node->{tag} ) && $node->hasClass($class) ) { 
    369                 my $next = $node->{next}; 
    370                 my @edible; 
    371                 my $collapsible; 
    372                 while ( 
    373                         $next 
    374                         && ( 
    375                                 ( !$next->{tag} && $next->{text} =~ /^\s*$/ ) 
    376                                 || (   $node->{tag} eq $next->{tag} 
    377                                         && $next->hasClass($class) ) 
    378                         ) 
    379                   ) 
    380                 { 
    381                         push( @edible, $next ); 
    382                         $collapsible ||= $next->hasClass($class); 
    383                         $next = $next->{next}; 
    384                 } 
    385                 if ($collapsible) { 
    386                         foreach my $meal (@edible) { 
    387                                 $meal->_remove(); 
    388                                 if ( $meal->{tag} ) { 
    389                                         require Foswiki::Plugins::WysiwygPlugin::HTML2TML::Leaf; 
    390                                         $node->addChild( 
    391                                                 new Foswiki::Plugins::WysiwygPlugin::HTML2TML::Leaf( 
    392                                                         $WC::NBBR) 
    393                                         ); 
    394                                         $node->_eat($meal); 
    395                                 } 
    396                         } 
    397                 } 
    398         } 
    399 } 
    400  
     365sub _collapseOneClass { 
     366    my $node  = shift; 
     367    my $class = shift; 
     368    if ( defined( $node->{tag} ) && $node->hasClass($class) ) { 
     369        my $next = $node->{next}; 
     370        my @edible; 
     371        my $collapsible; 
     372        while ( 
     373            $next 
     374            && ( 
     375                ( !$next->{tag} && $next->{text} =~ /^\s*$/ ) 
     376                || (   $node->{tag} eq $next->{tag} 
     377                    && $next->hasClass($class) ) 
     378            ) 
     379          ) 
     380        { 
     381            push( @edible, $next ); 
     382            $collapsible ||= $next->hasClass($class); 
     383            $next = $next->{next}; 
     384        } 
     385        if ($collapsible) { 
     386            foreach my $meal (@edible) { 
     387                $meal->_remove(); 
     388                if ( $meal->{tag} ) { 
     389                    require Foswiki::Plugins::WysiwygPlugin::HTML2TML::Leaf; 
     390                    $node->addChild( 
     391                        new Foswiki::Plugins::WysiwygPlugin::HTML2TML::Leaf( 
     392                            $WC::NBBR) 
     393                    ); 
     394                    $node->_eat($meal); 
     395                } 
     396            } 
     397        } 
     398    } 
     399} 
    401400 
    402401# Collapse adjacent VERBATIM nodes together 
     
    411410    while ( scalar(@jobs) ) { 
    412411        my $node = shift(@jobs); 
    413                 _collapseOneClass($node, 'TMLverbatim'); 
    414                 _collapseOneClass($node, 'WYSIWYG_STICKY'); 
     412        _collapseOneClass( $node, 'TMLverbatim' ); 
     413        _collapseOneClass( $node, 'WYSIWYG_STICKY' ); 
    415414        if (   $node->{tag} eq 'p' 
    416415            && $node->{head} 
     
    418417        { 
    419418            my $kid = $node->{head}; 
    420             if (   uc($kid->{tag}) eq 'SPAN' 
     419            if ( uc( $kid->{tag} ) eq 'SPAN' 
    421420                && $kid->hasClass('WYSIWYG_PROTECTED') ) 
    422421            { 
     
    465464    { 
    466465 
    467                 my %new_attrs = ( class => $class ); 
     466        my %new_attrs = ( class => $class ); 
    468467        $new_attrs{style} = $this->{attrs}->{style} 
    469468          if exists $this->{attrs}->{style}; 
  • trunk/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm

    r3985 r3986  
    232232</p> 
    233233BLAH 
    234                 tml => '*%RED% =Code= %ENDCOLOR%*' 
     234        tml => '*%RED% =Code= %ENDCOLOR%*' 
    235235    }, 
    236236    { 
     
    876876 </verbatim> Outside', 
    877877    }, 
    878         { 
    879                 exec => $TML2HTML | $ROUNDTRIP, 
    880                 name => 'verbatimWithNbsp1554', 
    881                 html => '<p><pre class="TMLverbatim">&amp;nbsp;</pre></p>', 
    882                 tml => "<verbatim>&nbsp;</verbatim>" 
    883         }, 
     878    { 
     879        exec => $TML2HTML | $ROUNDTRIP, 
     880        name => 'verbatimWithNbsp1554', 
     881        html => '<p><pre class="TMLverbatim">&amp;nbsp;</pre></p>', 
     882        tml => "<verbatim>&nbsp;</verbatim>" 
     883    }, 
    884884    { 
    885885        exec => $TML2HTML | $ROUNDTRIP, 
     
    16131613' 
    16141614    }, 
    1615         { 
    1616                 exec => $HTML2TML, 
    1617                 name => 'mergeStickyItem1667', 
    1618                 html => <<'BLAH', 
     1615    { 
     1616        exec => $HTML2TML, 
     1617        name => 'mergeStickyItem1667', 
     1618        html => <<'BLAH', 
    16191619<div class="WYSIWYG_STICKY">Line 1</div> 
    16201620<div class="WYSIWYG_STICKY">Line 2</div> 
    16211621BLAH 
    1622                 tml => "<sticky>Line 1\nLine 2</sticky>" 
    1623         }, 
    1624         { 
    1625                 exec => $HTML2TML | $ROUNDTRIP, 
    1626                 name => 'separateStickyRegions', 
    1627                 html => <<'BLAH', 
     1622        tml => "<sticky>Line 1\nLine 2</sticky>" 
     1623    }, 
     1624    { 
     1625        exec => $HTML2TML | $ROUNDTRIP, 
     1626        name => 'separateStickyRegions', 
     1627        html => <<'BLAH', 
    16281628<div class="WYSIWYG_STICKY">Oranges</div> 
    16291629<p></p> 
    16301630<div class="WYSIWYG_STICKY">Apples</div> 
    16311631BLAH 
    1632                 tml => "<sticky>Oranges</sticky>\n\n<sticky>Apples</sticky>" 
    1633         }, 
     1632        tml => "<sticky>Oranges</sticky>\n\n<sticky>Apples</sticky>" 
     1633    }, 
    16341634    { 
    16351635        exec => $TML2HTML, 
     
    17561756</table> 
    17571757BLAH 
    1758         tml  => <<'BLAH', 
     1758        tml => <<'BLAH', 
    17591759| *%RED%Red Heading%ENDCOLOR%* | 
    17601760| %RED%Red herring%ENDCOLOR% | 
     
    17701770</table> 
    17711771BLAH 
    1772         tml  => <<'BLAH', 
     1772        tml => <<'BLAH', 
    17731773| *%RED% =Redder code= %ENDCOLOR%* | 
    17741774| %RED% =Red code= %ENDCOLOR% | 
Note: See TracChangeset for help on using the changeset viewer.