--- trunk/html/FormatResult.pm 2004/08/31 09:04:15 89 +++ trunk/html/FormatResult.pm 2005/07/09 13:14:25 107 @@ -92,6 +92,9 @@ This is stand-alone function which does highlite. It cycle colors and generate html. Have in mind that it takes ref arguments. +C<@words> can also be array of arrays if you have alternative spellings +for each word (e.g. using C). + =cut sub highlite_words { @@ -103,13 +106,19 @@ my @words = sort { length($b) <=> length($a) } @{$words_ref}; # colors to highlite - my @colors = qw{#ffff66 #a0ffff #99ff99 #ff9999 #ff66ff}; + my @colors = ('#ffff66','#a0ffff','#99ff99','#ff9999','#ff66ff'); # color offset my $i = 0; foreach my $w (@words) { - $$snip_ref =~ s,(\b\Q$w\E),$1,gsi; + if ($w =~ m/ARRAY/) { + foreach my $ww (sort { length($b) <=> length($a) } @{$w}) { + $$snip_ref =~ s,(\b\Q$ww\E\w*),$1,gsi; + } + } else { + $$snip_ref =~ s,(\b\Q$w\E\w*),$1,gsi; + } $i++; $i = 0 if ($i > $#colors); }