File Coverage

blib/lib/PAD/Plugin/Markdown.pm
Criterion Covered Total %
statement 21 22 95.4
branch 1 2 50.0
condition n/a
subroutine 6 7 85.7
pod 3 3 100.0
total 31 34 91.1


line stmt bran cond sub pod time code
1             package PAD::Plugin::Markdown;
2 2     2   19769 use strict;
  2         4  
  2         59  
3 2     2   9 use warnings;
  2         4  
  2         48  
4 2     2   675 use parent 'PAD::Plugin';
  2         261  
  2         10  
5 2     2   2312 use Text::Markdown 'markdown';
  2         91179  
  2         428  
6              
7 0     0 1 0 sub suffix { qr/\.(?:markdown|mk?dn?)$/ }
8 1     1 1 8 sub content_type { 'text/html; charset=UTF-8' }
9              
10             sub execute {
11 1     1 1 2 my $self = shift;
12 1         4 my $path = $self->relative_path;
13              
14 1 50       57 open my $text, '<', $path or die $!;
15 1         2 my $md = markdown(do { local $/; <$text> });
  1         4  
  1         40  
16              
17 1         3912 my $res = $self->request->new_response(200, ['Content-Type' => $self->content_type], $md);
18 1         91 $res->finalize;
19             }
20              
21             1;
22             __END__