File Coverage

blib/lib/Text/Markup/Bbcode.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::Bbcode;
2              
3 1     1   164001 use 5.8.1;
  1         6  
4 1     1   19 use strict;
  1         5  
  1         45  
5 1     1   6 use warnings;
  1         3  
  1         69  
6 1     1   6 use Text::Markup;
  1         2  
  1         33  
7 1     1   6 use File::BOM qw(open_bom);
  1         2  
  1         125  
8 1     1   9 use Parse::BBCode;
  1         2  
  1         7  
9              
10             our $VERSION = '0.41';
11              
12             sub import {
13             # Replace the regex if passed one.
14 3 100   3   48 Text::Markup->register( bbcode => $_[1] ) if $_[1];
15             }
16              
17             sub parser {
18 2     2 0 9 my ($file, $encoding, $opts) = @_;
19 2         4 my %params = @{ $opts };
  2         6  
20 2         14 my $parse = Parse::BBCode->new(\%params);
21 2         3656 open_bom my $fh, $file, ":encoding($encoding)";
22 2         763 local $/;
23 2         66 my $html = $parse->render(<$fh>);
24 2 100       10855 return unless $html =~ /\S/;
25 1         5 utf8::encode($html);
26 1 50       5 return $html if $params{raw};
27 1         139 return qq{
28            
29            
30            
31            
32             $html
33            
34            
35             };
36              
37             }
38              
39             1;
40             __END__