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