| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::HTML::Turndown::Rules 0.11; |
|
2
|
5
|
|
|
5
|
|
75
|
use 5.020; |
|
|
5
|
|
|
|
|
15
|
|
|
3
|
5
|
|
|
5
|
|
22
|
use Moo; |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
35
|
|
|
4
|
5
|
|
|
5
|
|
1523
|
use experimental 'signatures'; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
31
|
|
|
5
|
5
|
|
|
5
|
|
633
|
use stable 'postderef'; |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
39
|
|
|
6
|
5
|
|
|
5
|
|
273
|
use Carp 'croak'; |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
6231
|
|
|
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
|
210
|
sub add( $self, $key, $rule ) { |
|
|
154
|
|
|
|
|
195
|
|
|
|
154
|
|
|
|
|
206
|
|
|
|
154
|
|
|
|
|
203
|
|
|
|
154
|
|
|
|
|
189
|
|
|
64
|
154
|
|
|
|
|
3124
|
unshift $self->array->@*, $rule |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
187
|
|
|
187
|
0
|
399
|
sub preprocess( $self, $processor ) { |
|
|
187
|
|
|
|
|
355
|
|
|
|
187
|
|
|
|
|
319
|
|
|
|
187
|
|
|
|
|
271
|
|
|
68
|
187
|
|
|
|
|
4234
|
unshift $self->_preprocess->@*, $processor |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
22
|
|
|
22
|
0
|
40
|
sub keep( $self, $filter ) { |
|
|
22
|
|
|
|
|
44
|
|
|
|
22
|
|
|
|
|
35
|
|
|
|
22
|
|
|
|
|
29
|
|
|
72
|
22
|
|
|
|
|
456
|
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
|
19
|
sub blankRule( $self ) { |
|
|
9
|
|
|
|
|
12
|
|
|
|
9
|
|
|
|
|
12
|
|
|
85
|
|
|
|
|
|
|
return { |
|
86
|
9
|
|
|
|
|
157
|
replacement => $self->blankReplacement, |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
364
|
|
|
364
|
0
|
522
|
sub defaultRule( $self ) { |
|
|
364
|
|
|
|
|
510
|
|
|
|
364
|
|
|
|
|
452
|
|
|
91
|
|
|
|
|
|
|
return { |
|
92
|
364
|
|
|
|
|
6695
|
replacement => $self->defaultReplacement |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
748
|
|
|
748
|
0
|
1276
|
sub forNode( $self, $node ) { |
|
|
748
|
|
|
|
|
1050
|
|
|
|
748
|
|
|
|
|
940
|
|
|
|
748
|
|
|
|
|
964
|
|
|
97
|
748
|
100
|
|
|
|
1998
|
if ($node->isBlank) { |
|
98
|
9
|
|
|
|
|
333
|
return $self->blankRule }; |
|
99
|
739
|
|
|
|
|
20307
|
my $rule; |
|
100
|
739
|
50
|
|
|
|
13859
|
if ($rule = $self->findRule($self->array, $node, $self->options)) { return $rule; } |
|
|
739
|
|
|
|
|
10517
|
|
|
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
|
165
|
|
|
165
|
0
|
262
|
sub forEach($self, $fn) { |
|
|
165
|
|
|
|
|
285
|
|
|
|
165
|
|
|
|
|
323
|
|
|
|
165
|
|
|
|
|
236
|
|
|
108
|
165
|
|
|
|
|
3737
|
my $arr = $self->array; |
|
109
|
|
|
|
|
|
|
$fn->( $arr->[ $_ ] ) |
|
110
|
165
|
|
|
|
|
1192
|
for (0..$#{$arr}); |
|
|
165
|
|
|
|
|
911
|
|
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
739
|
|
|
739
|
0
|
5105
|
sub findRule( $self, $rules, $node, $options ) { |
|
|
739
|
|
|
|
|
1032
|
|
|
|
739
|
|
|
|
|
1010
|
|
|
|
739
|
|
|
|
|
955
|
|
|
|
739
|
|
|
|
|
917
|
|
|
|
739
|
|
|
|
|
956
|
|
|
114
|
739
|
|
|
|
|
1583
|
for my $r ($rules->@*) { |
|
115
|
8848
|
100
|
|
|
|
164458
|
return $r |
|
116
|
|
|
|
|
|
|
if( $self->filterValue( $r, $node, $options )) |
|
117
|
|
|
|
|
|
|
} |
|
118
|
364
|
|
|
|
|
932
|
return $self->defaultRule |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
8848
|
|
|
8848
|
0
|
11859
|
sub filterValue( $self, $rule, $node, $options ) { |
|
|
8848
|
|
|
|
|
13136
|
|
|
|
8848
|
|
|
|
|
11677
|
|
|
|
8848
|
|
|
|
|
10999
|
|
|
|
8848
|
|
|
|
|
11325
|
|
|
|
8848
|
|
|
|
|
10431
|
|
|
122
|
8848
|
|
|
|
|
15113
|
my $filter = $rule->{filter}; |
|
123
|
8848
|
100
|
|
|
|
19647
|
if( ! ref $filter ) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
124
|
3120
|
|
|
|
|
52733
|
return $filter eq lc($node->nodeName) |
|
125
|
|
|
|
|
|
|
} elsif( ref $filter eq 'ARRAY' ) { |
|
126
|
2757
|
|
|
|
|
48890
|
my $nn = lc $node->nodeName; |
|
127
|
2757
|
|
|
|
|
73520
|
return scalar grep { $nn eq $_ } $filter->@* |
|
|
7912
|
|
|
|
|
19250
|
|
|
128
|
|
|
|
|
|
|
} elsif( ref $filter eq 'CODE' ) { |
|
129
|
2971
|
|
|
|
|
8537
|
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 |