use strict; use warnings; package KinoSearch::Highlight::SimpleHTMLFormatter; use KinoSearch::Util::ToolSet; use base qw( KinoSearch::Highlight::Formatter ); our %instance_vars = ( # constructor params / members pre_tag => '', post_tag => '', ); sub highlight { my ( $self, $text ) = @_; return "$self->{pre_tag}$text$self->{post_tag}"; } 1; __END__ =head1 NAME KinoSearch::Highlight::SimpleHTMLFormatter - Surround highlight bits with tags. =head1 SYNOPSIS my $formatter = KinoSearch::Highlight::SimpleHTMLFormatter->new( pre_tag => '', post_tag => '', ); # returns "foo" my $highlighted = $formatter->highlight("foo"); =head1 DESCRIPTION This subclass of L highlights text by surrounding it with tags. =head1 METHODS =head2 new Constructor. Takes hash-style params. my $formatter = KinoSearch::Highlight::SimpleHTMLFormatter->new( pre_tag => '*', # default: '' post_tag => '*', # default: '' ); =over =item * B - a string which will be inserted immediately prior to the highlightable text, typically to accentuate it. If you don't want highlighting, set both C and C to C<''>. =item * B - a string which will be inserted immediately after the highlightable text. =back =head1 COPYRIGHT Copyright 2006-2007 Marvin Humphrey =head1 LICENSE, DISCLAIMER, BUGS, etc. See L version 0.20. =cut