File Coverage

blib/lib/Text/Markup/Textile.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::Textile;
2              
3 1     1   63200 use 5.8.1;
  1         3  
4 1     1   3 use strict;
  1         1  
  1         19  
5 1     1   3 use warnings;
  1         1  
  1         42  
6 1     1   3 use Text::Markup;
  1         2  
  1         18  
7 1     1   3 use File::BOM qw(open_bom);
  1         1  
  1         44  
8 1     1   4 use Text::Textile 2.10;
  1         12  
  1         218  
9              
10             our $VERSION = '0.41';
11              
12             sub import {
13             # Replace the regex if passed one.
14 3 100   3   63 Text::Markup->register( textile => $_[1] ) if $_[1];
15             }
16              
17             sub parser {
18 2     2 0 5 my ($file, $encoding, $opts) = @_;
19 2         5 my %params = @{ $opts };
  2         6  
20 2         16 my $textile = Text::Textile->new(
21             charset => 'utf-8',
22             char_encoding => 0,
23             trim_spaces => 1,
24             %params,
25             );
26 2         443 open_bom my $fh, $file, ":encoding($encoding)";
27 2         482 local $/;
28 2         35 my $html = $textile->process(<$fh>);
29 2 100       5492 return unless $html =~ /\S/;
30 1         5 utf8::encode($html);
31 1 50       3 return $html if $params{raw};
32 1         59 return qq{
33            
34            
35            
36            
37             $html
38            
39            
40             };
41              
42             }
43              
44             1;
45             __END__