File Coverage

blib/lib/Text/Markup/Trac.pm
Criterion Covered Total %
statement 29 29 100.0
branch 5 6 83.3
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 42 44 95.4


line stmt bran cond sub pod time code
1             package Text::Markup::Trac;
2              
3 1     1   57889 use 5.8.1;
  1         4  
4 1     1   12 use strict;
  1         2  
  1         48  
5 1     1   5 use warnings;
  1         2  
  1         55  
6 1     1   4 use Text::Markup;
  1         17  
  1         25  
7 1     1   4 use File::BOM qw(open_bom);
  1         1  
  1         112  
8 1     1   5 use Text::Trac 0.10;
  1         12  
  1         312  
9              
10             our $VERSION = '0.41';
11              
12             sub import {
13             # Replace the regex if passed one.
14 3 100   3   40 Text::Markup->register( trac => $_[1] ) if $_[1];
15             }
16              
17             sub parser {
18 2     2 0 7 my ($file, $encoding, $opts) = @_;
19 2         4 my %params = @{ $opts };
  2         7  
20 2         18 my $trac = Text::Trac->new(%params);
21 2         1089 open_bom my $fh, $file, ":encoding($encoding)";
22 2         687 local $/;
23 2         49 my $html = $trac->parse(<$fh>);
24 2 100       94519 return unless $html =~ /\S/;
25 1         7 utf8::encode($html);
26 1 50       6 return $html if $params{raw};
27 1         90 return qq{
28            
29            
30            
31            
32             $html
33            
34            
35             };
36              
37             }
38              
39             1;
40             __END__