Perlfect Solutions
 

[Perlfect-search] stop highlighting of ignored document parts

Morten Wulff perlfect-search@perlfect.com
Fri, 05 Jul 2002 10:13:50 +0200
First of all, a big 'thank you' to Giorgos and Daniel for a great piece of 
software!

On one of my sites, some of the most popular search terms were also used in 
the site navigation. I put all navigation elements between 
$IGNORE_TEXT_START- and $IGNORE_TEXT_END-tags. Unfortunately the text in 
the navigation elements were still highlighted.

So, I've taken the liberty of making a small change to search.pl to fix 
this problem. Please correct me, if I've made any blatant mistakes ;-)

Diff against latest cvs version below.

Regards,
Morten Wulff

----

*** search_cvs.pl       Fri Jul  5 09:55:34 2002
--- search.pl   Fri Jul  5 09:55:30 2002
***************
*** 200,209 ****
     my $color = shift;
     my $content_new = "";
     my @comments = split(/(<!--.*?-->)/igs, $content);
     foreach my $c (@comments) {
       my @tags = split(/(<.*?>)/igs, $c);
       foreach my $part (@tags) {
!       if( $part !~ m/^</ ) {
           $part = normalize_special_chars($part);
           $part =~ s/\b($term)\b/<highlight>$1<\/highlight>/igs;
           # repair possibly damaged entities:
--- 200,212 ----
     my $color = shift;
     my $content_new = "";
     my @comments = split(/(<!--.*?-->)/igs, $content);
+   my $in_ignore = 0;
     foreach my $c (@comments) {
       my @tags = split(/(<.*?>)/igs, $c);
       foreach my $part (@tags) {
!       $in_ignore = 1 if $part =~ /$IGNORE_TEXT_START/;
!       $in_ignore = 0 if $part =~ /$IGNORE_TEXT_END/;
!       if( $part !~ m/^</ && !$in_ignore ) {
           $part = normalize_special_chars($part);
           $part =~ s/\b($term)\b/<highlight>$1<\/highlight>/igs;
           # repair possibly damaged entities: