Template-Plugin-HtmlToText-0.03 000777 000000 000000 0 11052447516 17055 5 ustar 00unknown unknown 000000 000000 Build.PL 000444 000000 000000 1046 10507105323 20413 0 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03 use strict;
use warnings;
use Module::Build;
my $builder = Module::Build->new(
module_name => 'Template::Plugin::HtmlToText',
license => 'perl',
dist_author => 'Fayland Lam ',
dist_version_from => 'lib/Template/Plugin/HtmlToText.pm',
create_makefile_pl => 'traditional',
build_requires => {
'Test::More' => 0,
'Template' => 0,
'HTML::TreeBuilder' => 0,
'HTML::FormatText' => 0,
},
);
$builder->create_build_script();
1; Changes 000444 000000 000000 254 10507105323 20372 0 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03 Revision history for Template-Plugin-HtmlToText
0.01 2006/8/31
better doc
0.01 Date/time
First version, released on an unsuspecting world.
Makefile.PL 000444 000000 000000 1137 11052447516 21103 0 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03 # Note: this file was auto-generated by Module::Build::Compat version 0.2808_01
use ExtUtils::MakeMaker;
WriteMakefile
(
'NAME' => 'Template::Plugin::HtmlToText',
'VERSION_FROM' => 'lib/Template/Plugin/HtmlToText.pm',
'PREREQ_PM' => {
'HTML::FormatText' => 0,
'HTML::TreeBuilder' => 0,
'Template' => 0,
'Test::More' => 0
},
'INSTALLDIRS' => 'site',
'EXE_FILES' => [],
'PL_FILES' => {}
)
;
MANIFEST 000444 000000 000000 217 10507105323 20227 0 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03 Build.PL
Changes
lib/Template/Plugin/HtmlToText.pm
Makefile.PL
MANIFEST
META.yml # Will be created by "make dist"
README
t/00-load.t
META.yml 000444 000000 000000 1061 11052447516 20376 0 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03 ---
name: Template-Plugin-HtmlToText
version: 0.03
author:
- 'Fayland Lam '
abstract: Plugin interface to HTML::FormatText
license: perl
resources:
license: http://dev.perl.org/licenses/
build_requires:
HTML::FormatText: 0
HTML::TreeBuilder: 0
Template: 0
Test::More: 0
provides:
Template::Plugin::HtmlToText:
file: lib/Template/Plugin/HtmlToText.pm
version: 0.03
generated_by: Module::Build version 0.280801
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.2.html
version: 1.2
README 000444 000000 000000 2776 10507105323 20012 0 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03 Template-Plugin-HtmlToText
The README is used to introduce the module and provide instructions on
how to install the module, any machine dependencies it may have (for
example C compilers and installed libraries) and any other information
that should be provided before the module is installed.
A README file is required for CPAN modules since CPAN extracts the README
file from a module distribution so that people browsing the archive
can use it get an idea of the modules uses. It is usually a good idea
to provide version information here so that people can decide whether
fixes for the module are worth downloading.
INSTALLATION
To install this module, run the following commands:
perl Makefile.PL
make
make test
make install
SUPPORT AND DOCUMENTATION
After installing, you can find documentation for this module with the perldoc command.
perldoc Template::Plugin::HtmlToText
You can also look for information at:
Search CPAN
http://search.cpan.org/dist/Template-Plugin-HtmlToText
CPAN Request Tracker:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Template-Plugin-HtmlToText
AnnoCPAN, annotated CPAN documentation:
http://annocpan.org/dist/Template-Plugin-HtmlToText
CPAN Ratings:
http://cpanratings.perl.org/d/Template-Plugin-HtmlToText
COPYRIGHT AND LICENCE
Copyright (C) 2006 Fayland Lam
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
lib 000777 000000 000000 0 11052447516 17544 5 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03 Template 000777 000000 000000 0 11052447516 21317 5 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03/lib Plugin 000777 000000 000000 0 11052447516 22555 5 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03/lib/Template HtmlToText.pm 000444 000000 000000 3162 11052447376 25326 0 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03/lib/Template/Plugin package Template::Plugin::HtmlToText;
use strict;
use vars qw( @ISA $VERSION );
use base qw( Template::Plugin );
use Template::Plugin;
$VERSION = '0.03';
sub new {
my ($class, $context, $arg) = @_;
$context->define_filter('html2text', [ \&html2text => 1 ]);
return \&tt_wrap;
}
sub html2text {
my ($context, $args) = @_;
return sub {
my $html = shift;
return $html unless ($html =~ m#(<|>)#s);
require HTML::TreeBuilder;
my $tree = HTML::TreeBuilder->new->parse($html);
require HTML::FormatText;
my $formatter = HTML::FormatText->new(%{$args});
my $text = $formatter->format($tree);
return $text;
}
}
1;
__END__
=head1 NAME
Template::Plugin::HtmlToText - Plugin interface to HTML::FormatText
=head1 SYNOPSIS
Quick summary of what the module does.
Perhaps a little code snippet.
[% USE HtmlToText %]
# use html2text FILTER to var 'myhtml' or 'myhtmltext'
[% myhtml FILTER html2text(leftmargin => 0, rightmargin => 50) %]
[% myhtmltext | html2text %]
# not to a var, but to html code
[% FILTER html2text %]
heavy
[% END %]
[%# output is "heavy", no %]
=head1 DESCRIPTION
This plugin provides an interface to the HTML::FormatText module which
format HTML as plaintext.
=head1 AUTHOR
Fayland Lam, C<< >>
=head1 COPYRIGHT & LICENSE
Copyright 2006 Fayland Lam, all rights reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
t 000777 000000 000000 0 11052447516 17241 5 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03 00-load.t 000444 000000 000000 145 10507105322 20661 0 ustar 00unknown unknown 000000 000000 Template-Plugin-HtmlToText-0.03/t #!perl -T
use Test::More tests => 1;
BEGIN {
use_ok( 'Template::Plugin::HtmlToText' );
}