-
-
23 Jul 2009 08:11:06 UTC
- Distribution: Text-Context
- Module version: 3.7
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (4)
- Testers (2277 / 2 / 1)
- Kwalitee
Bus factor: 0- 98.18% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (6.87KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- HTML::Entities
- Text::Context::EitherSide
- UNIVERSAL::require
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Text::Context - Handle highlighting search result context snippets
SYNOPSIS
use Text::Context; my $snippet = Text::Context->new($text, @keywords); $snippet->keywords("foo", "bar"); # In case you change your mind print $snippet->as_html; print $snippet->as_text;
DESCRIPTION
Given a piece of text and some search terms, produces an object which locates the search terms in the message, extracts a reasonable-length string containing all the search terms, and optionally dumps the string out as HTML text with the search terms highlighted in bold.
new
Creates a new snippet object for holding and formatting context for search terms.
keywords
Accessor method to get/set keywords. As the context search is done case-insensitively, the keywords will be lower-cased.
paras
@paras = $self->paras($maxlen)
Return shortened paragraphs to fit together into a snippet of at most
$maxlen
characters.as_text
Calculates a "representative" string which contains the given search terms. If there's lots and lots of context between the terms, it's replaced with an ellipsis.
as_html([ start => "<some tag>", end => "<some end tag>" ])
Markup the snippet as a HTML string using the specified delimiters or with a default set of delimiters (
<span class="quoted">
).AUTHOR
Original author: Simon Cozens
Current maintainer: Tony Bowden
BUGS and QUERIES
Please direct all correspondence regarding this module to: bug-Text-Context@rt.cpan.org
COPYRIGHT AND LICENSE
Copyright (C) 2002-2005 Kasei This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Module Install Instructions
To install Text::Context, copy and paste the appropriate command in to your terminal.
cpanm Text::Context
perl -MCPAN -e shell install Text::Context
For more information on module installation, please visit the detailed CPAN module installation guide.