File Coverage

blib/lib/Locale/Maketext/Utils/Phrase/Norm/Markup.pm
Criterion Covered Total %
statement 21 21 100.0
branch 5 6 83.3
condition n/a
subroutine 3 3 100.0
pod 0 1 0.0
total 29 31 93.5


line stmt bran cond sub pod time code
1             package Locale::Maketext::Utils::Phrase::Norm::Markup;
2              
3 4     4   5581 use strict;
  4         7  
  4         525  
4 4     4   23 use warnings;
  4         8  
  4         1361  
5              
6             sub normalize_maketext_string {
7 78     78 0 144 my ($filter) = @_;
8              
9             # & is handled more in depth in it's own module
10 78 100       334 if ( $filter->get_orig_str() =~ m/[<>"']/ ) {
11              
12             # normalize <>"' to [output,ENT]
13              
14             # this filter could be smarter like ampersand’s 'Prefer [output,amp] over …' and 'Prefer chr(38) over …'
15              
16 14         43 my $string_sr = $filter->get_string_sr();
17              
18 14 100       22 if ( ${$string_sr} =~ s/'/[output,apos]/g ) {
  14         88  
19 10         38 $filter->add_warning('consider if, instead of using a straight apostrophe, using ‘’ for single quoting and ’ for an apostrophe is the right thing here (i.e. instead of bracket notation)');
20             }
21 14 50       22 if ( ${$string_sr} =~ s/"/[output,quot]/g ) {
  14         82  
22 14         40 $filter->add_warning('consider if, instead of using straight double quotes, using “” is the right thing here (i.e. instead of bracket notation)');
23             }
24 14         21 ${$string_sr} =~ s/>/[output,gt]/g;
  14         58  
25 14         22 ${$string_sr} =~ s/
  14         42  
26              
27 14         52 $filter->add_violation('Contains markup related characters');
28             }
29              
30 78         268 return $filter->return_value;
31             }
32              
33             1;
34              
35             __END__