You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Adam Prime x443 <ap...@brunico.com> on 2006/11/12 06:08:48 UTC

[RFC] Apache2::Filter::TagAware

At ApacheCon this year Geoff gave a talk about Output filters (slides: http://www.modperlcookbook.org/~geoff/slides/ApacheCon/2006/mp2_filters-printable.pdf.gz) which included a sample handler that ran the manual through HTML::Clean.  a big part of the code in the filter was to handle the possibility of having split tags and that subsequently making HTML::Clean not play nice.  

Philippe gave a talk about Profiling and Instrumenting (slides: http://ectoplasm.org/Talks/mod_perl-2.0-profiling-9394.pdf) in which a comment came up about using Filters to insert page generation metrics into the body of the page the metrics were about.  This kind of filter too would have to handle the split tags problem.

So it occurred to me that this might well be handled by subclassing Apache2::Filter and making the subclass handle it.  So after a bunch of screwing around I finally got a pretty much working version.

An example is running here:

http://filtertest.kabob.ca/

It's running the manual through a filter that injects '!!' at the end of each read call, basically just illustrating that it's actually working.

code here: 

http://kabob.ca/perl/Apache2-Filter-TagAware/lib/Apache2/Filter/TagAware.pm

notes:

What constitutes a 'tag' is user defined.  it just takes a regexp that defines an incomplete tag, the default being '(<[^>]*)$'.

It only works with the stream filter API right now.  I haven't read any of the bucket brigade documentation, but I assume that this idea could also be applied to that API as well.

I'm not sure if i'm doing anything really weird or really wrong here, so any and all comments are welcome.

Adam