| 1 |
NAME |
| 2 |
Text::Context - Handle highlighting search result context snippets |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
use Text::Context; |
| 6 |
|
| 7 |
my $snippet = Text::Context->new($text, @keywords); |
| 8 |
|
| 9 |
$snippet->keywords("foo", "bar"); # In case you change your mind |
| 10 |
|
| 11 |
print $snippet->as_html; |
| 12 |
print $snippet->as_text; |
| 13 |
|
| 14 |
DESCRIPTION |
| 15 |
Given a piece of text and some search terms, produces an object which |
| 16 |
locates the search terms in the message, extracts a reasonable-length |
| 17 |
string containing all the search terms, and optionally dumps the string |
| 18 |
out as HTML text with the search terms highlighted in bold. |
| 19 |
|
| 20 |
new |
| 21 |
Creates a new snippet object for holding and formatting context for |
| 22 |
search terms. |
| 23 |
|
| 24 |
keywords |
| 25 |
Accessor method to get/set keywords. As the context search is done |
| 26 |
case-insensitively, the keywords will be lower-cased. |
| 27 |
|
| 28 |
paras |
| 29 |
@paras = $self->paras($maxlen) |
| 30 |
|
| 31 |
Return shortened paragraphs to fit together into a snippet of at most |
| 32 |
$maxlen characters. |
| 33 |
|
| 34 |
as_text |
| 35 |
Calculates a "representative" string which contains the given search |
| 36 |
terms. If there's lots and lots of context between the terms, it's |
| 37 |
replaced with an ellipsis. |
| 38 |
|
| 39 |
as_html([ start => "<some tag>", end => "<some end tag>" ]) |
| 40 |
Markup the snippet as a HTML string using the specified delimiters or |
| 41 |
with a default set of delimiters ("<span class="quoted">"). |
| 42 |
|
| 43 |
AUTHOR |
| 44 |
Original author: Simon Cozens |
| 45 |
|
| 46 |
Current maintainer: Tony Bowden |
| 47 |
|
| 48 |
BUGS and QUERIES |
| 49 |
Please direct all correspondence regarding this module to: |
| 50 |
[email protected] |
| 51 |
|
| 52 |
COPYRIGHT AND LICENSE |
| 53 |
Copyright (C) 2002-2005 Kasei |
| 54 |
|
| 55 |
This program is free software; you can redistribute it and/or modify |
| 56 |
it under the terms of the GNU General Public License; either version |
| 57 |
2 of the License, or (at your option) any later version. |
| 58 |
|
| 59 |
This program is distributed in the hope that it will be useful, |
| 60 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 61 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 62 |
|