| Plagger documentation | Contained in the Plagger distribution. |
Plagger::Plugin::Filter::Regexp - Rewrite entry body using regular expression
- module: Filter::Regexp
config:
regexp: s/Plagger/$1, the pluggable Aggregator/g
text_only: 1
This plugin applies regular expression to each entry body by using
eval.
When set to 1, uses HTML::Parser so that the regexp substitution should be applied only to HTML text part. Defaults to 0.
Tatsuhiko Miyagawa
| Plagger documentation | Contained in the Plagger distribution. |
package Plagger::Plugin::Filter::Regexp; use strict; use base qw( Plagger::Plugin::Filter::Base ); use Encode; sub init { my $self = shift; $self->SUPER::init(@_); unless ($self->conf->{regexp}) { Plagger->context->error("regexp is missing"); return; } } sub filter { my($self, $body) = @_; local $_ = $body; my $regexp = decode_utf8($self->conf->{regexp}, Encode::FB_CROAK); my $count = eval $regexp; if ($@) { Plagger->context->log(error => "Error: $@ in " . $self->conf->{regexp}); return (0, $body); } return ($count, $_); } 1; __END__