| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Locale::Maketext::Utils::Phrase::Norm::Ampersand; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
3560
|
use strict; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
141
|
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
1389
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub normalize_maketext_string { |
|
7
|
75
|
|
|
75
|
0
|
221
|
my ($filter) = @_; |
|
8
|
|
|
|
|
|
|
|
|
9
|
75
|
|
|
|
|
225
|
my $string_sr = $filter->get_string_sr(); |
|
10
|
|
|
|
|
|
|
|
|
11
|
75
|
100
|
|
|
|
147
|
if ( ${$string_sr} =~ s{\[output,chr,(?:\&|38)\]}{[output,amp]}g ) { |
|
|
75
|
|
|
|
|
338
|
|
|
12
|
8
|
|
|
|
|
32
|
$filter->add_violation('Prefer [output,amp] over [output,chr,&] or [output,chr,38].'); |
|
13
|
|
|
|
|
|
|
} |
|
14
|
75
|
100
|
|
|
|
141
|
if ( ${$string_sr} =~ s{chr\(&\)}{chr\(38\)}g ) { |
|
|
75
|
|
|
|
|
308
|
|
|
15
|
8
|
|
|
|
|
22
|
$filter->add_violation('Prefer chr(38) over chr(&).'); |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
75
|
100
|
|
|
|
169
|
if ( ${$string_sr} =~ s{&}{[output,amp]}g ) { |
|
|
75
|
|
|
|
|
290
|
|
|
19
|
8
|
|
|
|
|
26
|
$filter->add_violation('Ampersands need done via [output,amp].'); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
75
|
|
|
|
|
137
|
my $aft = ${$string_sr} =~ s/\[output,amp\]([^ ])/[output,amp] $1/g; |
|
|
75
|
|
|
|
|
299
|
|
|
23
|
75
|
|
|
|
|
157
|
my $bef = ${$string_sr} =~ s/([^ ])\[output,amp\]/$1 [output,amp]/g; |
|
|
75
|
|
|
|
|
241
|
|
|
24
|
75
|
100
|
66
|
|
|
420
|
if ( $bef || $aft ) { |
|
25
|
8
|
|
|
|
|
27
|
$filter->add_violation('Ampersand should have one space before and/or after unless it is embedded in an asis().'); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
75
|
|
|
|
|
241
|
return $filter->return_value; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
__END__ |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=encoding utf-8 |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 Normalization |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Do not use a raw ampersand even in output,chr. If used as text it needs to have a spaces around it. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 Rationale |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Same rationale as the L<Markup|Locale::Maketext::Utils::Phrase::Norm::Markup/Rationale>. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Since & is a markup character it must be done via output() in order to be safe in all contexts. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
If it is used as a word it should have a space on each side of it for clarity. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 IF YOU USE THIS FILTER ALSO USE … |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
… THIS FILTER L<Locale::Maketext::Utils::Phrase::Norm::Markup>. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This is not enforced anywhere since we want to assume the coder knows what they are doing. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 possible violations |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=over 4 |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item Prefer [output,amp] over [output,chr,&] or [output,chr,38]. |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Problem should be self explanatory. The former gets replaced with the latter. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item Prefer chr(38) over chr(&). |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Problem should be self explanatory. The former gets replaced with the latter. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item Ampersands need done via [output,amp]. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Problem should be self explanatory. The former gets replaced with the latter. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item Ampersand should have one space before and/or after unless it is embedded in an asis(). |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Problem should be self explanatory. Spaces get added as needed. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 possible warnings |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
None |