Changeset 3900


Ignore:
Timestamp:
05/13/09 20:16:40 (3 years ago)
Author:
MichaelTempest
Message:

Item1535, Item1397: Merge changes from trunk to release branch

Location:
branches/Release01x00/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/Release01x00/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML.pm

    r3899 r3900  
    6666 
    6767    my $this = new HTML::Parser( 
    68         start_h       => [ \&_openTag,  'self,tagname,attr' ], 
    69         end_h         => [ \&_closeTag, 'self,tagname' ], 
    70         declaration_h => [ \&_ignore,   'self' ], 
    71         default_h     => [ \&_text,     'self,text' ], 
    72         comment_h     => [ \&_comment,  'self,text' ] 
     68        start_h          => [ \&_openTag,  'self,tagname,attr' ], 
     69        end_h            => [ \&_closeTag, 'self,tagname' ], 
     70        text_h           => [ \&_text,     'self,text' ], 
     71        comment_h        => [ \&_comment,  'self,text' ], 
     72        declaration_h    => [ \&_ignore,   'self' ], 
     73        start_document_h => [ \&_ignore,   'self' ], 
     74        end_document_h   => [ \&_ignore,   'self' ], 
     75        default_h        => [ \&_default,  'self,event,text' ] 
    7376    ); 
    7477 
     
    220223} 
    221224 
     225sub _default { 
     226        my ( $this, $event, $text ) = @_; 
     227    # Unexpected $event event from HTML::Parser; text contains '$text' 
     228        ASSERT(0); 
     229} 
     230 
    222231sub _apply { 
    223232    my ( $this, $tag ) = @_; 
  • branches/Release01x00/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm

    r3899 r3900  
    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); 
  • branches/Release01x00/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm

    r3899 r3900  
    472472      (CGI::span({class => 'WYSIWYG_TT'}, $1))gem; 
    473473 
    474     # Handle [[][] and [[]] links 
     474    # Handle [[][]] and [[]] links 
    475475 
    476476    # We _not_ support [[http://link text]] syntax 
     
    772772        } 
    773773 
    774         push( @tr, { fn => $fn, attr => $attr, text => $cell } ); 
     774        $cell = ' '.$cell if $cell =~ /^(?:\*|==?|__?)[^\s]/; 
     775        $cell = $cell.' ' if $cell =~ /[^\s](?:\*|==?|__?)$/; 
     776 
     777        push( @tr, { fn => $fn, attr => $attr, text => $cell } );  
    775778    } 
    776779 
Note: See TracChangeset for help on using the changeset viewer.