Changeset 3900
- Timestamp:
- 05/13/09 20:16:40 (3 years ago)
- Location:
- branches/Release01x00/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin
- Files:
-
- 3 edited
-
HTML2TML.pm (modified) (2 diffs)
-
HTML2TML/Node.pm (modified) (5 diffs)
-
TML2HTML.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/Release01x00/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML.pm
r3899 r3900 66 66 67 67 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' ] 73 76 ); 74 77 … … 220 223 } 221 224 225 sub _default { 226 my ( $this, $event, $text ) = @_; 227 # Unexpected $event event from HTML::Parser; text contains '$text' 228 ASSERT(0); 229 } 230 222 231 sub _apply { 223 232 my ( $this, $tag ) = @_; -
branches/Release01x00/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
r3899 r3900 363 363 364 364 # Collapse adjacent VERBATIM nodes together 365 # Collapse a <p> tha ncontains only a protected span into a protected P365 # Collapse a <p> that contains only a protected span into a protected P 366 366 # Collapse em in em 367 367 # Collapse adjacent text nodes … … 444 444 } 445 445 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. 448 sub _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 446 467 # the actual generate function. rootGenerate is only applied to the root node. 447 468 sub generate { … … 487 508 $tag =~ s/!//; # DOCTYPE 488 509 my $tmlFn = '_handle' . uc($tag); 510 511 $this->_moveClassToSpan('WYSIWYG_TT'); 489 512 490 513 # See if we have a TML translation function for this tag … … 839 862 while ($kid) { 840 863 if ( $kid->{tag} eq 'th' ) { 864 $kid->_moveClassToSpan('WYSIWYG_TT'); 841 865 ( $flags, $text ) = $kid->_flatten($options); 842 866 $text = _TDtrim($text); … … 844 868 } 845 869 elsif ( $kid->{tag} eq 'td' ) { 870 $kid->_moveClassToSpan('WYSIWYG_TT'); 846 871 ( $flags, $text ) = $kid->_flatten($options); 847 872 $text = _TDtrim($text); -
branches/Release01x00/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
r3899 r3900 472 472 (CGI::span({class => 'WYSIWYG_TT'}, $1))gem; 473 473 474 # Handle [[][] and [[]] links474 # Handle [[][]] and [[]] links 475 475 476 476 # We _not_ support [[http://link text]] syntax … … 772 772 } 773 773 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 } ); 775 778 } 776 779
Note: See TracChangeset
for help on using the changeset viewer.
