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