Text::Context(3pm)
โจ Text::Context โจ
okay bestie, so this is a page from the User Contributed Perl Documentation section โ yes it's a 3pm manual, we're in module territory ๐
โ and it's literally all about highlighting search result context snippets. Let's get into it ๐ซถ
๐ธ NAME ๐ธ
Text::Context โ handle highlighting search result context snippets ๐
Like, you give it a big ol' blob of text and some search terms, and it goes "say less" and pulls out the good part.
๐ 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;
not the # In case you change your mind comment ๐ญ she's so real for that.
๐ฆ DESCRIPTION ๐ฆ
So here's the vibe: given a piece of text and some search terms, this produces an object. That object:
- 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 ๐
periodt.
๐ new
Creates a new snippet object for holding and formatting context for search terms. main character energy fr fr.
๐ keywords
Accessor method to get/set keywords. And listen โ because the context search is done case-insensitively, the keywords will be lower-cased. no cap. that's just what happens.
๐ paras
@paras = $self->paras($maxlen)
Return shortened paragraphs to fit together into a snippet of at most $maxlen characters. math is mathing, bestie ๐งฎโจ
๐ as_text
Calculates a "representative" string which contains the given search terms. And if there's lots and lots of context between the terms? it's replaced with an ellipsis. ... we love a dramatic pause ๐ซถ
๐ 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, which is "<span class="quoted">". cute! ๐
๐ AUTHOR ๐
- Original author: Simon Cozens
- Current maintainer: Tony Bowden
slay to both of them honestly ๐
๐ BUGS and QUERIES ๐
Please direct all correspondence regarding this module to:
bug-Text-Context@rt.cpan.org
bestie if something's broken, email that address. don't just suffer in silence ๐ญ
๐ 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.
so basically: GPL, version 2 or later, redistribute and/or modify as you please ๐ โ but it comes with NO WARRANTY, like, none at all, not even the implied ones for merchantability or fitness for a particular purpose. it's giving "use at your own risk" and honestly? iconic.
and that's the whole page, bestie!! this one's a perl v5.36.0 situation, dated 2022-12-13 โ so when you cite it in your group chat, you know exactly what you're working with ๐
โจ bye ily ๐ซถ
๐ฆ where this page comes from
- debian bookworm: libtext-context-perl 3.7-3 ยท GPL-2.0-or-later
- debian trixie: libtext-context-perl 3.7-3 ยท GPL-2.0-or-later
- ubuntu noble: libtext-context-perl 3.7-3 ยท GPL-2.0-or-later
- ubuntu resolute: libtext-context-perl 3.7-3 ยท GPL-2.0-or-later
- ubuntu stonking: libtext-context-perl 3.7-3 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms