line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Md2Inao::Builder; |
2
|
29
|
|
|
29
|
|
27891
|
use utf8; |
|
29
|
|
|
|
|
65
|
|
|
29
|
|
|
|
|
218
|
|
3
|
29
|
|
|
29
|
|
905
|
use strict; |
|
29
|
|
|
|
|
59
|
|
|
29
|
|
|
|
|
1114
|
|
4
|
29
|
|
|
29
|
|
160
|
use warnings; |
|
29
|
|
|
|
|
60
|
|
|
29
|
|
|
|
|
1428
|
|
5
|
|
|
|
|
|
|
|
6
|
29
|
|
|
29
|
|
167
|
use Class::Accessor::Fast qw/antlers/; |
|
29
|
|
|
|
|
64
|
|
|
29
|
|
|
|
|
309
|
|
7
|
|
|
|
|
|
|
|
8
|
29
|
|
|
29
|
|
52524
|
use JSON; |
|
29
|
|
|
|
|
695768
|
|
|
29
|
|
|
|
|
341
|
|
9
|
29
|
|
|
29
|
|
46047
|
use Path::Tiny; |
|
29
|
|
|
|
|
520285
|
|
|
29
|
|
|
|
|
20076
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has dispatch_table => ( is => 'rw' ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has before_filter_config => ( is => 'rw' ); |
14
|
|
|
|
|
|
|
has after_filter_config => ( is => 'rw' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
{ |
17
|
|
|
|
|
|
|
my %singleton; |
18
|
|
|
|
|
|
|
sub new { |
19
|
1194
|
|
|
1194
|
1
|
61681
|
my $class = shift; |
20
|
1194
|
|
66
|
|
|
5630
|
return $singleton{$class} //= $class->_new(); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _new { |
25
|
53
|
|
|
53
|
|
140
|
my $class = shift; |
26
|
53
|
|
|
|
|
672
|
return $class->SUPER::new({ dispatch_table => {} }); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub dispatch { |
30
|
943
|
|
|
943
|
0
|
4863
|
my ($self, $select) = @_; |
31
|
943
|
|
66
|
|
|
2468
|
return $self->dispatch_table->{$select} || $self->dispatch_table->{default}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub load_filter_config { |
35
|
24
|
|
|
24
|
0
|
1059
|
my ($self, $path) = @_; |
36
|
24
|
|
|
|
|
125
|
my $json = path($path)->slurp; |
37
|
24
|
|
|
|
|
9445
|
my $config = decode_json $json; |
38
|
24
|
|
|
|
|
86
|
for (qw/before_filter after_filter/) { |
39
|
48
|
50
|
|
|
|
666
|
if ($config->{$_}) { |
40
|
48
|
|
|
|
|
223
|
my $meth = sprintf "%s_config", $_; |
41
|
48
|
|
|
|
|
488
|
$self->$meth($config->{$_}); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub before_filter { |
47
|
202
|
|
|
202
|
0
|
1594
|
my ($self, $c, $in) = @_; |
48
|
202
|
100
|
|
|
|
918
|
if (my $config = $self->before_filter_config) { |
49
|
107
|
|
|
|
|
1613
|
for my $k (keys %$config) { |
50
|
4135
|
|
|
|
|
7740
|
my $v = $config->{$k}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
4135
|
|
|
|
|
12445
|
$v =~ s/</◆lt◆/g; |
56
|
4135
|
|
|
|
|
13941
|
$v =~ s/>/◆gt◆/g; |
57
|
|
|
|
|
|
|
|
58
|
4135
|
|
|
|
|
39560
|
$in =~ s/$k/$v/eg; |
|
40
|
|
|
|
|
165
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
202
|
|
|
|
|
1524
|
return $in; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub after_filter { |
65
|
202
|
|
|
202
|
0
|
391
|
my ($self, $c, $out) = @_; |
66
|
202
|
|
|
|
|
712
|
$out =~ s/◆lt◆/</g; |
67
|
202
|
|
|
|
|
893
|
$out =~ s/◆gt◆/>/g; |
68
|
202
|
100
|
|
|
|
849
|
if (my $config = $self->after_filter_config) { |
69
|
107
|
|
|
|
|
1052
|
for my $k (keys %$config) { |
70
|
1485
|
|
|
|
|
20207
|
$out =~ s/$k/$config->{$k}/eg; |
|
15
|
|
|
|
|
116
|
|
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
202
|
|
|
|
|
1765
|
return $out; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|