[KinoSearch] Re: Subclassable Highlighter
Marvin Humphrey
marvin at rectangular.com
Fri Feb 29 14:14:46 PST 2008
On Feb 29, 2008, at 12:36 PM, Father Chrysostomos wrote:
> Actually, my main point was that the highlighter should accept a
> code ref
Ah.
> Basically,
>
> my $highlighter = new KinoSearch::Highlight::Highlighter ...;
> $highlighter->set_encoder(sub { ... })
>
> is a lot shorter (and less convoluted) than
>
> { package MyHighlighter;
> @ISA = KinoSearch::Highlight::Highlighter;
> sub encode { ... } }
>
> my $highlighter = new MyHighlighter ...;
I think that would make a nice addition to a
KSx::Highlight::Summarizer. :) I don't really think it should be in
the core Highlighter class, though, for a couple reasons.
First, not that many people are going to want to override encode().
Most people will be serving highlighted search results via the web,
and the default encode_entities() functionality will be appropriate.
You made a good point about making it easy to change up the highlight
tags; I don't believe adding a handle to set the encoding mechanism
beyond overriding encode() has the same urgency.
Second, I'm trying to keep the KS architecture limited to a least-
common-denominator single-inheritance OO model; closures don't really
fit into that. I think it's good that KSx authors might not choose to
adhere to the same rigid restrictions, though. :)
Marvin Humphrey
Rectangular Research
http://www.rectangular.com/
More information about the kinosearch
mailing list