File Coverage

blib/lib/Text/Markup/Pod.pm
Criterion Covered Total %
statement 31 31 100.0
branch 5 6 83.3
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 44 46 95.6


line stmt bran cond sub pod time code
1             package Text::Markup::Pod;
2              
3 2     2   58815 use 5.8.1;
  2         7  
4 2     2   11 use strict;
  2         3  
  2         85  
5 2     2   10 use warnings;
  2         38  
  2         121  
6 2     2   9 use Text::Markup;
  2         2  
  2         88  
7 2     2   829 use Pod::Simple::XHTML 3.15;
  2         63200  
  2         849  
8              
9             sub import {
10             # Replace the regex if passed one.
11 3 100   3   40 Text::Markup->register( pod => $_[1] ) if $_[1];
12             }
13              
14             # Disable the use of HTML::Entities.
15             $Pod::Simple::XHTML::HAS_HTML_ENTITIES = 0;
16              
17             our $VERSION = '0.41';
18              
19             sub parser {
20 4     4 0 16 my ($file, $encoding, $opts) = @_;
21 4         37 my $p = Pod::Simple::XHTML->new;
22             # Output everything as UTF-8.
23 4         697 $p->html_header_tags('');
24 4     3   77 $p->strip_verbatim_indent(sub { (sort map { /^(\s+)/ } @{$_[0]})[0] });
  3         17400  
  15         70  
  3         9  
25 4         36 $p->output_string(\my $html);
26             # Want user supplied options to override even these default behaviors,
27             # if necessary
28 4 50       291 my $opt = $opts ? { @$opts } : {};
29 4         15 foreach my $method ( keys %$opt ) {
30 3         11 my $v = $opt->{$method};
31 3         8 $p->$method($v);
32             }
33 4         40 $p->parse_file($file);
34 4 100       2288 return unless $p->content_seen;
35 3         33 utf8::encode($html);
36 3         140 return $html;
37             }
38              
39             1;
40             __END__