#!/usr/bin/perl use strict; $|++; use My_HTML_Filter; ## from http://www.perlmonks.org/index.pl?node_id=29281 my %PERMITTED = map { my($k, @v) = split; ($k, {map {$_, 1} @v}) } split /\n/, <<'END'; a href name target class title b big blockquote class br center dd div class dl dt em font size color class h1 h2 h3 h4 h5 h6 hr i li ol type start p align class pre class small span class title strike strong sub sup table width cellpadding cellspacing border bgcolor class td width align valign colspan rowspan bgcolor height class th colspan width align bgcolor height class tr width align valign class tt class u ul END use Test::More qw(no_plan); my $f = My_HTML_Filter->new(\%PERMITTED) or die; isa_ok($f, "My_HTML_Filter"); is($f->strip(qq{Hello}), qq{
Hello
\n}, "basic text gets paragraphed"); is($f->strip(qq{Thing What do you say?}),
qq{ What do you say? oneHi!}),
qq{
\n},
"tags get balanced");
is($f->strip(qq{bold italic!}),
qq{bold italic!\n},
"b/i tags get balanced");
is($f->strip(qq{bold italic!}),
qq{bold italic!\n},
"b/i tags get nested properly");
is($f->strip(qq{bold italic!}),
qq{bold italic!\n},
"tags get lowercased");
is($f->strip(qq{Hi! hey
one
two}),
qq{hey
\n
two