- Timestamp:
- 05/27/09 19:54:07 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
r3985 r3986 361 361 return $text; 362 362 } 363 363 364 # 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 365 sub _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 } 401 400 402 401 # Collapse adjacent VERBATIM nodes together … … 411 410 while ( scalar(@jobs) ) { 412 411 my $node = shift(@jobs); 413 _collapseOneClass($node, 'TMLverbatim');414 _collapseOneClass($node, 'WYSIWYG_STICKY');412 _collapseOneClass( $node, 'TMLverbatim' ); 413 _collapseOneClass( $node, 'WYSIWYG_STICKY' ); 415 414 if ( $node->{tag} eq 'p' 416 415 && $node->{head} … … 418 417 { 419 418 my $kid = $node->{head}; 420 if ( uc($kid->{tag}) eq 'SPAN'419 if ( uc( $kid->{tag} ) eq 'SPAN' 421 420 && $kid->hasClass('WYSIWYG_PROTECTED') ) 422 421 { … … 465 464 { 466 465 467 my %new_attrs = ( class => $class );466 my %new_attrs = ( class => $class ); 468 467 $new_attrs{style} = $this->{attrs}->{style} 469 468 if exists $this->{attrs}->{style};
Note: See TracChangeset
for help on using the changeset viewer.
