File Coverage

blib/lib/Text/Markup/Mediawiki.pm
Criterion Covered Total %
statement 27 27 100.0
branch 4 6 66.6
condition 1 3 33.3
subroutine 8 8 100.0
pod 0 1 0.0
total 40 45 88.8


line stmt bran cond sub pod time code
1             package Text::Markup::Mediawiki;
2              
3 1     1   59348 use 5.8.1;
  1         5  
4 1     1   6 use strict;
  1         3  
  1         25  
5 1     1   6 use warnings;
  1         2  
  1         56  
6 1     1   7 use Text::Markup;
  1         2  
  1         44  
7 1     1   6 use File::BOM qw(open_bom);
  1         2  
  1         90  
8 1     1   6 use Text::MediawikiFormat 1.0;
  1         18  
  1         7  
9              
10             our $VERSION = '0.41';
11              
12             sub import {
13             # Replace the regex if passed one.
14 3 100   3   28 Text::Markup->register( mediawiki => $_[1] ) if $_[1];
15             }
16              
17             sub parser {
18 2     2 0 3 my ($file, $encoding, $opts) = @_;
19 2         15 open_bom my $fh, $file, ":encoding($encoding)";
20 2         479 local $/;
21 2         38 my $html = Text::MediawikiFormat::format(<$fh>, @{ $opts });
  2         29  
22 2 100       3862 return unless $html =~ /\S/;
23 1         3 utf8::encode($html);
24 1 0 33     2 return $html if $opts->[1] && $opts->[1]->{raw};
25 1         24 return qq{
26            
27            
28            
29            
30             $html
31            
32            
33             };
34              
35             }
36              
37             1;
38             __END__