File Coverage

blib/lib/String/PodQuote.pm
Criterion Covered Total %
statement 16 16 100.0
branch 1 2 50.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 23 24 95.8


line stmt bran cond sub pod time code
1             package String::PodQuote;
2              
3             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
4             our $DATE = '2019-12-16'; # DATE
5             our $DIST = 'String-PodQuote'; # DIST
6             our $VERSION = '0.002'; # VERSION
7              
8 1     1   67631 use 5.010001;
  1         12  
9 1     1   7 use strict 'subs', 'vars';
  1         2  
  1         39  
10 1     1   6 use warnings;
  1         2  
  1         28  
11              
12 1     1   5 use Exporter qw(import);
  1         2  
  1         248  
13             our @EXPORT_OK = qw(pod_escape pod_quote);
14              
15             our %transforms = (
16             "<" => "E",
17             ">" => "E",
18             " " => "E<32>",
19             "\t" => "E<9>",
20             "=" => "E<61>",
21             "/" => "E",
22             "|" => "E",
23             );
24              
25             sub pod_escape {
26 12 50   12 1 123 my $opts = ref $_[0] eq 'HASH' ? shift : {};
27 12         25 my $text = shift;
28              
29 12         76 $text =~ s{
30             ((?<=[A-Z])<|>|/|\||^[=\x09\x20])
31             }{
32 14         76 $transforms{$1}
33             }egmx;
34 12         67 $text;
35             }
36              
37             *pod_quote = \&pod_escape;
38              
39             1;
40              
41             # ABSTRACT: Escape/quote special characters that might be interpreted by a POD parser
42              
43             __END__