line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Template::Compiled::Filter::Whitespace; ## no critic (TidyCode)
|
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
178392
|
use strict;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
67
|
|
4
|
3
|
|
|
3
|
|
10
|
use warnings;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
99
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.09';
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
1074
|
use parent qw( Exporter::Tiny );
|
|
3
|
|
|
|
|
648
|
|
|
3
|
|
|
|
|
12
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw(
|
11
|
|
|
|
|
|
|
get_whitespace_filter
|
12
|
|
|
|
|
|
|
whitespace_filter
|
13
|
|
|
|
|
|
|
);
|
14
|
|
|
|
|
|
|
our $DEBUG;
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $inplace_whitespace_filter = sub {
|
17
|
|
|
|
|
|
|
my $scalarref = shift;
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
return if $DEBUG;
|
20
|
|
|
|
|
|
|
${$scalarref} =~ tr{\0}{ };
|
21
|
|
|
|
|
|
|
my @unclean;
|
22
|
|
|
|
|
|
|
while (
|
23
|
|
|
|
|
|
|
${$scalarref} =~ s{(
|
24
|
|
|
|
|
|
|
< \s* (pre | code | textarea) [^>]* > # opening pre-, code
|
25
|
|
|
|
|
|
|
# or textarea tag
|
26
|
|
|
|
|
|
|
.*? # content
|
27
|
|
|
|
|
|
|
< \s* / \2 [^>]* > # closing tag
|
28
|
|
|
|
|
|
|
)}{\0}xmsi
|
29
|
|
|
|
|
|
|
) {
|
30
|
|
|
|
|
|
|
push @unclean, $1;
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
${$scalarref} =~ s{
|
33
|
|
|
|
|
|
|
(?: ^ \s*) # leading spaces and empty lines
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
(?: [^\S\n]* $)
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
([^\S\n]* (?: \n | \z)) # spaces at EOL
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
([^\S\n]{2,}) # spaces between text
|
40
|
|
|
|
|
|
|
}{ $1 ? "\n" : $2 ? q{ } : q{} }xmsge;
|
41
|
|
|
|
|
|
|
for my $unclean (@unclean) {
|
42
|
|
|
|
|
|
|
${$scalarref} =~ s{\0}{$unclean}xms;
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return;
|
46
|
|
|
|
|
|
|
};
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub get_whitespace_filter {
|
49
|
1
|
|
|
1
|
1
|
75838
|
return $inplace_whitespace_filter;
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub whitespace_filter {
|
53
|
1
|
|
|
1
|
1
|
67622
|
my $html = shift;
|
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
4
|
$inplace_whitespace_filter->(\$html);
|
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
5
|
return $html;
|
58
|
|
|
|
|
|
|
}
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# $Id$
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1;
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__
|