- Timestamp:
- 05/27/09 19:49:34 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
r3984 r3985 361 361 return $text; 362 362 } 363 # 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 363 401 364 402 # Collapse adjacent VERBATIM nodes together 403 # Collapse adjacent STICKY nodes together 365 404 # Collapse a <p> that contains only a protected span into a protected P 366 405 # Collapse em in em … … 372 411 while ( scalar(@jobs) ) { 373 412 my $node = shift(@jobs); 374 if ( defined( $node->{tag} ) && $node->hasClass('TMLverbatim') ) { 375 my $next = $node->{next}; 376 my @edible; 377 my $collapsible; 378 while ( 379 $next 380 && ( 381 ( !$next->{tag} && $next->{text} =~ /^\s*$/ ) 382 || ( $node->{tag} eq $next->{tag} 383 && $next->hasClass('TMLverbatim') ) 384 ) 385 ) 386 { 387 push( @edible, $next ); 388 $collapsible ||= $next->hasClass('TMLverbatim'); 389 $next = $next->{next}; 390 } 391 if ($collapsible) { 392 foreach my $meal (@edible) { 393 $meal->_remove(); 394 if ( $meal->{tag} ) { 395 require Foswiki::Plugins::WysiwygPlugin::HTML2TML::Leaf; 396 $node->addChild( 397 new Foswiki::Plugins::WysiwygPlugin::HTML2TML::Leaf( 398 $WC::NBBR) 399 ); 400 $node->_eat($meal); 401 } 402 } 403 } 404 } 413 _collapseOneClass($node, 'TMLverbatim'); 414 _collapseOneClass($node, 'WYSIWYG_STICKY'); 405 415 if ( $node->{tag} eq 'p' 406 416 && $node->{head} … … 408 418 { 409 419 my $kid = $node->{head}; 410 if ( $kid->{tag}eq 'SPAN'420 if ( uc($kid->{tag}) eq 'SPAN' 411 421 && $kid->hasClass('WYSIWYG_PROTECTED') ) 412 422 {
Note: See TracChangeset
for help on using the changeset viewer.
