line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Entities::Numbered; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
200608
|
use strict; |
|
10
|
|
|
|
|
25
|
|
|
10
|
|
|
|
|
378
|
|
4
|
10
|
|
|
10
|
|
4756
|
use HTML::Entities::Numbered::Table; |
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
1033
|
|
5
|
10
|
|
|
10
|
|
52
|
use base qw(Exporter); |
|
10
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
665
|
|
6
|
10
|
|
|
10
|
|
45
|
use vars qw($VERSION @EXPORT %DECIMALS %ENTITIES); |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
828
|
|
7
|
|
|
|
|
|
|
@EXPORT = qw( |
8
|
|
|
|
|
|
|
name2decimal name2hex name2decimal_xml name2hex_xml decimal2name hex2name |
9
|
|
|
|
|
|
|
); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = '0.04'; |
12
|
|
|
|
|
|
|
|
13
|
10
|
|
|
10
|
|
8363
|
BEGIN { %ENTITIES = reverse %DECIMALS } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub name2decimal { |
16
|
1512
|
|
|
1512
|
1
|
191381
|
my $content = shift; |
17
|
1512
|
|
|
|
|
5426
|
$content =~ s/(&[a-z0-9]+;)/_convert2num($1, '%d;')/ieg; |
|
1512
|
|
|
|
|
2745
|
|
18
|
1512
|
|
|
|
|
4757
|
return $content; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub name2hex { |
22
|
756
|
|
|
756
|
1
|
79114
|
my $content = shift; |
23
|
756
|
|
|
|
|
2445
|
$content =~ s/(&[a-z0-9]+;)/_convert2num($1, '%X;')/ieg; |
|
756
|
|
|
|
|
1218
|
|
24
|
756
|
|
|
|
|
2181
|
return $content; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub name2decimal_xml { |
28
|
252
|
|
|
252
|
1
|
55494
|
my $content = shift; |
29
|
252
|
|
|
|
|
959
|
$content =~ s{(&(?:(lt|gt|amp|quot|apos)|[a-z0-9]+);)} |
30
|
252
|
100
|
|
|
|
702
|
{ $2 ? $1 : _convert2num($1, '%d;') }ieg; |
31
|
252
|
|
|
|
|
784
|
return $content; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub name2hex_xml { |
35
|
252
|
|
|
252
|
1
|
68988
|
my $content = shift; |
36
|
252
|
|
|
|
|
1089
|
$content =~ s{(&(?:(lt|gt|amp|quot|apos)|[a-z0-9]+);)} |
37
|
252
|
100
|
|
|
|
895
|
{ $2 ? $1 : _convert2num($1, '%X;') }ieg; |
38
|
252
|
|
|
|
|
873
|
return $content; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub decimal2name { |
42
|
1008
|
|
|
1008
|
1
|
81508
|
my $content = shift; |
43
|
1008
|
|
|
|
|
3820
|
$content =~ s/(\d+;)/_convert2name($1)/ieg; |
|
1008
|
|
|
|
|
1472
|
|
44
|
1008
|
|
|
|
|
3101
|
return $content; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub hex2name { |
48
|
1008
|
|
|
1008
|
1
|
109167
|
my $content = shift; |
49
|
1008
|
|
|
|
|
3664
|
$content =~ s/([a-f0-9]+;)/_convert2name($1)/ieg; |
|
1008
|
|
|
|
|
1602
|
|
50
|
1008
|
|
|
|
|
3074
|
return $content; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _convert2num { |
54
|
2764
|
|
|
2764
|
|
4911
|
my($reference, $format) = @_; |
55
|
2764
|
|
|
|
|
7769
|
my($name) = $reference =~ /^&([a-z0-9]+);$/i; |
56
|
2764
|
100
|
|
|
|
13331
|
return exists $DECIMALS{$name} ? |
57
|
|
|
|
|
|
|
sprintf($format, $DECIMALS{$name}) : $reference; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _convert2name { |
61
|
2016
|
|
|
2016
|
|
3228
|
my $reference = shift; |
62
|
2016
|
|
|
|
|
6804
|
my($is_hex, $decimal) = $reference =~ /^(x?)([a-f0-9]+);$/i; |
63
|
2016
|
100
|
|
|
|
5745
|
$decimal = sprintf('%d', ($is_hex ? hex($decimal) : $decimal)); |
64
|
2016
|
50
|
|
|
|
8787
|
return exists $ENTITIES{$decimal} ? |
65
|
|
|
|
|
|
|
sprintf('&%s;', $ENTITIES{$decimal}) : $reference; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |