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 History Action Size Date Who Comment
Unknown file formatdiff Search.pm.diff r1 manage 2.9 K 2003-03-05 - 16:52 JohannesMartin  
Unknown file formatdiff TWiki.pm.diff r1 manage 1.3 K 2003-03-05 - 16:52 JohannesMartin  
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2003-04-02 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.