/usr/share/perl5/Perlanet/Trait/Tidy.pm is in libperlanet-perl 0.56-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | package Perlanet::Trait::Tidy;
use strict;
use warnings;
use Moose::Role;
use namespace::autoclean;
use Encode;
use HTML::Tidy;
=head1 NAME
Perlanet::Trait::Tidy - run posts through HTML::Tidy
=head1 SYNOPSIS
my $perlanet = Perlanet->new_with_traits(
traits => [ 'Perlanet::Trait::Tidy' ]
);
$perlanet->run;
=head1 DESCRIPTION
Before a post is added to the aggregated feed, it will be ran through
HTML::Tidy.
=head2 Configuring
To configure the HTML::Tidy instance, you should override the C<_build_tidy>
method. This method takes no input, and returns a HTML::Tidy instance.
=head1 ATTRIBUTES
=head2 tidy
An instance of L<HTML::Tidy> used to tidy the feed entry contents
before outputting. For default settings see source..
=cut
has 'tidy' => (
is => 'rw',
lazy_build => 1
);
sub _build_tidy {
my $self = shift;
my %tidy = (
doctype => 'omit',
output_xhtml => 1,
wrap => 0,
alt_text => '',
break_before_br => 0,
char_encoding => 'raw',
tidy_mark => 0,
show_body_only => 1,
preserve_entities => 1,
show_warnings => 0,
);
my $tidy = HTML::Tidy->new(\%tidy);
$tidy->ignore( type => TIDY_WARNING );
return $tidy;
}
around 'clean_html' => sub {
my $orig = shift;
my ($self, $html) = @_;
$html = $self->$orig($html);
my $clean = $self->tidy->clean(utf8::is_utf8($html)
? $html
: decode('utf8', $html));
return $clean;
};
=head1 AUTHOR
Oliver Charles, <oliver.g.charles@googlemail.com>
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2010 by Magnum Solutions Ltd.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.10.0 or,
at your option, any later version of Perl 5 you may have available.
=cut
1;
|