| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Text::Ligature; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
84719
|
use 5.006; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
93
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
76
|
|
|
5
|
2
|
|
|
2
|
|
253
|
use warnings; |
|
|
2
|
|
|
|
|
11
|
|
|
|
2
|
|
|
|
|
79
|
|
|
6
|
2
|
|
|
2
|
|
932
|
use utf8; |
|
|
2
|
|
|
|
|
11
|
|
|
|
2
|
|
|
|
|
12
|
|
|
7
|
2
|
|
|
2
|
|
1933
|
use parent 'Exporter'; |
|
|
2
|
|
|
|
|
827
|
|
|
|
2
|
|
|
|
|
10
|
|
|
8
|
2
|
|
|
2
|
|
125
|
use Carp; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
913
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw< to_ligatures from_ligatures to_ligature from_ligature >; |
|
12
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \@EXPORT_OK ); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# TODO: remove to_ligature/from_ligature in next release |
|
15
|
|
|
|
|
|
|
*to_ligature = \&to_ligatures; |
|
16
|
|
|
|
|
|
|
*from_ligature = \&from_ligatures; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my @defaults = qw< ff fi fl ffi ffl >; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my %lig_for = ( |
|
21
|
|
|
|
|
|
|
ff => 'ff', |
|
22
|
|
|
|
|
|
|
fi => 'fi', |
|
23
|
|
|
|
|
|
|
fl => 'fl', |
|
24
|
|
|
|
|
|
|
ffi => 'ffi', |
|
25
|
|
|
|
|
|
|
ffl => 'ffl', |
|
26
|
|
|
|
|
|
|
ft => 'ſt', |
|
27
|
|
|
|
|
|
|
st => 'st', |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my %chars_for = reverse %lig_for; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub to_ligatures { |
|
33
|
4
|
|
|
4
|
0
|
165
|
my ($text) = @_; |
|
34
|
|
|
|
|
|
|
|
|
35
|
4
|
100
|
|
|
|
19
|
if (@_ != 1) { |
|
36
|
2
|
|
|
|
|
61
|
carp 'to_ligatures() expects one argument'; |
|
37
|
2
|
|
|
|
|
1613
|
return; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# longest token matching |
|
41
|
2
|
|
|
|
|
11
|
for my $chars (sort { length $b <=> length $a } @defaults) { |
|
|
14
|
|
|
|
|
22
|
|
|
42
|
10
|
|
|
|
|
113
|
$text =~ s/$chars/$lig_for{$chars}/g; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
13
|
return $text; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub from_ligatures { |
|
49
|
4
|
|
|
4
|
0
|
96
|
my ($text) = @_; |
|
50
|
|
|
|
|
|
|
|
|
51
|
4
|
100
|
|
|
|
18
|
if (@_ != 1) { |
|
52
|
2
|
|
|
|
|
31
|
carp 'from_ligatures() expects one argument'; |
|
53
|
2
|
|
|
|
|
1784
|
return; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
2
|
|
|
|
|
9
|
for my $lig (keys %chars_for) { |
|
57
|
14
|
|
|
|
|
170
|
$text =~ s/$lig/$chars_for{$lig}/g; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
13
|
return $text; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |