/[swish]/trunk/html/FormatResult.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/html/FormatResult.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 89 by dpavlin, Tue Aug 31 09:04:15 2004 UTC revision 90 by dpavlin, Wed Sep 1 14:12:57 2004 UTC
# Line 92  sub get_snippet { Line 92  sub get_snippet {
92  This is stand-alone function which does highlite. It cycle colors  This is stand-alone function which does highlite. It cycle colors
93  and generate html. Have in mind that it takes ref arguments.  and generate html. Have in mind that it takes ref arguments.
94    
95    C<@words> can also be array of arrays if you have alternative spellings
96    for each word (e.g. using C<Lingua::Spelling::Alternative>).
97    
98  =cut  =cut
99    
100  sub highlite_words {  sub highlite_words {
# Line 109  sub highlite_words { Line 112  sub highlite_words {
112          my $i = 0;          my $i = 0;
113    
114          foreach my $w (@words) {          foreach my $w (@words) {
115                  $$snip_ref =~ s,(\b\Q$w\E),<span style="background: $colors[$i]; color:black;">$1</span>,gsi;                  if ($w =~ m/ARRAY/) {
116                            foreach my $ww (sort { length($b) <=> length($a) } @{$w}) {
117                                    $$snip_ref =~ s,(\b\Q$ww\E),<span style="background: $colors[$i]; color:black;">$1</span>,gsi;
118                            }
119                    } else {
120                            $$snip_ref =~ s,(\b\Q$w\E),<span style="background: $colors[$i]; color:black;">$1</span>,gsi;
121                    }
122                  $i++;                  $i++;
123                  $i = 0 if ($i > $#colors);                  $i = 0 if ($i > $#colors);
124          }          }

Legend:
Removed from v.89  
changed lines
  Added in v.90

  ViewVC Help
Powered by ViewVC 1.1.26