File Coverage

blib/lib/HTML/Obliterate.pm
Criterion Covered Total %
statement 25 37 67.5
branch 8 8 100.0
condition n/a
subroutine 6 18 33.3
pod 14 15 93.3
total 53 78 67.9


line stmt bran cond sub pod time code
1             package HTML::Obliterate;
2              
3 1     1   21260 use strict;
  1         2  
  1         31  
4 1     1   33 use warnings;
  1         2  
  1         41  
5             our $VERSION = '0.3';
6              
7 1     1   6 use base 'Exporter';
  1         5  
  1         590  
8             our @EXPORT_OK = qw(
9             remove_html remove_html_from_string
10             obliterate_html kill_html
11             erase_html extinguish_html
12             extirpate_html abolish_html
13             doff_html eliminate_html
14             drop_html purge_html
15             strip_html destroy_html
16             defenestrate_html
17             );
18              
19             sub remove_html {
20 4     4 1 11311 my ($item) = @_;
21            
22 4 100       17 if(ref $item eq 'ARRAY') {
23 2         4 my @copy;
24            
25 2         5 for my $i (0 .. (@{ $item } -1)) {
  2         10  
26 6 100       21 $item->[$i] = remove_html_from_string($item->[$i]) if !defined wantarray;
27 6 100       20 $copy[$i] = remove_html_from_string($item->[$i]) if defined wantarray;
28             }
29            
30 2 100       9 return $item if !defined wantarray; # seems kind of pointless but its not, hmm a riddle :)
31 1         3 return \@copy;
32             }
33            
34 2         6 return remove_html_from_string($item);
35             }
36              
37             sub remove_html_from_string {
38 37     37 1 6339 my($string) = @_;
39 37         73 $string =~ s{ < \s* [!] \s* [-] \s* [-] \s* .*? [-] \s* [-] \s* > }{}oxms; # comment's w/ posible HTML
40 37         288 $string =~ s{ < \W* [^>]* > (?: [^<]* >)* }{}oxmsg;
41 37         75 $string =~ s{ [&][#]? \w+ [;]? }{}oxmsg;
42 37         103 return $string;
43             }
44              
45 0     0 1 0 sub obliterate_html { goto &HTML::Obliterate::remove_html }
46 0     0 1 0 sub kill_html { goto &HTML::Obliterate::remove_html }
47 0     0 1 0 sub erase_html { goto &HTML::Obliterate::remove_html }
48 0     0 1 0 sub extinguish_html { goto &HTML::Obliterate::remove_html }
49 1     1 1 1725 sub extirpate_html { goto &HTML::Obliterate::remove_html }
50 0     0 1   sub abolish_html { goto &HTML::Obliterate::remove_html }
51 0     0 1   sub doff_html { goto &HTML::Obliterate::remove_html }
52 0     0 1   sub eliminate_html { goto &HTML::Obliterate::remove_html }
53 0     0 1   sub drop_html { goto &HTML::Obliterate::remove_html }
54 0     0 1   sub purge_html { goto &HTML::Obliterate::remove_html }
55 0     0 1   sub strip_html { goto &HTML::Obliterate::remove_html }
56 0     0 0   sub destroy_html { goto &HTML::Obliterate::remove_html }
57 0     0 1   sub defenestrate_html { goto &HTML::Obliterate::remove_html }
58              
59             1;
60              
61             __END__