line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# MathML::Entitities::Approximate |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright, Ian Stuart 2005. |
4
|
|
|
|
|
|
|
# Extends MathML::Entitities (c) Jacques Distler |
5
|
|
|
|
|
|
|
# All Rights Reserved. |
6
|
|
|
|
|
|
|
# Licensed under the Perl Artistic License. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Version: 0.20 |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package MathML::Entities::Approximate; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
32445
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
13
|
1
|
|
|
1
|
|
1278
|
use MathML::Entities qw(name2numbered name2utf8 ); |
|
1
|
|
|
|
|
10657
|
|
|
1
|
|
|
|
|
987
|
|
14
|
|
|
|
|
|
|
require Exporter; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @ISA = qw(Exporter MathML::Entities); |
17
|
|
|
|
|
|
|
our @EXPORT = qw( name2approximated name2numbered name2utf8 ); |
18
|
|
|
|
|
|
|
our $VERSION = '0.20'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our %APPROXIMATES = ( |
21
|
|
|
|
|
|
|
'AElig' => 'A', |
22
|
|
|
|
|
|
|
'Aacute' => 'A', |
23
|
|
|
|
|
|
|
'Abreve' => 'A', |
24
|
|
|
|
|
|
|
'Acirc' => 'A', |
25
|
|
|
|
|
|
|
'Agrave' => 'A', |
26
|
|
|
|
|
|
|
'Amacr' => 'A', |
27
|
|
|
|
|
|
|
'Aogon' => 'A', |
28
|
|
|
|
|
|
|
'Aring' => 'A', |
29
|
|
|
|
|
|
|
'Atilde' => 'A', |
30
|
|
|
|
|
|
|
'Auml' => 'A', |
31
|
|
|
|
|
|
|
'Cacute' => 'C', |
32
|
|
|
|
|
|
|
'Ccaron' => 'C', |
33
|
|
|
|
|
|
|
'Ccedil' => 'C', |
34
|
|
|
|
|
|
|
'Ccirc' => 'C', |
35
|
|
|
|
|
|
|
'Cdot' => 'C', |
36
|
|
|
|
|
|
|
'Dcaron' => 'D', |
37
|
|
|
|
|
|
|
'Dstrok' => 'D', |
38
|
|
|
|
|
|
|
'Dstroke' => 'D', |
39
|
|
|
|
|
|
|
'Eacute' => 'E', |
40
|
|
|
|
|
|
|
'Ecaron' => 'E', |
41
|
|
|
|
|
|
|
'Ecirc' => 'E', |
42
|
|
|
|
|
|
|
'Edot' => 'E', |
43
|
|
|
|
|
|
|
'Egrave' => 'E', |
44
|
|
|
|
|
|
|
'Emacr' => 'E', |
45
|
|
|
|
|
|
|
'Eogon' => 'E', |
46
|
|
|
|
|
|
|
'Euml' => 'E', |
47
|
|
|
|
|
|
|
'Gbreve' => 'G', |
48
|
|
|
|
|
|
|
'Gcedil' => 'G', |
49
|
|
|
|
|
|
|
'Gcirc' => 'G', |
50
|
|
|
|
|
|
|
'Gdot' => 'G', |
51
|
|
|
|
|
|
|
'Hcirc' => 'H', |
52
|
|
|
|
|
|
|
'Hstrok' => 'H', |
53
|
|
|
|
|
|
|
'IJlig' => 'IJ', |
54
|
|
|
|
|
|
|
'Iacute' => 'I', |
55
|
|
|
|
|
|
|
'Icirc' => 'I', |
56
|
|
|
|
|
|
|
'Idot' => 'I', |
57
|
|
|
|
|
|
|
'Igrave' => 'I', |
58
|
|
|
|
|
|
|
'Imacr' => 'I', |
59
|
|
|
|
|
|
|
'Iogon' => 'I', |
60
|
|
|
|
|
|
|
'Itilde' => 'I', |
61
|
|
|
|
|
|
|
'Iuml' => 'I', |
62
|
|
|
|
|
|
|
'Jcirc' => 'J', |
63
|
|
|
|
|
|
|
'Kcedil' => 'K', |
64
|
|
|
|
|
|
|
'Lacute' => 'L', |
65
|
|
|
|
|
|
|
'Lcaron' => 'L', |
66
|
|
|
|
|
|
|
'Lcedil' => 'L', |
67
|
|
|
|
|
|
|
'Lmidot' => 'L', |
68
|
|
|
|
|
|
|
'Lstrok' => 'L', |
69
|
|
|
|
|
|
|
'Lstroke' => 'L', |
70
|
|
|
|
|
|
|
'ENG' => 'N', |
71
|
|
|
|
|
|
|
'Nacute' => 'N', |
72
|
|
|
|
|
|
|
'Ncaron' => 'N', |
73
|
|
|
|
|
|
|
'Ncedil' => 'N', |
74
|
|
|
|
|
|
|
'Ntilde' => 'N', |
75
|
|
|
|
|
|
|
'OElig' => 'OE', |
76
|
|
|
|
|
|
|
'Oacute' => 'O', |
77
|
|
|
|
|
|
|
'Ocirc' => 'O', |
78
|
|
|
|
|
|
|
'Odblac' => 'O', |
79
|
|
|
|
|
|
|
'Ograve' => 'O', |
80
|
|
|
|
|
|
|
'Omacr' => 'O', |
81
|
|
|
|
|
|
|
'Oslash' => 'O', |
82
|
|
|
|
|
|
|
'Otilde' => 'O', |
83
|
|
|
|
|
|
|
'Ouml' => 'O', |
84
|
|
|
|
|
|
|
'Racute' => 'R', |
85
|
|
|
|
|
|
|
'Rcaron' => 'R', |
86
|
|
|
|
|
|
|
'Rcedil' => 'R', |
87
|
|
|
|
|
|
|
'Sacute' => 'S', |
88
|
|
|
|
|
|
|
'Scaron' => 'S', |
89
|
|
|
|
|
|
|
'Scedil' => 'S', |
90
|
|
|
|
|
|
|
'Scirc' => 'S', |
91
|
|
|
|
|
|
|
'Tcaron' => 'T', |
92
|
|
|
|
|
|
|
'Tcedil' => 'T', |
93
|
|
|
|
|
|
|
'Tstrok' => 'T', |
94
|
|
|
|
|
|
|
'Uacute' => 'U', |
95
|
|
|
|
|
|
|
'Ubreve' => 'U', |
96
|
|
|
|
|
|
|
'Ucirc' => 'U', |
97
|
|
|
|
|
|
|
'Udblac' => 'U', |
98
|
|
|
|
|
|
|
'Ugrave' => 'U', |
99
|
|
|
|
|
|
|
'Umacr' => 'U', |
100
|
|
|
|
|
|
|
'Uogon' => 'U', |
101
|
|
|
|
|
|
|
'Uring' => 'U', |
102
|
|
|
|
|
|
|
'Utilde' => 'U', |
103
|
|
|
|
|
|
|
'Uuml' => 'U', |
104
|
|
|
|
|
|
|
'Wcirc' => 'W', |
105
|
|
|
|
|
|
|
'Yacute' => 'Y', |
106
|
|
|
|
|
|
|
'Ycirc' => 'Y', |
107
|
|
|
|
|
|
|
'Yuml' => 'Y', |
108
|
|
|
|
|
|
|
'Zacute' => 'Z', |
109
|
|
|
|
|
|
|
'Zcaron' => 'Z', |
110
|
|
|
|
|
|
|
'Zdot' => 'Z', |
111
|
|
|
|
|
|
|
'aacute' => 'a', |
112
|
|
|
|
|
|
|
'abreve' => 'a', |
113
|
|
|
|
|
|
|
'acirc' => 'a', |
114
|
|
|
|
|
|
|
'aelig' => 'a', |
115
|
|
|
|
|
|
|
'agrave' => 'a', |
116
|
|
|
|
|
|
|
'amacr' => 'a', |
117
|
|
|
|
|
|
|
'Dstroke' => 'D', |
118
|
|
|
|
|
|
|
'Lstroke' => 'L', |
119
|
|
|
|
|
|
|
'cedilla' => 'c', |
120
|
|
|
|
|
|
|
'lstroke' => 'l', |
121
|
|
|
|
|
|
|
'aogon' => 'a', |
122
|
|
|
|
|
|
|
'aring' => 'a', |
123
|
|
|
|
|
|
|
'atilde' => 'a', |
124
|
|
|
|
|
|
|
'auml' => 'a', |
125
|
|
|
|
|
|
|
'cacute' => 'c', |
126
|
|
|
|
|
|
|
'ccaron' => 'c', |
127
|
|
|
|
|
|
|
'ccedil' => 'c', |
128
|
|
|
|
|
|
|
'ccirc' => 'c', |
129
|
|
|
|
|
|
|
'cdot' => 'c', |
130
|
|
|
|
|
|
|
'dcaron' => 'd', |
131
|
|
|
|
|
|
|
'dotlessi' => 'i', |
132
|
|
|
|
|
|
|
'dstrok' => 'd', |
133
|
|
|
|
|
|
|
'eacute' => 'e', |
134
|
|
|
|
|
|
|
'ecaron' => 'e', |
135
|
|
|
|
|
|
|
'ecirc' => 'e', |
136
|
|
|
|
|
|
|
'edot' => 'e', |
137
|
|
|
|
|
|
|
'egrave' => 'e', |
138
|
|
|
|
|
|
|
'emacr' => 'e', |
139
|
|
|
|
|
|
|
'eogon' => 'e', |
140
|
|
|
|
|
|
|
'euml' => 'e', |
141
|
|
|
|
|
|
|
'fnof' => 'f', |
142
|
|
|
|
|
|
|
'gacute' => 'g', |
143
|
|
|
|
|
|
|
'gbreve' => 'g', |
144
|
|
|
|
|
|
|
'gcirc' => 'g', |
145
|
|
|
|
|
|
|
'gdot' => 'g', |
146
|
|
|
|
|
|
|
'hcirc' => 'h', |
147
|
|
|
|
|
|
|
'hstrok' => 'h', |
148
|
|
|
|
|
|
|
'iacute' => 'i', |
149
|
|
|
|
|
|
|
'icirc' => 'i', |
150
|
|
|
|
|
|
|
'igrave' => 'i', |
151
|
|
|
|
|
|
|
'ijlig' => 'ij', |
152
|
|
|
|
|
|
|
'imacr' => 'i', |
153
|
|
|
|
|
|
|
'inodot' => 'i', |
154
|
|
|
|
|
|
|
'iogon' => 'i', |
155
|
|
|
|
|
|
|
'itilde' => 'i', |
156
|
|
|
|
|
|
|
'iuml' => 'i', |
157
|
|
|
|
|
|
|
'jcirc' => 'j', |
158
|
|
|
|
|
|
|
'kcedil' => 'k', |
159
|
|
|
|
|
|
|
'kgreen' => 'k', |
160
|
|
|
|
|
|
|
'lacute' => 'l', |
161
|
|
|
|
|
|
|
'lcaron' => 'l', |
162
|
|
|
|
|
|
|
'lcedil' => 'l', |
163
|
|
|
|
|
|
|
'lmidot' => 'l', |
164
|
|
|
|
|
|
|
'lstrok' => 'l', |
165
|
|
|
|
|
|
|
'lstroke' => 'l', |
166
|
|
|
|
|
|
|
'eng' => 'n', |
167
|
|
|
|
|
|
|
'nacute' => 'n', |
168
|
|
|
|
|
|
|
'napos' => 'n', |
169
|
|
|
|
|
|
|
'ncaron' => 'n', |
170
|
|
|
|
|
|
|
'ncedil' => 'n', |
171
|
|
|
|
|
|
|
'ntilde' => 'n', |
172
|
|
|
|
|
|
|
'oacute' => 'o', |
173
|
|
|
|
|
|
|
'ocirc' => 'o', |
174
|
|
|
|
|
|
|
'odblac' => 'o', |
175
|
|
|
|
|
|
|
'oelig' => 'oe', |
176
|
|
|
|
|
|
|
'ograve' => 'o', |
177
|
|
|
|
|
|
|
'omacr' => 'o', |
178
|
|
|
|
|
|
|
'oslash' => 'o', |
179
|
|
|
|
|
|
|
'otilde' => 'o', |
180
|
|
|
|
|
|
|
'ouml' => 'o', |
181
|
|
|
|
|
|
|
'racute' => 'r', |
182
|
|
|
|
|
|
|
'rcaron' => 'r', |
183
|
|
|
|
|
|
|
'rcedil' => 'r', |
184
|
|
|
|
|
|
|
'sacute' => 's', |
185
|
|
|
|
|
|
|
'scaron' => 's', |
186
|
|
|
|
|
|
|
'scedil' => 's', |
187
|
|
|
|
|
|
|
'scirc' => 's', |
188
|
|
|
|
|
|
|
'sup1' => '1', |
189
|
|
|
|
|
|
|
'szlig' => 's', |
190
|
|
|
|
|
|
|
'tcaron' => 't', |
191
|
|
|
|
|
|
|
'tcedil' => 't', |
192
|
|
|
|
|
|
|
'tstrok' => 't', |
193
|
|
|
|
|
|
|
'uacute' => 'u', |
194
|
|
|
|
|
|
|
'ubreve' => 'u', |
195
|
|
|
|
|
|
|
'ucirc' => 'u', |
196
|
|
|
|
|
|
|
'udblac' => 'u', |
197
|
|
|
|
|
|
|
'ugrave' => 'u', |
198
|
|
|
|
|
|
|
'umacr' => 'u', |
199
|
|
|
|
|
|
|
'uogon' => 'u', |
200
|
|
|
|
|
|
|
'uring' => 'u', |
201
|
|
|
|
|
|
|
'utilde' => 'u', |
202
|
|
|
|
|
|
|
'uuml' => 'u', |
203
|
|
|
|
|
|
|
'wcirc' => 'w', |
204
|
|
|
|
|
|
|
'yacute' => 'y', |
205
|
|
|
|
|
|
|
'ycirc' => 'y', |
206
|
|
|
|
|
|
|
'yuml' => 'y', |
207
|
|
|
|
|
|
|
'zacute' => 'z', |
208
|
|
|
|
|
|
|
'zcaron' => 'z', |
209
|
|
|
|
|
|
|
'zdot' => 'z' |
210
|
|
|
|
|
|
|
); |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
sub name2approximated { |
213
|
3
|
|
|
3
|
1
|
12
|
my $content = shift; |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
# We have to call the subroutine so we can do the "exist" test. |
216
|
|
|
|
|
|
|
# If we don't do the exist test, then we get loads of |
217
|
|
|
|
|
|
|
# 'Use of uninitialized value in substitution iterator' errors |
218
|
3
|
50
|
|
|
|
26
|
$content =~ s/(&([a-zA-Z0-9]+);)/$2 ? _convert2approximated($1) : ""/eg; |
|
3
|
|
|
|
|
17
|
|
219
|
|
|
|
|
|
|
|
220
|
3
|
|
|
|
|
21
|
return $content; |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub getSet { |
225
|
|
|
|
|
|
|
# get, or set-and-get, a key-value pair from the lookup table |
226
|
2
|
|
|
2
|
1
|
513
|
my ($key, $value) = @_; |
227
|
|
|
|
|
|
|
|
228
|
2
|
50
|
|
|
|
6
|
if ($key) { |
229
|
2
|
100
|
|
|
|
8
|
$APPROXIMATES{$key} = $value if $value; |
230
|
2
|
|
|
|
|
12
|
return $APPROXIMATES{$key}; |
231
|
|
|
|
|
|
|
}; |
232
|
0
|
|
|
|
|
0
|
return undef; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub _convert2approximated { |
236
|
|
|
|
|
|
|
# this is the actual lookup routine |
237
|
3
|
|
|
3
|
|
8
|
my $reference = shift; |
238
|
3
|
|
|
|
|
9
|
$reference =~ /^&([a-zA-Z0-9]+);$/; |
239
|
3
|
|
|
|
|
7
|
my $name = $1; |
240
|
3
|
100
|
66
|
|
|
27
|
return (exists $MathML::Entities::ENTITIES{$name} && |
241
|
|
|
|
|
|
|
exists $APPROXIMATES{$name} ) ? |
242
|
|
|
|
|
|
|
$APPROXIMATES{$name} : "" ; |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
} |
245
|
|
|
|
|
|
|
1; |
246
|
|
|
|
|
|
|
__END__ |