Tags:
create new tag
, view all tags
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
Topic attachments
I Attachment Action Size Date Who Comment
elsediff Search.pm.diff manage 2.9 K 05 Mar 2003 - 16:52 JohannesMartin  
elsediff TWiki.pm.diff manage 1.3 K 05 Mar 2003 - 16:52 JohannesMartin  
Topic revision: r4 - 02 Apr 2003 - 07:37:16 - PeterThoeny
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback