line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Entirely stolen from HTML::Entities |
2
|
|
|
|
|
|
|
# And modified to fit Petal's purposes. |
3
|
|
|
|
|
|
|
package Petal::Entities; |
4
|
77
|
|
|
77
|
|
550
|
use strict; |
|
77
|
|
|
|
|
127
|
|
|
77
|
|
|
|
|
2207
|
|
5
|
77
|
|
|
77
|
|
353
|
use warnings; |
|
77
|
|
|
|
|
139
|
|
|
77
|
|
|
|
|
76068
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our %ENTITY_2_CHAR = ( |
9
|
|
|
|
|
|
|
# Some normal chars that have special meaning in SGML context |
10
|
|
|
|
|
|
|
# those will be managed by XML::Parser |
11
|
|
|
|
|
|
|
# so we don't want to expand them |
12
|
|
|
|
|
|
|
# amp => '&', # ampersand |
13
|
|
|
|
|
|
|
# 'gt' => '>', # greater than |
14
|
|
|
|
|
|
|
# 'lt' => '<', # less than |
15
|
|
|
|
|
|
|
# quot => '"', # double quote |
16
|
|
|
|
|
|
|
# apos => "'", # single quote |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# PUBLIC ISO 8879-1986//ENTITIES Added Latin 1//EN//HTML |
19
|
|
|
|
|
|
|
AElig => 'Æ', # capital AE diphthong (ligature) |
20
|
|
|
|
|
|
|
Aacute => 'Á', # capital A, acute accent |
21
|
|
|
|
|
|
|
Acirc => 'Â', # capital A, circumflex accent |
22
|
|
|
|
|
|
|
Agrave => 'À', # capital A, grave accent |
23
|
|
|
|
|
|
|
Aring => 'Å', # capital A, ring |
24
|
|
|
|
|
|
|
Atilde => 'Ã', # capital A, tilde |
25
|
|
|
|
|
|
|
Auml => 'Ä', # capital A, dieresis or umlaut mark |
26
|
|
|
|
|
|
|
Ccedil => 'Ç', # capital C, cedilla |
27
|
|
|
|
|
|
|
ETH => 'Ð', # capital Eth, Icelandic |
28
|
|
|
|
|
|
|
Eacute => 'É', # capital E, acute accent |
29
|
|
|
|
|
|
|
Ecirc => 'Ê', # capital E, circumflex accent |
30
|
|
|
|
|
|
|
Egrave => 'È', # capital E, grave accent |
31
|
|
|
|
|
|
|
Euml => 'Ë', # capital E, dieresis or umlaut mark |
32
|
|
|
|
|
|
|
Iacute => 'Í', # capital I, acute accent |
33
|
|
|
|
|
|
|
Icirc => 'Î', # capital I, circumflex accent |
34
|
|
|
|
|
|
|
Igrave => 'Ì', # capital I, grave accent |
35
|
|
|
|
|
|
|
Iuml => 'Ï', # capital I, dieresis or umlaut mark |
36
|
|
|
|
|
|
|
Ntilde => 'Ñ', # capital N, tilde |
37
|
|
|
|
|
|
|
Oacute => 'Ó', # capital O, acute accent |
38
|
|
|
|
|
|
|
Ocirc => 'Ô', # capital O, circumflex accent |
39
|
|
|
|
|
|
|
Ograve => 'Ò', # capital O, grave accent |
40
|
|
|
|
|
|
|
Oslash => 'Ø', # capital O, slash |
41
|
|
|
|
|
|
|
Otilde => 'Õ', # capital O, tilde |
42
|
|
|
|
|
|
|
Ouml => 'Ö', # capital O, dieresis or umlaut mark |
43
|
|
|
|
|
|
|
THORN => 'Þ', # capital THORN, Icelandic |
44
|
|
|
|
|
|
|
Uacute => 'Ú', # capital U, acute accent |
45
|
|
|
|
|
|
|
Ucirc => 'Û', # capital U, circumflex accent |
46
|
|
|
|
|
|
|
Ugrave => 'Ù', # capital U, grave accent |
47
|
|
|
|
|
|
|
Uuml => 'Ü', # capital U, dieresis or umlaut mark |
48
|
|
|
|
|
|
|
Yacute => 'Ý', # capital Y, acute accent |
49
|
|
|
|
|
|
|
aacute => 'á', # small a, acute accent |
50
|
|
|
|
|
|
|
acirc => 'â', # small a, circumflex accent |
51
|
|
|
|
|
|
|
aelig => 'æ', # small ae diphthong (ligature) |
52
|
|
|
|
|
|
|
agrave => 'à', # small a, grave accent |
53
|
|
|
|
|
|
|
aring => 'å', # small a, ring |
54
|
|
|
|
|
|
|
atilde => 'ã', # small a, tilde |
55
|
|
|
|
|
|
|
auml => 'ä', # small a, dieresis or umlaut mark |
56
|
|
|
|
|
|
|
ccedil => 'ç', # small c, cedilla |
57
|
|
|
|
|
|
|
eacute => 'é', # small e, acute accent |
58
|
|
|
|
|
|
|
ecirc => 'ê', # small e, circumflex accent |
59
|
|
|
|
|
|
|
egrave => 'è', # small e, grave accent |
60
|
|
|
|
|
|
|
eth => 'ð', # small eth, Icelandic |
61
|
|
|
|
|
|
|
euml => 'ë', # small e, dieresis or umlaut mark |
62
|
|
|
|
|
|
|
iacute => 'í', # small i, acute accent |
63
|
|
|
|
|
|
|
icirc => 'î', # small i, circumflex accent |
64
|
|
|
|
|
|
|
igrave => 'ì', # small i, grave accent |
65
|
|
|
|
|
|
|
iuml => 'ï', # small i, dieresis or umlaut mark |
66
|
|
|
|
|
|
|
ntilde => 'ñ', # small n, tilde |
67
|
|
|
|
|
|
|
oacute => 'ó', # small o, acute accent |
68
|
|
|
|
|
|
|
ocirc => 'ô', # small o, circumflex accent |
69
|
|
|
|
|
|
|
ograve => 'ò', # small o, grave accent |
70
|
|
|
|
|
|
|
oslash => 'ø', # small o, slash |
71
|
|
|
|
|
|
|
otilde => 'õ', # small o, tilde |
72
|
|
|
|
|
|
|
ouml => 'ö', # small o, dieresis or umlaut mark |
73
|
|
|
|
|
|
|
szlig => 'ß', # small sharp s, German (sz ligature) |
74
|
|
|
|
|
|
|
thorn => 'þ', # small thorn, Icelandic |
75
|
|
|
|
|
|
|
uacute => 'ú', # small u, acute accent |
76
|
|
|
|
|
|
|
ucirc => 'û', # small u, circumflex accent |
77
|
|
|
|
|
|
|
ugrave => 'ù', # small u, grave accent |
78
|
|
|
|
|
|
|
uuml => 'ü', # small u, dieresis or umlaut mark |
79
|
|
|
|
|
|
|
yacute => 'ý', # small y, acute accent |
80
|
|
|
|
|
|
|
yuml => 'ÿ', # small y, dieresis or umlaut mark |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Some extra Latin 1 chars that are listed in the HTML3.2 draft (21-May-96) |
83
|
|
|
|
|
|
|
copy => '©', # copyright sign |
84
|
|
|
|
|
|
|
reg => '®', # registered sign |
85
|
|
|
|
|
|
|
nbsp => "\240", # non breaking space |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Additional ISO-8859/1 entities listed in rfc1866 (section 14) |
88
|
|
|
|
|
|
|
iexcl => '¡', |
89
|
|
|
|
|
|
|
cent => '¢', |
90
|
|
|
|
|
|
|
pound => '£', |
91
|
|
|
|
|
|
|
curren => '¤', |
92
|
|
|
|
|
|
|
yen => '¥', |
93
|
|
|
|
|
|
|
brvbar => '¦', |
94
|
|
|
|
|
|
|
sect => '§', |
95
|
|
|
|
|
|
|
uml => '¨', |
96
|
|
|
|
|
|
|
ordf => 'ª', |
97
|
|
|
|
|
|
|
laquo => '«', |
98
|
|
|
|
|
|
|
'not' => '¬', # not is a keyword in perl |
99
|
|
|
|
|
|
|
shy => '', |
100
|
|
|
|
|
|
|
macr => '¯', |
101
|
|
|
|
|
|
|
deg => '°', |
102
|
|
|
|
|
|
|
plusmn => '±', |
103
|
|
|
|
|
|
|
sup1 => '¹', |
104
|
|
|
|
|
|
|
sup2 => '²', |
105
|
|
|
|
|
|
|
sup3 => '³', |
106
|
|
|
|
|
|
|
acute => '´', |
107
|
|
|
|
|
|
|
micro => 'µ', |
108
|
|
|
|
|
|
|
para => '¶', |
109
|
|
|
|
|
|
|
middot => '·', |
110
|
|
|
|
|
|
|
cedil => '¸', |
111
|
|
|
|
|
|
|
ordm => 'º', |
112
|
|
|
|
|
|
|
raquo => '»', |
113
|
|
|
|
|
|
|
frac14 => '¼', |
114
|
|
|
|
|
|
|
frac12 => '½', |
115
|
|
|
|
|
|
|
frac34 => '¾', |
116
|
|
|
|
|
|
|
iquest => '¿', |
117
|
|
|
|
|
|
|
'times' => '×', # times is a keyword in perl |
118
|
|
|
|
|
|
|
divide => '÷', |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
OElig => chr(338), |
121
|
|
|
|
|
|
|
oelig => chr(339), |
122
|
|
|
|
|
|
|
Scaron => chr(352), |
123
|
|
|
|
|
|
|
scaron => chr(353), |
124
|
|
|
|
|
|
|
Yuml => chr(376), |
125
|
|
|
|
|
|
|
fnof => chr(402), |
126
|
|
|
|
|
|
|
circ => chr(710), |
127
|
|
|
|
|
|
|
tilde => chr(732), |
128
|
|
|
|
|
|
|
Alpha => chr(913), |
129
|
|
|
|
|
|
|
Beta => chr(914), |
130
|
|
|
|
|
|
|
Gamma => chr(915), |
131
|
|
|
|
|
|
|
Delta => chr(916), |
132
|
|
|
|
|
|
|
Epsilon => chr(917), |
133
|
|
|
|
|
|
|
Zeta => chr(918), |
134
|
|
|
|
|
|
|
Eta => chr(919), |
135
|
|
|
|
|
|
|
Theta => chr(920), |
136
|
|
|
|
|
|
|
Iota => chr(921), |
137
|
|
|
|
|
|
|
Kappa => chr(922), |
138
|
|
|
|
|
|
|
Lambda => chr(923), |
139
|
|
|
|
|
|
|
Mu => chr(924), |
140
|
|
|
|
|
|
|
Nu => chr(925), |
141
|
|
|
|
|
|
|
Xi => chr(926), |
142
|
|
|
|
|
|
|
Omicron => chr(927), |
143
|
|
|
|
|
|
|
Pi => chr(928), |
144
|
|
|
|
|
|
|
Rho => chr(929), |
145
|
|
|
|
|
|
|
Sigma => chr(931), |
146
|
|
|
|
|
|
|
Tau => chr(932), |
147
|
|
|
|
|
|
|
Upsilon => chr(933), |
148
|
|
|
|
|
|
|
Phi => chr(934), |
149
|
|
|
|
|
|
|
Chi => chr(935), |
150
|
|
|
|
|
|
|
Psi => chr(936), |
151
|
|
|
|
|
|
|
Omega => chr(937), |
152
|
|
|
|
|
|
|
alpha => chr(945), |
153
|
|
|
|
|
|
|
beta => chr(946), |
154
|
|
|
|
|
|
|
gamma => chr(947), |
155
|
|
|
|
|
|
|
delta => chr(948), |
156
|
|
|
|
|
|
|
epsilon => chr(949), |
157
|
|
|
|
|
|
|
zeta => chr(950), |
158
|
|
|
|
|
|
|
eta => chr(951), |
159
|
|
|
|
|
|
|
theta => chr(952), |
160
|
|
|
|
|
|
|
iota => chr(953), |
161
|
|
|
|
|
|
|
kappa => chr(954), |
162
|
|
|
|
|
|
|
lambda => chr(955), |
163
|
|
|
|
|
|
|
mu => chr(956), |
164
|
|
|
|
|
|
|
nu => chr(957), |
165
|
|
|
|
|
|
|
xi => chr(958), |
166
|
|
|
|
|
|
|
omicron => chr(959), |
167
|
|
|
|
|
|
|
pi => chr(960), |
168
|
|
|
|
|
|
|
rho => chr(961), |
169
|
|
|
|
|
|
|
sigmaf => chr(962), |
170
|
|
|
|
|
|
|
sigma => chr(963), |
171
|
|
|
|
|
|
|
tau => chr(964), |
172
|
|
|
|
|
|
|
upsilon => chr(965), |
173
|
|
|
|
|
|
|
phi => chr(966), |
174
|
|
|
|
|
|
|
chi => chr(967), |
175
|
|
|
|
|
|
|
psi => chr(968), |
176
|
|
|
|
|
|
|
omega => chr(969), |
177
|
|
|
|
|
|
|
thetasym => chr(977), |
178
|
|
|
|
|
|
|
upsih => chr(978), |
179
|
|
|
|
|
|
|
piv => chr(982), |
180
|
|
|
|
|
|
|
ensp => chr(8194), |
181
|
|
|
|
|
|
|
emsp => chr(8195), |
182
|
|
|
|
|
|
|
thinsp => chr(8201), |
183
|
|
|
|
|
|
|
zwnj => chr(8204), |
184
|
|
|
|
|
|
|
zwj => chr(8205), |
185
|
|
|
|
|
|
|
lrm => chr(8206), |
186
|
|
|
|
|
|
|
rlm => chr(8207), |
187
|
|
|
|
|
|
|
ndash => chr(8211), |
188
|
|
|
|
|
|
|
mdash => chr(8212), |
189
|
|
|
|
|
|
|
lsquo => chr(8216), |
190
|
|
|
|
|
|
|
rsquo => chr(8217), |
191
|
|
|
|
|
|
|
sbquo => chr(8218), |
192
|
|
|
|
|
|
|
ldquo => chr(8220), |
193
|
|
|
|
|
|
|
rdquo => chr(8221), |
194
|
|
|
|
|
|
|
bdquo => chr(8222), |
195
|
|
|
|
|
|
|
dagger => chr(8224), |
196
|
|
|
|
|
|
|
Dagger => chr(8225), |
197
|
|
|
|
|
|
|
bull => chr(8226), |
198
|
|
|
|
|
|
|
hellip => chr(8230), |
199
|
|
|
|
|
|
|
permil => chr(8240), |
200
|
|
|
|
|
|
|
prime => chr(8242), |
201
|
|
|
|
|
|
|
Prime => chr(8243), |
202
|
|
|
|
|
|
|
lsaquo => chr(8249), |
203
|
|
|
|
|
|
|
rsaquo => chr(8250), |
204
|
|
|
|
|
|
|
oline => chr(8254), |
205
|
|
|
|
|
|
|
frasl => chr(8260), |
206
|
|
|
|
|
|
|
euro => chr(8364), |
207
|
|
|
|
|
|
|
image => chr(8465), |
208
|
|
|
|
|
|
|
weierp => chr(8472), |
209
|
|
|
|
|
|
|
real => chr(8476), |
210
|
|
|
|
|
|
|
trade => chr(8482), |
211
|
|
|
|
|
|
|
alefsym => chr(8501), |
212
|
|
|
|
|
|
|
larr => chr(8592), |
213
|
|
|
|
|
|
|
uarr => chr(8593), |
214
|
|
|
|
|
|
|
rarr => chr(8594), |
215
|
|
|
|
|
|
|
darr => chr(8595), |
216
|
|
|
|
|
|
|
harr => chr(8596), |
217
|
|
|
|
|
|
|
crarr => chr(8629), |
218
|
|
|
|
|
|
|
lArr => chr(8656), |
219
|
|
|
|
|
|
|
uArr => chr(8657), |
220
|
|
|
|
|
|
|
rArr => chr(8658), |
221
|
|
|
|
|
|
|
dArr => chr(8659), |
222
|
|
|
|
|
|
|
hArr => chr(8660), |
223
|
|
|
|
|
|
|
forall => chr(8704), |
224
|
|
|
|
|
|
|
part => chr(8706), |
225
|
|
|
|
|
|
|
exist => chr(8707), |
226
|
|
|
|
|
|
|
empty => chr(8709), |
227
|
|
|
|
|
|
|
nabla => chr(8711), |
228
|
|
|
|
|
|
|
isin => chr(8712), |
229
|
|
|
|
|
|
|
notin => chr(8713), |
230
|
|
|
|
|
|
|
ni => chr(8715), |
231
|
|
|
|
|
|
|
prod => chr(8719), |
232
|
|
|
|
|
|
|
sum => chr(8721), |
233
|
|
|
|
|
|
|
minus => chr(8722), |
234
|
|
|
|
|
|
|
lowast => chr(8727), |
235
|
|
|
|
|
|
|
radic => chr(8730), |
236
|
|
|
|
|
|
|
prop => chr(8733), |
237
|
|
|
|
|
|
|
infin => chr(8734), |
238
|
|
|
|
|
|
|
ang => chr(8736), |
239
|
|
|
|
|
|
|
'and' => chr(8743), |
240
|
|
|
|
|
|
|
'or' => chr(8744), |
241
|
|
|
|
|
|
|
cap => chr(8745), |
242
|
|
|
|
|
|
|
cup => chr(8746), |
243
|
|
|
|
|
|
|
'int' => chr(8747), |
244
|
|
|
|
|
|
|
there4 => chr(8756), |
245
|
|
|
|
|
|
|
sim => chr(8764), |
246
|
|
|
|
|
|
|
cong => chr(8773), |
247
|
|
|
|
|
|
|
asymp => chr(8776), |
248
|
|
|
|
|
|
|
'ne' => chr(8800), |
249
|
|
|
|
|
|
|
equiv => chr(8801), |
250
|
|
|
|
|
|
|
'le' => chr(8804), |
251
|
|
|
|
|
|
|
'ge' => chr(8805), |
252
|
|
|
|
|
|
|
'sub' => chr(8834), |
253
|
|
|
|
|
|
|
sup => chr(8835), |
254
|
|
|
|
|
|
|
nsub => chr(8836), |
255
|
|
|
|
|
|
|
sube => chr(8838), |
256
|
|
|
|
|
|
|
supe => chr(8839), |
257
|
|
|
|
|
|
|
oplus => chr(8853), |
258
|
|
|
|
|
|
|
otimes => chr(8855), |
259
|
|
|
|
|
|
|
perp => chr(8869), |
260
|
|
|
|
|
|
|
sdot => chr(8901), |
261
|
|
|
|
|
|
|
lceil => chr(8968), |
262
|
|
|
|
|
|
|
rceil => chr(8969), |
263
|
|
|
|
|
|
|
lfloor => chr(8970), |
264
|
|
|
|
|
|
|
rfloor => chr(8971), |
265
|
|
|
|
|
|
|
lang => chr(9001), |
266
|
|
|
|
|
|
|
rang => chr(9002), |
267
|
|
|
|
|
|
|
loz => chr(9674), |
268
|
|
|
|
|
|
|
spades => chr(9824), |
269
|
|
|
|
|
|
|
clubs => chr(9827), |
270
|
|
|
|
|
|
|
hearts => chr(9829), |
271
|
|
|
|
|
|
|
diams => chr(9830), |
272
|
|
|
|
|
|
|
); |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
my %subst; # compiled encoding regexps |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
sub decode_entities |
279
|
|
|
|
|
|
|
{ |
280
|
0
|
|
|
0
|
0
|
|
my $array = \@_; # modify in-place |
281
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
|
my $c; |
283
|
0
|
|
|
|
|
|
for (@$array) { |
284
|
0
|
0
|
|
|
|
|
s/(&\#(\d+);?)/$2 < 256 ? chr($2) : $1/eg; |
|
0
|
|
|
|
|
|
|
285
|
0
|
0
|
|
|
|
|
s/(&\#[xX]([0-9a-fA-F]+);?)/$c = hex($2); $c < 256 ? chr($c) : $1/eg; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
286
|
0
|
0
|
|
|
|
|
s/(&(\w+);?)/$ENTITY_2_CHAR{$2} || $1/eg; |
|
0
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
} |
288
|
0
|
0
|
|
|
|
|
wantarray ? @$array : $array->[0]; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
1; |