Ignore:
Timestamp:
04/10/09 10:37:08 (3 years ago)
Author:
CrawfordCurrie
Message:

Item1394: fixed colour handling

File:
1 edited

Legend:

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

    r2957 r3396  
    260260 
    261261    # Handle colour tags specially (hack, hack, hackity-HACK!) 
    262     my $colourMatch = join( '|', grep( /^[A-Z]/, keys %WC::KNOWN_COLOUR ) ); 
    263     while ( $text =~ 
    264         s#%($colourMatch)%(.*?)%ENDCOLOR%#<font color="\L$1\E">$2</font>#og ) 
    265     { 
    266     } 
     262    my $colourMatch = join( '|', grep( /^[A-Z]/, @WC::TML_COLOURS ) ); 
     263    $text =~ s#%($colourMatch)%(.*?)%ENDCOLOR%# 
     264      _getNamedColour($1, $2)#oge; 
    267265 
    268266    # Convert Foswiki tags to spans outside protected text 
     
    508506} 
    509507 
     508sub _getNamedColour { 
     509    my ( $name, $t ) = @_; 
     510    my $epr = Foswiki::Func::getPreferencesValue($name); 
     511 
     512    # Match <font color="x" and style="color:x" 
     513    if ( 
     514        defined $epr 
     515        && (   $epr =~ /color=["'](#?\w+)['"]/ 
     516            || $epr =~ /color\s*:\s*(#?\w+)/ ) 
     517      ) 
     518    { 
     519        return "<span class='WYSIWYG_COLOR' style='color:$1'>$t</span>"; 
     520    } 
     521 
     522    # Can't map to a 'real' colour; leave the variables 
     523    return '%' . $name . '%' . $t . '%ENDCOLOR%'; 
     524} 
     525 
    510526sub _addClass { 
    511527    if ( $_[0] ) { 
Note: See TracChangeset for help on using the changeset viewer.