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
Unknown file formatdiff Search.pm.diff manage 2.9 K 2003-03-05 - 16:52 JohannesMartin  
Unknown file formatdiff TWiki.pm.diff manage 1.3 K 2003-03-05 - 16:52 JohannesMartin  
Topic revision: r4 - 2003-04-02 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by PerlIdeas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.