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

Revision 1690 (checked in by otsune, 14 years ago)

Add Filter::UnicodeNormalize?

Line 
1 package Plagger::Plugin::Filter::UnicodeNormalize;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 use Unicode::Normalize 'normalize';
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
18     my $entry = $args->{entry};
19     my $form = $self->conf->{form} || 'KC';
20     my $normalized_body = normalize($form, $entry->body);
21     $entry->body($normalized_body);
22 }
23
24 1;
25 __END__
26
27 =head1 NAME
28
29 Plagger::Plugin::Filter::UnicodeNormalize - Unicode Normalization
30
31 =head1 SYNOPSIS
32
33   - module: Filter::UnicodeNormalize
34     config:
35       form: NFKC
36
37 =head1 DESCRIPTION
38
39 This plugin normalize feed content using L<Unicode::Normalize>.
40
41 =head1 CONFIG
42
43 =over 4
44
45 =item form
46
47 The method of normalize form can be specified by I<form> set.
48 select forms from NFD, NFC, NFKD, NFKC, etc. Optional and defaults to NFKC.
49 see L<Unicode::Normalize>.
50
51 =back
52
53 =head1 AUTHOR
54
55 Masafumi Otsune
56
57 =head1 SEE ALSO
58
59 L<Plagger> L<Unicode::Normalize>
60
61 =cut
Note: See TracBrowser for help on using the browser.