*** Search.pm.old Sun Jan 5 02:36:46 2003 --- Search.pm Wed Mar 5 17:48:02 2003 *************** *** 462,468 **** $beforeText =~ s/%WEB%/$thisWebName/go; $beforeText = &TWiki::handleCommonTags( $beforeText, $topic ); $afterText = &TWiki::handleCommonTags( $afterText, $topic ); ! if( ! $noHeader ) { if( $doInline || $theFormat ) { # print at the end if formatted search because of table rendering $searchResult .= $beforeText; --- 462,468 ---- $beforeText =~ s/%WEB%/$thisWebName/go; $beforeText = &TWiki::handleCommonTags( $beforeText, $topic ); $afterText = &TWiki::handleCommonTags( $afterText, $topic ); ! if( ! $noHeader || ( ( $noHeader eq "if" ) && ( $#topicList >= 0 ) ) ) { if( $doInline || $theFormat ) { # print at the end if formatted search because of table rendering $searchResult .= $beforeText; *************** *** 648,653 **** --- 648,654 ---- $tempVal =~ s/\$summary/&TWiki::makeTopicSummary( $text, $topic, $thisWebName )/geos; $tempVal =~ s/\$formfield\(\s*([^\)]*)\s*\)/getMetaFormField( $meta, $1 )/geos; $tempVal =~ s/\$pattern\(\s*(.*?\s*\.\*)\)/getTextPattern( $text, $1 )/geos; + $tempVal =~ s/\$highlight\(\s*(.*?\s*)\.\*\)/getTextHighlights( $text, $topic, $thisWebName, $1 )/geos; $tempVal =~ s/\$nop(\(\))?//gos; # remove filler, useful for nested search $tempVal =~ s/\$quot(\(\))?/\"/gos; # expand double quote $tempVal =~ s/\$percnt(\(\))?/\%/gos; # expand percent *************** *** 766,771 **** --- 767,808 ---- $theText = "" unless( $theText =~ s/$thePattern/$1/is ); return $theText; + } + + #========================= + sub getTextHighlights + { + my( $theText, $theTopic, $theWeb, $thePattern ) = @_; + + return &TWiki::makeTopicSummary( $theText, $theTopic, $theWeb ) if (!$thePattern); + + $thePattern =~ s/([^\\])([\$\@\%\&\#\'\`\/])/$1\\$2/go; # escape some special chars + $thePattern =~ /(.*)/; # untaint + $thePattern = $1; + my $result = "