Search engines like Google highlight the search terms in the summaries of the search results
(
example). It would be nice, if the TWiki search could provide a similar feature.
Actually, I have implemented an extension to TWiki's SEARCH{} variable, that allows us to do this.
$highlight(regexp.*) works like $pattern() in that it extracts some text from a page. However, it does not only extract the text matching the regular expression but the previous and following 2x162 characters (using makeTopicSummary). The text matching the regular expression is highlighted. All matches for one page are shown in a bulleted list.
You can try a search using this technique
here.
I will attach a minor patch for TWiki.pm (support for reversed topic summary (i.e. 162 chars from the end of a string)) and the main patch for Search.pm (implementation of $highlight()). I also added a $noHeader = "if" option that will cause the header to be shown only if the search was successful.
--
JohannesMartin - 05 Mar 2003
See also
MultipleSearchesInSameTopic,
MultiExtractionWithinTopic,
FormattedSearchinTopics,
FormattedSearchGetMultipleHitsPerTopic
--
PeterThoeny - 02 Apr 2003
Category:
TWikiPatches