[Catalyst] HTML to plain text conversion

Carl Franks fireartist at gmail.com
Mon Jan 8 17:30:49 GMT 2007


On 08/01/07, Xavier Robin <robin0 at etu.unige.ch> wrote:
> Hello,
>
> Do you know a (catalyst plugin|perl module|external tool) that converts HTML
> to plain text? I mean, keeping some formatting (especially lists and
> links...), not just stripping HTML tags...
>
> I tried Template::Plugin::HtmlToText that fits well into TT, but the links are
> lost. Lists are well rendered, though.

Something like this should work:

    my $scrubber = HTML::Scrubber->new( allow => [qw/ a ul ol li /] );
    my $text = $scrubber->scrub( $html );

Carl



More information about the Catalyst mailing list