" element
is output as the empty string. (The default behavious treats it rather
like "".)
{
package Local::SkipDEL;
use Moose::Role;
override DEL => sub { '' };
}
print HTML::HTML5::ToText
-> with_traits(qw/ShowLinks ShowImages +Local::SkipDEL/)
-> process_string($html);
Or maybe we want to force "" elements into uppercase?
{
package Local::Embiggen;
use Moose::Role;
around BIG => sub
{
my ($orig, $self, $elem) = @_;
return uc $self->$orig($elem);
};
}
print HTML::HTML5::ToText
-> with_traits(qw/+Local::Embiggen/)
-> process_string($html);
Share your examples of extending HTML::HTML5::ToText at
.
BUGS
Please report any bugs to
.
SEE ALSO
HTML::HTML5::Parser, HTML::HTML5::Table.
HTML::HTML5::ToText::Trait::RenderTables,
HTML::HTML5::ToText::Trait::ShowImages,
HTML::HTML5::ToText::Trait::ShowLinks,
HTML::HTML5::ToText::Trait::TextFormatting.
Similar Modules on CPAN
* HTML::FormatText
About 15 years old, and still maintained, this falls into the
"mature" category. This module is based on HTML::Tree, so its HTML
parser may not behave as closely to modern browsers as
HTML::HTML5::Parser's parsing, but its conversion to text seems
somewhat better than HTML::HTML5::ToText's default output (i.e. with
no traits applied).
At the time of writing, its bug queue on rt.cpan.org lists eight
bugs, some quite serious. However, since being taken over by its
latest maintainer, there seems to be progress being made on them.
Fairly extensible, but not in the mix-and-match traits way allowed
by HTML::HTML5::ToText.
* HTML::FormatText::WithLinks
An extension of HTML::FormatText.
* HTML::FormatText::WithLinks::AndTables
An extension of HTML::FormatText::WithLinks.
The code that deals with tables is pretty crude compared with
HTML::HTML5::ToText::Trait::RenderTables. It doesn't support
"colspan", "rowspan", or the "" element.
* LEOCHARRE::HTML::Text
Very basic conversion; basically just tag stripping using regular
expressions.
* HTML::FormatExternal
Passes HTML through external command-line tools such as `lynx`.
Obviously this has limited portability.
AUTHOR
Toby Inkster .
THANKS
Everyone behind Moose. No way I could have done all this in a few hours
without Moose's strange brand of meta-programming!
COPYRIGHT AND LICENCE
This software is copyright (c) 2012-2013 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|