[ic] Filter tag and html - Patch for Interpolate.pm

Kevin Walsh kevin at cursor.biz
Fri Mar 25 11:33:27 EST 2005


Sandy Thomson [sandy at scotwebshops.com] wrote:
> Daniel Davenport wrote:
> > This isn't a half bad idea, except that it leads to strings that can be
> > quite a bit longer than the x characters implied in a [filter x]... tag.
> > This patch makes [filter x] effectively useless for limiting the length
> > of code that might need its size limited.
> > 
> I agree, just didn't think about what I was typing yesterday. The
> example was for the filter tag with a number and a dot.
> 
Rather than risk breaking existing functionality by rewriting the
length limiting filter, why not just create a new filter to strip
HTML from the string?

With that, you could then create a filter pipeline that looks
something like the following:

    [filter op="strip html2text strip_html decode_entities 20. encode_entities"]
                                ^^^^^^^^^^
    [/filter]

New filters can be placed in the "code/Filter" directory instead of
editing Interpolate.pm.

I imagine that the strip_html filter could be very simple, and would
probably just look something like "s:<[/\w].*?>::g".

That's probably what I'd try if faced with a similar problem.

Either that, or create a new "limit_html" filter that does everything
in one hit - without disturbing existing code.  For example:

    [filter op="limit_html.30.elipsis"]
        Electric sheep say &quot;Fooo <i>Baaaaaaa</i>&quot;
    [/filter]

Which, in theory, could make "Electric sheep say &quot;Fooo Baaaa".
You could code it to adjust, and include, the italic tag span if you
really need that functionality.

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin at cursor.biz
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/



More information about the interchange-users mailing list