| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::HTML::Turndown::Rules 0.12; |
|
2
|
6
|
|
|
6
|
|
117
|
use 5.020; |
|
|
6
|
|
|
|
|
55
|
|
|
3
|
6
|
|
|
6
|
|
38
|
use Moo; |
|
|
6
|
|
|
|
|
12
|
|
|
|
6
|
|
|
|
|
67
|
|
|
4
|
6
|
|
|
6
|
|
2711
|
use experimental 'signatures'; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
50
|
|
|
5
|
6
|
|
|
6
|
|
1151
|
use stable 'postderef'; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
59
|
|
|
6
|
6
|
|
|
6
|
|
521
|
use Carp 'croak'; |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
10844
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'options' => ( |
|
9
|
|
|
|
|
|
|
is => 'ro', |
|
10
|
|
|
|
|
|
|
required => 1, |
|
11
|
|
|
|
|
|
|
); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'rules' => ( |
|
14
|
|
|
|
|
|
|
is => 'ro', |
|
15
|
|
|
|
|
|
|
required => 1, |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has '_preprocess' => ( |
|
19
|
|
|
|
|
|
|
is => 'lazy', |
|
20
|
|
|
|
|
|
|
default => sub { [] }, |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has '_keep' => ( |
|
24
|
|
|
|
|
|
|
is => 'lazy', |
|
25
|
|
|
|
|
|
|
default => sub { [] }, |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has '_remove' => ( |
|
29
|
|
|
|
|
|
|
is => 'lazy', |
|
30
|
|
|
|
|
|
|
default => sub { [] }, |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'array' => ( |
|
34
|
|
|
|
|
|
|
is => 'lazy', |
|
35
|
|
|
|
|
|
|
default => sub($self) { |
|
36
|
|
|
|
|
|
|
my @arr; |
|
37
|
|
|
|
|
|
|
my $r = $self->rules // {}; |
|
38
|
|
|
|
|
|
|
for my $rule ( sort keys $r->%*) { |
|
39
|
|
|
|
|
|
|
push @arr, $r->{$rule}; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
return \@arr; |
|
42
|
|
|
|
|
|
|
}, |
|
43
|
|
|
|
|
|
|
); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has 'defaultReplacement' => ( |
|
46
|
|
|
|
|
|
|
is => 'lazy', |
|
47
|
|
|
|
|
|
|
default => sub { |
|
48
|
|
|
|
|
|
|
sub( $content, $node, $options, $context ) { |
|
49
|
|
|
|
|
|
|
$node->isBlock ? "\n\n" . $content . "\n\n" : $content |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has 'blankReplacement' => ( |
|
55
|
|
|
|
|
|
|
is => 'lazy', |
|
56
|
|
|
|
|
|
|
default => sub { |
|
57
|
|
|
|
|
|
|
sub( $content, $node, $options, $context ) { |
|
58
|
|
|
|
|
|
|
$node->isBlock ? "\n\n" : '' |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
); |
|
62
|
|
|
|
|
|
|
|
|
63
|
154
|
|
|
154
|
0
|
250
|
sub add( $self, $key, $rule ) { |
|
|
154
|
|
|
|
|
255
|
|
|
|
154
|
|
|
|
|
239
|
|
|
|
154
|
|
|
|
|
219
|
|
|
|
154
|
|
|
|
|
215
|
|
|
64
|
154
|
|
|
|
|
3662
|
unshift $self->array->@*, $rule |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
189
|
|
|
189
|
0
|
399
|
sub preprocess( $self, $processor ) { |
|
|
189
|
|
|
|
|
317
|
|
|
|
189
|
|
|
|
|
291
|
|
|
|
189
|
|
|
|
|
312
|
|
|
68
|
189
|
|
|
|
|
4146
|
unshift $self->_preprocess->@*, $processor |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
22
|
|
|
22
|
0
|
36
|
sub keep( $self, $filter ) { |
|
|
22
|
|
|
|
|
44
|
|
|
|
22
|
|
|
|
|
32
|
|
|
|
22
|
|
|
|
|
34
|
|
|
72
|
22
|
|
|
|
|
546
|
unshift $self->_keep->@*, $filter |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
0
|
0
|
sub remove( $self, $filter ) { |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
76
|
|
|
|
|
|
|
unshift $self->_remove->@*, { |
|
77
|
|
|
|
|
|
|
filter => $filter, |
|
78
|
|
|
|
|
|
|
replacement => sub { |
|
79
|
0
|
|
|
0
|
|
0
|
return ''; |
|
80
|
|
|
|
|
|
|
}, |
|
81
|
0
|
|
|
|
|
0
|
}; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
9
|
|
|
9
|
0
|
18
|
sub blankRule( $self ) { |
|
|
9
|
|
|
|
|
15
|
|
|
|
9
|
|
|
|
|
14
|
|
|
85
|
|
|
|
|
|
|
return { |
|
86
|
9
|
|
|
|
|
177
|
replacement => $self->blankReplacement, |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
371
|
|
|
371
|
0
|
508
|
sub defaultRule( $self ) { |
|
|
371
|
|
|
|
|
508
|
|
|
|
371
|
|
|
|
|
468
|
|
|
91
|
|
|
|
|
|
|
return { |
|
92
|
371
|
|
|
|
|
6315
|
replacement => $self->defaultReplacement |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
757
|
|
|
757
|
0
|
1132
|
sub forNode( $self, $node ) { |
|
|
757
|
|
|
|
|
1147
|
|
|
|
757
|
|
|
|
|
1058
|
|
|
|
757
|
|
|
|
|
1076
|
|
|
97
|
757
|
100
|
|
|
|
2215
|
if ($node->isBlank) { |
|
98
|
9
|
|
|
|
|
366
|
return $self->blankRule }; |
|
99
|
748
|
|
|
|
|
20689
|
my $rule; |
|
100
|
748
|
50
|
|
|
|
15291
|
if ($rule = $self->findRule($self->array, $node, $self->options)) { return $rule; } |
|
|
748
|
|
|
|
|
11924
|
|
|
101
|
0
|
0
|
|
|
|
0
|
if ($rule = $self->findRule($self->_keep, $node, $self->options)) { return $rule; } |
|
|
0
|
|
|
|
|
0
|
|
|
102
|
0
|
0
|
|
|
|
0
|
if ($rule = $self->findRule($self->_remove, $node, $self->options)) { return $rule; } |
|
|
0
|
|
|
|
|
0
|
|
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
0
|
return $self->defaultRule |
|
105
|
|
|
|
|
|
|
}; |
|
106
|
|
|
|
|
|
|
|
|
107
|
167
|
|
|
167
|
0
|
283
|
sub forEach($self, $fn) { |
|
|
167
|
|
|
|
|
261
|
|
|
|
167
|
|
|
|
|
307
|
|
|
|
167
|
|
|
|
|
233
|
|
|
108
|
167
|
|
|
|
|
3716
|
my $arr = $self->array; |
|
109
|
|
|
|
|
|
|
$fn->( $arr->[ $_ ] ) |
|
110
|
167
|
|
|
|
|
1207
|
for (0..$#{$arr}); |
|
|
167
|
|
|
|
|
936
|
|
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
748
|
|
|
748
|
0
|
5549
|
sub findRule( $self, $rules, $node, $options ) { |
|
|
748
|
|
|
|
|
1094
|
|
|
|
748
|
|
|
|
|
1079
|
|
|
|
748
|
|
|
|
|
945
|
|
|
|
748
|
|
|
|
|
1041
|
|
|
|
748
|
|
|
|
|
957
|
|
|
114
|
748
|
|
|
|
|
1609
|
for my $r ($rules->@*) { |
|
115
|
8843
|
100
|
|
|
|
180300
|
return $r |
|
116
|
|
|
|
|
|
|
if( $self->filterValue( $r, $node, $options )) |
|
117
|
|
|
|
|
|
|
} |
|
118
|
371
|
|
|
|
|
929
|
return $self->defaultRule |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
8843
|
|
|
8843
|
0
|
11656
|
sub filterValue( $self, $rule, $node, $options ) { |
|
|
8843
|
|
|
|
|
12166
|
|
|
|
8843
|
|
|
|
|
14627
|
|
|
|
8843
|
|
|
|
|
10767
|
|
|
|
8843
|
|
|
|
|
11146
|
|
|
|
8843
|
|
|
|
|
10379
|
|
|
122
|
8843
|
|
|
|
|
15535
|
my $filter = $rule->{filter}; |
|
123
|
8843
|
100
|
|
|
|
19846
|
if( ! ref $filter ) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
124
|
3281
|
|
|
|
|
55646
|
return $filter eq lc($node->nodeName) |
|
125
|
|
|
|
|
|
|
} elsif( ref $filter eq 'ARRAY' ) { |
|
126
|
2550
|
|
|
|
|
46057
|
my $nn = lc $node->nodeName; |
|
127
|
2550
|
|
|
|
|
68344
|
return scalar grep { $nn eq $_ } $filter->@* |
|
|
7534
|
|
|
|
|
18555
|
|
|
128
|
|
|
|
|
|
|
} elsif( ref $filter eq 'CODE' ) { |
|
129
|
3012
|
|
|
|
|
8683
|
return $filter->( $rule, $node, $options ) |
|
130
|
|
|
|
|
|
|
} else { |
|
131
|
0
|
|
|
|
|
|
croak "Unknown filter type '$filter'"; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
|
136
|
|
|
|
|
|
|
=head1 REPOSITORY |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
The public repository of this module is |
|
139
|
|
|
|
|
|
|
L. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 SUPPORT |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
The public support forum of this module is L. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 BUG TRACKER |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Please report bugs in this module via the Github bug queue at |
|
148
|
|
|
|
|
|
|
L |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 AUTHOR |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Max Maischein C |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 COPYRIGHT (c) |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Copyright 2025- by Max Maischein C. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 LICENSE |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This module is released under the Artistic License 2.0. |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |