Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: kinosearch: discuss

Re: Subclassable Highlighter

 

 

kinosearch discuss RSS feed   Index | Next | Previous | View Threaded


marvin at rectangular

Feb 26, 2008, 9:36 PM

Post #1 of 4 (1172 views)
Permalink
Re: Subclassable Highlighter

Father Chrysostomos wrote in reply:

> > How about this instead?
> >
> > * Eliminate Encoder, Formatter, SimpleHTMLEncoder, and
> > SimpleHTMLFormatter.
> > * Add public encode() and highlight() methods to Highlighter.
> >
> > sub encode { return encode_entities( $_[1] ) }
> > sub highlight { return '<strong>' . $_[1] . '</strong>' }
>
> Actually, I think that’s worse than the current system. If I wanted
> simply to override the default HTML tags, I’d be much more comfortable
> with create an object than a class.

OK, I can understand that. How about if we change highlight() to use
variables which are settable via accessors?

__PACKAGE__->ready_get_set(qw( pre_tag post_tag ));

sub highlight { "$pre_tag{$$self}$_[1]$post_tag{$$self}" }

I'd really like to kill off those four classes. And putting the
highlighting functionality into a method named "highlight" makes more
sense than farming it out to a class called "Formatter" (so named
because it can't be "Highlighter").

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/


_______________________________________________
KinoSearch mailing list
KinoSearch [at] rectangular
http://www.rectangular.com/mailman/listinfo/kinosearch


sprout at cpan

Feb 29, 2008, 1:17 PM

Post #2 of 4 (1097 views)
Permalink
Re: Subclassable Highlighter [In reply to]

On Feb 29, 2008, at 12:08 PM, Marvin Humphrey wrote:

>>> __PACKAGE__->ready_get_set(qw( pre_tag post_tag ));
>>>
>>> sub highlight { "$pre_tag{$$self}$_[1]$post_tag{$$self}" }
>>
>> This sounds fine. I¢m working on a patch.
>
> :)

And here it is:
Attachments: goodbye-formatter.diff (5.84 KB)


marvin at rectangular

Feb 29, 2008, 2:11 PM

Post #3 of 4 (1091 views)
Permalink
Re: Subclassable Highlighter [In reply to]

On Feb 29, 2008, at 1:17 PM, Father Chrysostomos wrote:

> <goodbye-formatter.diff>

Looks great. Applied as r3088.

Thanks!

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/


_______________________________________________
KinoSearch mailing list
KinoSearch [at] rectangular
http://www.rectangular.com/mailman/listinfo/kinosearch


marvin at rectangular

Feb 29, 2008, 2:17 PM

Post #4 of 4 (1097 views)
Permalink
Re: Subclassable Highlighter [In reply to]

On Feb 29, 2008, at 1:17 PM, Father Chrysostomos wrote:

> And here it is:

PS: While we're messing with the public API and before you release
another version of KSx::Highlight::Summarizer, I'm going to cram in
one additional change: the constructor will take the labeled param
"searchable" instead of "searcher". This is to reflect the fact that
what is required is a subclass of KinoSearch::Search::Searchable,
rather than a KinoSearch::Searcher specifically; and to bring it into
line with other constructors that use the 'searchable' label (Weight,
MultiSearcher).

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/


_______________________________________________
KinoSearch mailing list
KinoSearch [at] rectangular
http://www.rectangular.com/mailman/listinfo/kinosearch

kinosearch discuss RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.