root/trunk/plagger/lib/Plagger/Plugin/Filter/StripTagsFromTitle.pm

Revision 1173 (checked in by miyagawa, 14 years ago)

Merge from refactoring-planet. YAY!

Line 
1 package Plagger::Plugin::Filter::StripTagsFromTitle;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use Plagger::Util;
6
7 sub register {
8     my($self, $context) = @_;
9     $context->register_hook(
10         $self,
11         'update.entry.fixup' => \&filter,
12     );
13 }
14
15 sub filter {
16     my($self, $context, $args) = @_;
17     if (defined $args->{entry}->title) {
18         $args->{entry}->title( Plagger::Util::strip_html($args->{entry}->title) );
19     }
20 }
21
22 1;
23
24 __END__
25
26 =head1 NAME
27
28 Plagger::Plugin::Filter::StripTagsFromTitle - Strip tags from entry title
29
30 =head1 SYNOPSIS
31
32   - module: Filter::StripTagsFromTitle
33
34 =head1 DESCRIPTION
35
36 This plugin filters entries to remove HTML tags from its title. Some
37 feeds like blog search engine's result feeds contain HTML tags e.g.:
38
39   <title>&lt;b&gt;Plagger&lt;/b&gt; rocks</title>
40
41 But with RSS spec, there's no way to declare if it's a markup or an
42 escaped text, while Atom 1.0 has by using I<title@type>
43 attribute. This plugin normalizes those titles by simply stripping
44 HTML tags from them.
45
46 =head1 AUTHOR
47
48 Tatsuhiko Miyagawa
49
50 =head1 SEE ALSO
51
52 L<Plagger>, L<http://feedvalidator.org/docs/warning/ContainsHTML.html>
53
54 =cut
Note: See TracBrowser for help on using the browser.