File Coverage

blib/lib/String/PodQuote.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 20 20 100.0


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