Ignore:
Timestamp:
05/10/09 16:02:03 (3 years ago)
Author:
MichaelTempest
Message:

Item1535: Inserted span elements when WYSIWYG_TT class is applied to other elements. Added unit tests to replicate fault.

Also updated the internal test documentation in TranslatorTest.pm. (CDot: Thanks for explaining things)

Added explicit event handlers for each type of event generated by HTML::Parser, to eliminate the empty text elements generated from the start_document and end_document events. The default event handler should never be called, now.

File:
1 edited

Legend:

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

    r3396 r3875  
    363363 
    364364# Collapse adjacent VERBATIM nodes together 
    365 # Collapse a <p> than contains only a protected span into a protected P 
     365# Collapse a <p> that contains only a protected span into a protected P 
    366366# Collapse em in em 
    367367# Collapse adjacent text nodes 
     
    444444} 
    445445 
     446# If this node has the specified class, insert a new "span" node with that 
     447# class between this node and all of this node's children. 
     448sub _moveClassToSpan 
     449{ 
     450    my $this = shift; 
     451    my $class = shift; 
     452 
     453    if ( $this->{tag} and  
     454         lc($this->{tag}) ne 'span' and 
     455         $this->_removeClass($class) ) { 
     456          
     457        my $newspan = new Foswiki::Plugins::WysiwygPlugin::HTML2TML::Node( $this->{context}, 'span', { class => $class } ); 
     458        my $kid = $this->{head}; 
     459        while ($kid) { 
     460            $newspan->addChild($kid); 
     461            $kid = $kid->{next}; 
     462        } 
     463        $this->{head} = $this->{tail} = $newspan; 
     464    } 
     465} 
     466 
    446467# the actual generate function. rootGenerate is only applied to the root node. 
    447468sub generate { 
     
    487508    $tag =~ s/!//;    # DOCTYPE 
    488509    my $tmlFn = '_handle' . uc($tag); 
     510 
     511    $this->_moveClassToSpan('WYSIWYG_TT'); 
    489512 
    490513    # See if we have a TML translation function for this tag 
     
    839862    while ($kid) { 
    840863        if ( $kid->{tag} eq 'th' ) { 
     864            $kid->_moveClassToSpan('WYSIWYG_TT'); 
    841865            ( $flags, $text ) = $kid->_flatten($options); 
    842866            $text = _TDtrim($text); 
     
    844868        } 
    845869        elsif ( $kid->{tag} eq 'td' ) { 
     870            $kid->_moveClassToSpan('WYSIWYG_TT'); 
    846871            ( $flags, $text ) = $kid->_flatten($options); 
    847872            $text = _TDtrim($text); 
Note: See TracChangeset for help on using the changeset viewer.