File Coverage

blib/lib/Text/Markup/None.pm
Criterion Covered Total %
statement 27 27 100.0
branch 5 6 83.3
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 40 42 95.2


line stmt bran cond sub pod time code
1             package Text::Markup::None;
2              
3 2     2   20 use 5.8.1;
  2         5  
4 2     2   8 use strict;
  2         14  
  2         42  
5 2     2   6 use warnings;
  2         4  
  2         57  
6 2     2   33 use Text::Markup;
  2         3  
  2         41  
7 2     2   444 use HTML::Entities;
  2         8527  
  2         214  
8 2     2   1133 use File::BOM qw(open_bom);
  2         53676  
  2         666  
9              
10             our $VERSION = '0.41';
11              
12             sub import {
13             # Set a regex if passed one.
14 5 100   5   5538 Text::Markup->register( none => $_[1] ) if $_[1];
15             }
16              
17             sub parser {
18 3     3 0 11 my ($file, $encoding, $opts) = @_;
19 3         21 open_bom my $fh, $file, ":encoding($encoding)";
20 3         3443 local $/;
21 3         102 my $html = encode_entities(<$fh>, '<>&"');
22 3 100       821 return undef unless $html =~ /\S/;
23 2         10 utf8::encode($html);
24 2 50       4 return $html if { @{ $opts } }->{raw};
  2         12  
25 2         68 return qq{
26            
27            
28            
29            
30            
$html
31            
32            
33             };
34             }
35              
36             1;
37             __END__