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 { |
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 |
} |
} |