File Coverage

blib/lib/Pod/Markdown/Github.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 24 25 96.0


line stmt bran cond sub pod time code
1             package Pod::Markdown::Github;
2              
3 1     1   455 use strict;
  1         2  
  1         27  
4 1     1   5 use warnings;
  1         2  
  1         26  
5 1     1   409 use parent 'Pod::Markdown';
  1         348  
  1         6  
6              
7             our $VERSION = '0.04';
8              
9             sub syntax {
10 2     2 0 5 my ( $self, $paragraph ) = @_;
11 2 100       20 return ( $paragraph =~ /(sub|my|use|shift|\$self|\=\>|\$_|\@_)/ )
12             ? 'perl'
13             : '';
14             }
15              
16             sub _indent_verbatim {
17 2     2   5338 my ( $self, $paragraph ) = @_;
18 2         9 $paragraph = $self->SUPER::_indent_verbatim($paragraph);
19              
20             # Remove the leading 4 spaces because we'll escape via ```language
21 2         55 $paragraph = join "\n", map { s/^\s{4}//; $_ } split /\n/, $paragraph;
  5         15  
  5         14  
22              
23             # Enclose the paragraph in ``` and specify the language
24 2         8 return sprintf( "```%s\n%s\n```", $self->syntax($paragraph), $paragraph );
25             }
26              
27             1;
28              
29             __END__