1use Test::More 'no_plan'; 2use HTML::FormatText::WithLinks; 3 4my $html = simple_example(); 5my $f = HTML::FormatText::WithLinks->new( 6 leftmargin => 0, 7 skip_linked_urls => 1, 8 before_link => '', 9 after_link => ' (%l)', 10 footnote => '' 11); 12 13ok($f, 'object created'); 14 15my $text = $f->parse($html); 16 17my $correct_text = qq!This is a mail of some sort with a bunch of linked URLs. 18 19http://example.com/ 20 21and another https://example.com/ 22 23ftp now ftp://example.com 24 25not the same but not this (http://example.com/) 26 27or this http://example.com (http://example.com/foo) 28 29!; 30 31ok($text, 'html formatted'); 32is($text, $correct_text, 'html correctly formatted'); 33 34 35sub simple_example { 36return <<'HTML'; 37<html> 38<body> 39<p>This is a mail of some sort with a bunch of linked URLs.</p> 40<p><a href="http://example.com/">http://example.com/</a></p> 41<p>and another <a href="https://example.com/">https://example.com/</a></p> 42<p>ftp now <a href="ftp://example.com">ftp://example.com</a></p> 43<p>not the same <a href="http://example.com/">but not this</a></p> 44<p>or this <a href="http://example.com/foo">http://example.com</a></p> 45</body> 46</html> 47HTML 48} 49 50