1Text::Context(3)      User Contributed Perl Documentation     Text::Context(3)
2
3
4

NAME

6       Text::Context - Handle highlighting search result context snippets
7

SYNOPSIS

9         use Text::Context;
10
11         my $snippet = Text::Context->new($text, @keywords);
12
13         $snippet->keywords("foo", "bar"); # In case you change your mind
14
15         print $snippet->as_html;
16         print $snippet->as_text;
17

DESCRIPTION

19       Given a piece of text and some search terms, produces an object which
20       locates the search terms in the message, extracts a reasonable-length
21       string containing all the search terms, and optionally dumps the string
22       out as HTML text with the search terms highlighted in bold.
23
24   new
25       Creates a new snippet object for holding and formatting context for
26       search terms.
27
28   keywords
29       Accessor method to get/set keywords. As the context search is done
30       case-insensitively, the keywords will be lower-cased.
31
32   paras
33           @paras = $self->paras($maxlen)
34
35       Return shortened paragraphs to fit together into a snippet of at most
36       $maxlen characters.
37
38   as_text
39       Calculates a "representative" string which contains the given search
40       terms. If there's lots and lots of context between the terms, it's
41       replaced with an ellipsis.
42
43   as_html([ start => "<some tag>", end => "<some end tag>" ])
44       Markup the snippet as a HTML string using the specified delimiters or
45       with a default set of delimiters ("<span class="quoted">").
46

AUTHOR

48       Original author: Simon Cozens
49
50       Current maintainer: Tony Bowden
51

BUGS and QUERIES

53       Please direct all correspondence regarding this module to:
54         bug-Text-Context@rt.cpan.org
55
57         Copyright (C) 2002-2005 Kasei
58
59         This program is free software; you can redistribute it and/or modify
60         it under the terms of the GNU General Public License; either version
61         2 of the License, or (at your option) any later version.
62
63         This program is distributed in the hope that it will be useful,
64         but WITHOUT ANY WARRANTY; without even the implied warranty of
65         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
66
67
68
69perl v5.30.0                      2019-07-26                  Text::Context(3)
Impressum