| 2 |
use strict; |
use strict; |
| 3 |
our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
| 4 |
|
|
| 5 |
## This is an early version of an HTML parser. |
## ISSUE: |
| 6 |
|
## var doc = implementation.createDocument (null, null, null); |
| 7 |
|
## doc.write (''); |
| 8 |
|
## alert (doc.compatMode); |
| 9 |
|
|
| 10 |
my $permitted_slash_tag_name = { |
my $permitted_slash_tag_name = { |
| 11 |
base => 1, |
base => 1, |
| 158 |
# $self->{next_input_character} |
# $self->{next_input_character} |
| 159 |
!!!next-input-character; |
!!!next-input-character; |
| 160 |
$self->{token} = []; |
$self->{token} = []; |
| 161 |
|
# $self->{escape} |
| 162 |
} # _initialize_tokenizer |
} # _initialize_tokenizer |
| 163 |
|
|
| 164 |
## A token has: |
## A token has: |
| 165 |
## ->{type} eq 'DOCTYPE', 'start tag', 'end tag', 'comment', |
## ->{type} eq 'DOCTYPE', 'start tag', 'end tag', 'comment', |
| 166 |
## 'character', or 'end-of-file' |
## 'character', or 'end-of-file' |
| 167 |
## ->{name} (DOCTYPE, start tag (tagname), end tag (tagname)) |
## ->{name} (DOCTYPE, start tag (tag name), end tag (tag name)) |
| 168 |
## ISSUE: the spec need s/tagname/tag name/ |
## ->{public_identifier} (DOCTYPE) |
| 169 |
## ->{error} == 1 or 0 (DOCTYPE) |
## ->{system_identifier} (DOCTYPE) |
| 170 |
|
## ->{correct} == 1 or 0 (DOCTYPE) |
| 171 |
## ->{attributes} isa HASH (start tag, end tag) |
## ->{attributes} isa HASH (start tag, end tag) |
| 172 |
## ->{data} (comment, character) |
## ->{data} (comment, character) |
| 173 |
|
|
|
## Macros |
|
|
## Macros MUST be preceded by three EXCLAMATION MARKs. |
|
|
## emit ($token) |
|
|
## Emits the specified token. |
|
|
|
|
| 174 |
## Emitted token MUST immediately be handled by the tree construction state. |
## Emitted token MUST immediately be handled by the tree construction state. |
| 175 |
|
|
| 176 |
## Before each step, UA MAY check to see if either one of the scripts in |
## Before each step, UA MAY check to see if either one of the scripts in |
| 335 |
!!!next-input-character; |
!!!next-input-character; |
| 336 |
next TAGNAME; |
next TAGNAME; |
| 337 |
} else { |
} else { |
|
!!!parse-error (type => 'unmatched end tag'); |
|
| 338 |
$self->{next_input_character} = shift @next_char; # reconsume |
$self->{next_input_character} = shift @next_char; # reconsume |
| 339 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 340 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 354 |
$self->{next_input_character} == 0x003E or # > |
$self->{next_input_character} == 0x003E or # > |
| 355 |
$self->{next_input_character} == 0x002F or # / |
$self->{next_input_character} == 0x002F or # / |
| 356 |
$self->{next_input_character} == -1) { |
$self->{next_input_character} == -1) { |
|
!!!parse-error (type => 'unmatched end tag'); |
|
| 357 |
$self->{next_input_character} = shift @next_char; # reconsume |
$self->{next_input_character} = shift @next_char; # reconsume |
| 358 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 359 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 1101 |
## Stay in the state |
## Stay in the state |
| 1102 |
!!!next-input-character; |
!!!next-input-character; |
| 1103 |
redo A; |
redo A; |
|
} elsif (0x0061 <= $self->{next_input_character} and |
|
|
$self->{next_input_character} <= 0x007A) { # a..z |
|
|
## ISSUE: "Set the token's name name to the" in the spec |
|
|
$self->{current_token} = {type => 'DOCTYPE', |
|
|
name => chr ($self->{next_input_character} - 0x0020), |
|
|
error => 1}; |
|
|
$self->{state} = 'DOCTYPE name'; |
|
|
!!!next-input-character; |
|
|
redo A; |
|
| 1104 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1105 |
!!!parse-error (type => 'no DOCTYPE name'); |
!!!parse-error (type => 'no DOCTYPE name'); |
| 1106 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 1107 |
!!!next-input-character; |
!!!next-input-character; |
| 1108 |
|
|
| 1109 |
!!!emit ({type => 'DOCTYPE', name => '', error => 1}); |
!!!emit ({type => 'DOCTYPE'}); # incorrect |
| 1110 |
|
|
| 1111 |
redo A; |
redo A; |
| 1112 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1114 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 1115 |
## reconsume |
## reconsume |
| 1116 |
|
|
| 1117 |
!!!emit ({type => 'DOCTYPE', name => '', error => 1}); |
!!!emit ({type => 'DOCTYPE'}); # incorrect |
| 1118 |
|
|
| 1119 |
redo A; |
redo A; |
| 1120 |
} else { |
} else { |
| 1121 |
$self->{current_token} = {type => 'DOCTYPE', |
$self->{current_token} |
| 1122 |
name => chr ($self->{next_input_character}), |
= {type => 'DOCTYPE', |
| 1123 |
error => 1}; |
name => chr ($self->{next_input_character}), |
| 1124 |
|
correct => 1}; |
| 1125 |
## ISSUE: "Set the token's name name to the" in the spec |
## ISSUE: "Set the token's name name to the" in the spec |
| 1126 |
$self->{state} = 'DOCTYPE name'; |
$self->{state} = 'DOCTYPE name'; |
| 1127 |
!!!next-input-character; |
!!!next-input-character; |
| 1128 |
redo A; |
redo A; |
| 1129 |
} |
} |
| 1130 |
} elsif ($self->{state} eq 'DOCTYPE name') { |
} elsif ($self->{state} eq 'DOCTYPE name') { |
| 1131 |
|
## ISSUE: Redundant "First," in the spec. |
| 1132 |
if ($self->{next_input_character} == 0x0009 or # HT |
if ($self->{next_input_character} == 0x0009 or # HT |
| 1133 |
$self->{next_input_character} == 0x000A or # LF |
$self->{next_input_character} == 0x000A or # LF |
| 1134 |
$self->{next_input_character} == 0x000B or # VT |
$self->{next_input_character} == 0x000B or # VT |
| 1135 |
$self->{next_input_character} == 0x000C or # FF |
$self->{next_input_character} == 0x000C or # FF |
| 1136 |
$self->{next_input_character} == 0x0020) { # SP |
$self->{next_input_character} == 0x0020) { # SP |
|
$self->{current_token}->{error} = ($self->{current_token}->{name} ne 'HTML'); # DOCTYPE |
|
| 1137 |
$self->{state} = 'after DOCTYPE name'; |
$self->{state} = 'after DOCTYPE name'; |
| 1138 |
!!!next-input-character; |
!!!next-input-character; |
| 1139 |
redo A; |
redo A; |
| 1140 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
|
$self->{current_token}->{error} = ($self->{current_token}->{name} ne 'HTML'); # DOCTYPE |
|
| 1141 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 1142 |
!!!next-input-character; |
!!!next-input-character; |
| 1143 |
|
|
| 1145 |
undef $self->{current_token}; |
undef $self->{current_token}; |
| 1146 |
|
|
| 1147 |
redo A; |
redo A; |
|
} elsif (0x0061 <= $self->{next_input_character} and |
|
|
$self->{next_input_character} <= 0x007A) { # a..z |
|
|
$self->{current_token}->{name} .= chr ($self->{next_input_character} - 0x0020); # DOCTYPE |
|
|
#$self->{current_token}->{error} = ($self->{current_token}->{name} ne 'HTML'); |
|
|
## Stay in the state |
|
|
!!!next-input-character; |
|
|
redo A; |
|
| 1148 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1149 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
|
$self->{current_token}->{error} = ($self->{current_token}->{name} ne 'HTML'); # DOCTYPE |
|
| 1150 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 1151 |
## reconsume |
## reconsume |
| 1152 |
|
|
| 1153 |
!!!emit ($self->{current_token}); |
delete $self->{current_token}->{correct}; |
| 1154 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1155 |
undef $self->{current_token}; |
undef $self->{current_token}; |
| 1156 |
|
|
| 1157 |
redo A; |
redo A; |
| 1158 |
} else { |
} else { |
| 1159 |
$self->{current_token}->{name} |
$self->{current_token}->{name} |
| 1160 |
.= chr ($self->{next_input_character}); # DOCTYPE |
.= chr ($self->{next_input_character}); # DOCTYPE |
|
#$self->{current_token}->{error} = ($self->{current_token}->{name} ne 'HTML'); |
|
| 1161 |
## Stay in the state |
## Stay in the state |
| 1162 |
!!!next-input-character; |
!!!next-input-character; |
| 1163 |
redo A; |
redo A; |
| 1184 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 1185 |
## reconsume |
## reconsume |
| 1186 |
|
|
| 1187 |
|
delete $self->{current_token}->{correct}; |
| 1188 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1189 |
|
undef $self->{current_token}; |
| 1190 |
|
|
| 1191 |
|
redo A; |
| 1192 |
|
} elsif ($self->{next_input_character} == 0x0050 or # P |
| 1193 |
|
$self->{next_input_character} == 0x0070) { # p |
| 1194 |
|
!!!next-input-character; |
| 1195 |
|
if ($self->{next_input_character} == 0x0055 or # U |
| 1196 |
|
$self->{next_input_character} == 0x0075) { # u |
| 1197 |
|
!!!next-input-character; |
| 1198 |
|
if ($self->{next_input_character} == 0x0042 or # B |
| 1199 |
|
$self->{next_input_character} == 0x0062) { # b |
| 1200 |
|
!!!next-input-character; |
| 1201 |
|
if ($self->{next_input_character} == 0x004C or # L |
| 1202 |
|
$self->{next_input_character} == 0x006C) { # l |
| 1203 |
|
!!!next-input-character; |
| 1204 |
|
if ($self->{next_input_character} == 0x0049 or # I |
| 1205 |
|
$self->{next_input_character} == 0x0069) { # i |
| 1206 |
|
!!!next-input-character; |
| 1207 |
|
if ($self->{next_input_character} == 0x0043 or # C |
| 1208 |
|
$self->{next_input_character} == 0x0063) { # c |
| 1209 |
|
$self->{state} = 'before DOCTYPE public identifier'; |
| 1210 |
|
!!!next-input-character; |
| 1211 |
|
redo A; |
| 1212 |
|
} |
| 1213 |
|
} |
| 1214 |
|
} |
| 1215 |
|
} |
| 1216 |
|
} |
| 1217 |
|
|
| 1218 |
|
# |
| 1219 |
|
} elsif ($self->{next_input_character} == 0x0053 or # S |
| 1220 |
|
$self->{next_input_character} == 0x0073) { # s |
| 1221 |
|
!!!next-input-character; |
| 1222 |
|
if ($self->{next_input_character} == 0x0059 or # Y |
| 1223 |
|
$self->{next_input_character} == 0x0079) { # y |
| 1224 |
|
!!!next-input-character; |
| 1225 |
|
if ($self->{next_input_character} == 0x0053 or # S |
| 1226 |
|
$self->{next_input_character} == 0x0073) { # s |
| 1227 |
|
!!!next-input-character; |
| 1228 |
|
if ($self->{next_input_character} == 0x0054 or # T |
| 1229 |
|
$self->{next_input_character} == 0x0074) { # t |
| 1230 |
|
!!!next-input-character; |
| 1231 |
|
if ($self->{next_input_character} == 0x0045 or # E |
| 1232 |
|
$self->{next_input_character} == 0x0065) { # e |
| 1233 |
|
!!!next-input-character; |
| 1234 |
|
if ($self->{next_input_character} == 0x004D or # M |
| 1235 |
|
$self->{next_input_character} == 0x006D) { # m |
| 1236 |
|
$self->{state} = 'before DOCTYPE system identifier'; |
| 1237 |
|
!!!next-input-character; |
| 1238 |
|
redo A; |
| 1239 |
|
} |
| 1240 |
|
} |
| 1241 |
|
} |
| 1242 |
|
} |
| 1243 |
|
} |
| 1244 |
|
|
| 1245 |
|
# |
| 1246 |
|
} else { |
| 1247 |
|
!!!next-input-character; |
| 1248 |
|
# |
| 1249 |
|
} |
| 1250 |
|
|
| 1251 |
|
!!!parse-error (type => 'string after DOCTYPE name'); |
| 1252 |
|
$self->{state} = 'bogus DOCTYPE'; |
| 1253 |
|
# next-input-character is already done |
| 1254 |
|
redo A; |
| 1255 |
|
} elsif ($self->{state} eq 'before DOCTYPE public identifier') { |
| 1256 |
|
if ({ |
| 1257 |
|
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 1258 |
|
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 1259 |
|
}->{$self->{next_input_character}}) { |
| 1260 |
|
## Stay in the state |
| 1261 |
|
!!!next-input-character; |
| 1262 |
|
redo A; |
| 1263 |
|
} elsif ($self->{next_input_character} eq 0x0022) { # " |
| 1264 |
|
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
| 1265 |
|
$self->{state} = 'DOCTYPE public identifier (double-quoted)'; |
| 1266 |
|
!!!next-input-character; |
| 1267 |
|
redo A; |
| 1268 |
|
} elsif ($self->{next_input_character} eq 0x0027) { # ' |
| 1269 |
|
$self->{current_token}->{public_identifier} = ''; # DOCTYPE |
| 1270 |
|
$self->{state} = 'DOCTYPE public identifier (single-quoted)'; |
| 1271 |
|
!!!next-input-character; |
| 1272 |
|
redo A; |
| 1273 |
|
} elsif ($self->{next_input_character} eq 0x003E) { # > |
| 1274 |
|
!!!parse-error (type => 'no PUBLIC literal'); |
| 1275 |
|
|
| 1276 |
|
$self->{state} = 'data'; |
| 1277 |
|
!!!next-input-character; |
| 1278 |
|
|
| 1279 |
|
delete $self->{current_token}->{correct}; |
| 1280 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1281 |
|
undef $self->{current_token}; |
| 1282 |
|
|
| 1283 |
|
redo A; |
| 1284 |
|
} elsif ($self->{next_input_character} == -1) { |
| 1285 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1286 |
|
|
| 1287 |
|
$self->{state} = 'data'; |
| 1288 |
|
## reconsume |
| 1289 |
|
|
| 1290 |
|
delete $self->{current_token}->{correct}; |
| 1291 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1292 |
undef $self->{current_token}; |
undef $self->{current_token}; |
| 1293 |
|
|
| 1294 |
redo A; |
redo A; |
| 1295 |
} else { |
} else { |
| 1296 |
!!!parse-error (type => 'string after DOCTYPE name'); |
!!!parse-error (type => 'string after PUBLIC'); |
| 1297 |
$self->{current_token}->{error} = 1; # DOCTYPE |
$self->{state} = 'bogus DOCTYPE'; |
| 1298 |
|
!!!next-input-character; |
| 1299 |
|
redo A; |
| 1300 |
|
} |
| 1301 |
|
} elsif ($self->{state} eq 'DOCTYPE public identifier (double-quoted)') { |
| 1302 |
|
if ($self->{next_input_character} == 0x0022) { # " |
| 1303 |
|
$self->{state} = 'after DOCTYPE public identifier'; |
| 1304 |
|
!!!next-input-character; |
| 1305 |
|
redo A; |
| 1306 |
|
} elsif ($self->{next_input_character} == -1) { |
| 1307 |
|
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1308 |
|
|
| 1309 |
|
$self->{state} = 'data'; |
| 1310 |
|
## reconsume |
| 1311 |
|
|
| 1312 |
|
delete $self->{current_token}->{correct}; |
| 1313 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1314 |
|
undef $self->{current_token}; |
| 1315 |
|
|
| 1316 |
|
redo A; |
| 1317 |
|
} else { |
| 1318 |
|
$self->{current_token}->{public_identifier} # DOCTYPE |
| 1319 |
|
.= chr $self->{next_input_character}; |
| 1320 |
|
## Stay in the state |
| 1321 |
|
!!!next-input-character; |
| 1322 |
|
redo A; |
| 1323 |
|
} |
| 1324 |
|
} elsif ($self->{state} eq 'DOCTYPE public identifier (single-quoted)') { |
| 1325 |
|
if ($self->{next_input_character} == 0x0027) { # ' |
| 1326 |
|
$self->{state} = 'after DOCTYPE public identifier'; |
| 1327 |
|
!!!next-input-character; |
| 1328 |
|
redo A; |
| 1329 |
|
} elsif ($self->{next_input_character} == -1) { |
| 1330 |
|
!!!parse-error (type => 'unclosed PUBLIC literal'); |
| 1331 |
|
|
| 1332 |
|
$self->{state} = 'data'; |
| 1333 |
|
## reconsume |
| 1334 |
|
|
| 1335 |
|
delete $self->{current_token}->{correct}; |
| 1336 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1337 |
|
undef $self->{current_token}; |
| 1338 |
|
|
| 1339 |
|
redo A; |
| 1340 |
|
} else { |
| 1341 |
|
$self->{current_token}->{public_identifier} # DOCTYPE |
| 1342 |
|
.= chr $self->{next_input_character}; |
| 1343 |
|
## Stay in the state |
| 1344 |
|
!!!next-input-character; |
| 1345 |
|
redo A; |
| 1346 |
|
} |
| 1347 |
|
} elsif ($self->{state} eq 'after DOCTYPE public identifier') { |
| 1348 |
|
if ({ |
| 1349 |
|
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 1350 |
|
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 1351 |
|
}->{$self->{next_input_character}}) { |
| 1352 |
|
## Stay in the state |
| 1353 |
|
!!!next-input-character; |
| 1354 |
|
redo A; |
| 1355 |
|
} elsif ($self->{next_input_character} == 0x0022) { # " |
| 1356 |
|
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 1357 |
|
$self->{state} = 'DOCTYPE system identifier (double-quoted)'; |
| 1358 |
|
!!!next-input-character; |
| 1359 |
|
redo A; |
| 1360 |
|
} elsif ($self->{next_input_character} == 0x0027) { # ' |
| 1361 |
|
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 1362 |
|
$self->{state} = 'DOCTYPE system identifier (single-quoted)'; |
| 1363 |
|
!!!next-input-character; |
| 1364 |
|
redo A; |
| 1365 |
|
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1366 |
|
$self->{state} = 'data'; |
| 1367 |
|
!!!next-input-character; |
| 1368 |
|
|
| 1369 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1370 |
|
undef $self->{current_token}; |
| 1371 |
|
|
| 1372 |
|
redo A; |
| 1373 |
|
} elsif ($self->{next_input_character} == -1) { |
| 1374 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1375 |
|
|
| 1376 |
|
$self->{state} = 'data'; |
| 1377 |
|
## recomsume |
| 1378 |
|
|
| 1379 |
|
delete $self->{current_token}->{correct}; |
| 1380 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1381 |
|
undef $self->{current_token}; |
| 1382 |
|
|
| 1383 |
|
redo A; |
| 1384 |
|
} else { |
| 1385 |
|
!!!parse-error (type => 'string after PUBLIC literal'); |
| 1386 |
|
$self->{state} = 'bogus DOCTYPE'; |
| 1387 |
|
!!!next-input-character; |
| 1388 |
|
redo A; |
| 1389 |
|
} |
| 1390 |
|
} elsif ($self->{state} eq 'before DOCTYPE system identifier') { |
| 1391 |
|
if ({ |
| 1392 |
|
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 1393 |
|
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 1394 |
|
}->{$self->{next_input_character}}) { |
| 1395 |
|
## Stay in the state |
| 1396 |
|
!!!next-input-character; |
| 1397 |
|
redo A; |
| 1398 |
|
} elsif ($self->{next_input_character} == 0x0022) { # " |
| 1399 |
|
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 1400 |
|
$self->{state} = 'DOCTYPE system identifier (double-quoted)'; |
| 1401 |
|
!!!next-input-character; |
| 1402 |
|
redo A; |
| 1403 |
|
} elsif ($self->{next_input_character} == 0x0027) { # ' |
| 1404 |
|
$self->{current_token}->{system_identifier} = ''; # DOCTYPE |
| 1405 |
|
$self->{state} = 'DOCTYPE system identifier (single-quoted)'; |
| 1406 |
|
!!!next-input-character; |
| 1407 |
|
redo A; |
| 1408 |
|
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1409 |
|
!!!parse-error (type => 'no SYSTEM literal'); |
| 1410 |
|
$self->{state} = 'data'; |
| 1411 |
|
!!!next-input-character; |
| 1412 |
|
|
| 1413 |
|
delete $self->{current_token}->{correct}; |
| 1414 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1415 |
|
undef $self->{current_token}; |
| 1416 |
|
|
| 1417 |
|
redo A; |
| 1418 |
|
} elsif ($self->{next_input_character} == -1) { |
| 1419 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1420 |
|
|
| 1421 |
|
$self->{state} = 'data'; |
| 1422 |
|
## recomsume |
| 1423 |
|
|
| 1424 |
|
delete $self->{current_token}->{correct}; |
| 1425 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1426 |
|
undef $self->{current_token}; |
| 1427 |
|
|
| 1428 |
|
redo A; |
| 1429 |
|
} else { |
| 1430 |
|
!!!parse-error (type => 'string after PUBLIC literal'); |
| 1431 |
|
$self->{state} = 'bogus DOCTYPE'; |
| 1432 |
|
!!!next-input-character; |
| 1433 |
|
redo A; |
| 1434 |
|
} |
| 1435 |
|
} elsif ($self->{state} eq 'DOCTYPE system identifier (double-quoted)') { |
| 1436 |
|
if ($self->{next_input_character} == 0x0022) { # " |
| 1437 |
|
$self->{state} = 'after DOCTYPE system identifier'; |
| 1438 |
|
!!!next-input-character; |
| 1439 |
|
redo A; |
| 1440 |
|
} elsif ($self->{next_input_character} == -1) { |
| 1441 |
|
!!!parse-error (type => 'unclosed SYSTEM literal'); |
| 1442 |
|
|
| 1443 |
|
$self->{state} = 'data'; |
| 1444 |
|
## reconsume |
| 1445 |
|
|
| 1446 |
|
delete $self->{current_token}->{correct}; |
| 1447 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1448 |
|
undef $self->{current_token}; |
| 1449 |
|
|
| 1450 |
|
redo A; |
| 1451 |
|
} else { |
| 1452 |
|
$self->{current_token}->{system_identifier} # DOCTYPE |
| 1453 |
|
.= chr $self->{next_input_character}; |
| 1454 |
|
## Stay in the state |
| 1455 |
|
!!!next-input-character; |
| 1456 |
|
redo A; |
| 1457 |
|
} |
| 1458 |
|
} elsif ($self->{state} eq 'DOCTYPE system identifier (single-quoted)') { |
| 1459 |
|
if ($self->{next_input_character} == 0x0027) { # ' |
| 1460 |
|
$self->{state} = 'after DOCTYPE system identifier'; |
| 1461 |
|
!!!next-input-character; |
| 1462 |
|
redo A; |
| 1463 |
|
} elsif ($self->{next_input_character} == -1) { |
| 1464 |
|
!!!parse-error (type => 'unclosed SYSTEM literal'); |
| 1465 |
|
|
| 1466 |
|
$self->{state} = 'data'; |
| 1467 |
|
## reconsume |
| 1468 |
|
|
| 1469 |
|
delete $self->{current_token}->{correct}; |
| 1470 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1471 |
|
undef $self->{current_token}; |
| 1472 |
|
|
| 1473 |
|
redo A; |
| 1474 |
|
} else { |
| 1475 |
|
$self->{current_token}->{system_identifier} # DOCTYPE |
| 1476 |
|
.= chr $self->{next_input_character}; |
| 1477 |
|
## Stay in the state |
| 1478 |
|
!!!next-input-character; |
| 1479 |
|
redo A; |
| 1480 |
|
} |
| 1481 |
|
} elsif ($self->{state} eq 'after DOCTYPE system identifier') { |
| 1482 |
|
if ({ |
| 1483 |
|
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, 0x0020 => 1, |
| 1484 |
|
#0x000D => 1, # HT, LF, VT, FF, SP, CR |
| 1485 |
|
}->{$self->{next_input_character}}) { |
| 1486 |
|
## Stay in the state |
| 1487 |
|
!!!next-input-character; |
| 1488 |
|
redo A; |
| 1489 |
|
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1490 |
|
$self->{state} = 'data'; |
| 1491 |
|
!!!next-input-character; |
| 1492 |
|
|
| 1493 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1494 |
|
undef $self->{current_token}; |
| 1495 |
|
|
| 1496 |
|
redo A; |
| 1497 |
|
} elsif ($self->{next_input_character} == -1) { |
| 1498 |
|
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1499 |
|
|
| 1500 |
|
$self->{state} = 'data'; |
| 1501 |
|
## recomsume |
| 1502 |
|
|
| 1503 |
|
delete $self->{current_token}->{correct}; |
| 1504 |
|
!!!emit ($self->{current_token}); # DOCTYPE |
| 1505 |
|
undef $self->{current_token}; |
| 1506 |
|
|
| 1507 |
|
redo A; |
| 1508 |
|
} else { |
| 1509 |
|
!!!parse-error (type => 'string after SYSTEM literal'); |
| 1510 |
$self->{state} = 'bogus DOCTYPE'; |
$self->{state} = 'bogus DOCTYPE'; |
| 1511 |
!!!next-input-character; |
!!!next-input-character; |
| 1512 |
redo A; |
redo A; |
| 1516 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 1517 |
!!!next-input-character; |
!!!next-input-character; |
| 1518 |
|
|
| 1519 |
|
delete $self->{current_token}->{correct}; |
| 1520 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1521 |
undef $self->{current_token}; |
undef $self->{current_token}; |
| 1522 |
|
|
| 1526 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 1527 |
## reconsume |
## reconsume |
| 1528 |
|
|
| 1529 |
|
delete $self->{current_token}->{correct}; |
| 1530 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1531 |
undef $self->{current_token}; |
undef $self->{current_token}; |
| 1532 |
|
|
| 1546 |
|
|
| 1547 |
sub _tokenize_attempt_to_consume_an_entity ($) { |
sub _tokenize_attempt_to_consume_an_entity ($) { |
| 1548 |
my $self = shift; |
my $self = shift; |
| 1549 |
|
|
| 1550 |
if ($self->{next_input_character} == 0x0023) { # # |
if ({ |
| 1551 |
|
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
| 1552 |
|
0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & # 0x000D # CR |
| 1553 |
|
}->{$self->{next_input_character}}) { |
| 1554 |
|
## Don't consume |
| 1555 |
|
## No error |
| 1556 |
|
return undef; |
| 1557 |
|
} elsif ($self->{next_input_character} == 0x0023) { # # |
| 1558 |
!!!next-input-character; |
!!!next-input-character; |
| 1559 |
if ($self->{next_input_character} == 0x0078 or # x |
if ($self->{next_input_character} == 0x0078 or # x |
| 1560 |
$self->{next_input_character} == 0x0058) { # X |
$self->{next_input_character} == 0x0058) { # X |
| 1701 |
$self->{document}->strict_error_checking (0); |
$self->{document}->strict_error_checking (0); |
| 1702 |
## TODO: Turn mutation events off # MUST |
## TODO: Turn mutation events off # MUST |
| 1703 |
## TODO: Turn loose Document option (manakai extension) on |
## TODO: Turn loose Document option (manakai extension) on |
| 1704 |
## TODO: Mark the Document as an HTML document # MUST |
$self->{document}->manakai_is_html (1); # MUST |
| 1705 |
} # _initialize_tree_constructor |
} # _initialize_tree_constructor |
| 1706 |
|
|
| 1707 |
sub _terminate_tree_constructor ($) { |
sub _terminate_tree_constructor ($) { |
| 1741 |
|
|
| 1742 |
sub _tree_construction_initial ($) { |
sub _tree_construction_initial ($) { |
| 1743 |
my $self = shift; |
my $self = shift; |
| 1744 |
B: { |
INITIAL: { |
| 1745 |
if ($token->{type} eq 'DOCTYPE') { |
if ($token->{type} eq 'DOCTYPE') { |
| 1746 |
if ($token->{error}) { |
## NOTE: Conformance checkers MAY, instead of reporting "not HTML5" |
| 1747 |
## ISSUE: Spec currently left this case undefined. |
## error, switch to a conformance checking mode for another |
| 1748 |
!!!parse-error (type => 'bogus DOCTYPE'); |
## language. |
| 1749 |
} |
my $doctype_name = $token->{name}; |
| 1750 |
my $doctype = $self->{document}->create_document_type_definition |
$doctype_name = '' unless defined $doctype_name; |
| 1751 |
($token->{name}); |
$doctype_name =~ tr/a-z/A-Z/; |
| 1752 |
$self->{document}->append_child ($doctype); |
if (not defined $token->{name} or # <!DOCTYPE> |
| 1753 |
#$phase = 'root element'; |
defined $token->{public_identifier} or |
| 1754 |
!!!next-token; |
defined $token->{system_identifier}) { |
| 1755 |
#redo B; |
!!!parse-error (type => 'not HTML5'); |
| 1756 |
return; |
} elsif ($doctype_name ne 'HTML') { |
| 1757 |
} elsif ({ |
## ISSUE: ASCII case-insensitive? (in fact it does not matter) |
| 1758 |
comment => 1, |
!!!parse-error (type => 'not HTML5'); |
| 1759 |
'start tag' => 1, |
} |
| 1760 |
'end tag' => 1, |
|
| 1761 |
'end-of-file' => 1, |
my $doctype = $self->{document}->create_document_type_definition |
| 1762 |
}->{$token->{type}}) { |
($token->{name}); ## ISSUE: If name is missing (e.g. <!DOCTYPE>)? |
| 1763 |
## ISSUE: Spec currently left this case undefined. |
$doctype->public_id ($token->{public_identifier}) |
| 1764 |
!!!parse-error (type => 'missing DOCTYPE'); |
if defined $token->{public_identifier}; |
| 1765 |
#$phase = 'root element'; |
$doctype->system_id ($token->{system_identifier}) |
| 1766 |
## reprocess |
if defined $token->{system_identifier}; |
| 1767 |
#redo B; |
## NOTE: Other DocumentType attributes are null or empty lists. |
| 1768 |
return; |
## ISSUE: internalSubset = null?? |
| 1769 |
} elsif ($token->{type} eq 'character') { |
$self->{document}->append_child ($doctype); |
| 1770 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
|
| 1771 |
$self->{document}->manakai_append_text ($1); |
if (not $token->{correct} or $doctype_name ne 'HTML') { |
| 1772 |
## ISSUE: DOM3 Core does not allow Document > Text |
$self->{document}->manakai_compat_mode ('quirks'); |
| 1773 |
unless (length $token->{data}) { |
} elsif (defined $token->{public_identifier}) { |
| 1774 |
## Stay in the phase |
my $pubid = $token->{public_identifier}; |
| 1775 |
!!!next-token; |
$pubid =~ tr/a-z/A-z/; |
| 1776 |
redo B; |
if ({ |
| 1777 |
|
"+//SILMARIL//DTD HTML PRO V0R11 19970101//EN" => 1, |
| 1778 |
|
"-//ADVASOFT LTD//DTD HTML 3.0 ASWEDIT + EXTENSIONS//EN" => 1, |
| 1779 |
|
"-//AS//DTD HTML 3.0 ASWEDIT + EXTENSIONS//EN" => 1, |
| 1780 |
|
"-//IETF//DTD HTML 2.0 LEVEL 1//EN" => 1, |
| 1781 |
|
"-//IETF//DTD HTML 2.0 LEVEL 2//EN" => 1, |
| 1782 |
|
"-//IETF//DTD HTML 2.0 STRICT LEVEL 1//EN" => 1, |
| 1783 |
|
"-//IETF//DTD HTML 2.0 STRICT LEVEL 2//EN" => 1, |
| 1784 |
|
"-//IETF//DTD HTML 2.0 STRICT//EN" => 1, |
| 1785 |
|
"-//IETF//DTD HTML 2.0//EN" => 1, |
| 1786 |
|
"-//IETF//DTD HTML 2.1E//EN" => 1, |
| 1787 |
|
"-//IETF//DTD HTML 3.0//EN" => 1, |
| 1788 |
|
"-//IETF//DTD HTML 3.0//EN//" => 1, |
| 1789 |
|
"-//IETF//DTD HTML 3.2 FINAL//EN" => 1, |
| 1790 |
|
"-//IETF//DTD HTML 3.2//EN" => 1, |
| 1791 |
|
"-//IETF//DTD HTML 3//EN" => 1, |
| 1792 |
|
"-//IETF//DTD HTML LEVEL 0//EN" => 1, |
| 1793 |
|
"-//IETF//DTD HTML LEVEL 0//EN//2.0" => 1, |
| 1794 |
|
"-//IETF//DTD HTML LEVEL 1//EN" => 1, |
| 1795 |
|
"-//IETF//DTD HTML LEVEL 1//EN//2.0" => 1, |
| 1796 |
|
"-//IETF//DTD HTML LEVEL 2//EN" => 1, |
| 1797 |
|
"-//IETF//DTD HTML LEVEL 2//EN//2.0" => 1, |
| 1798 |
|
"-//IETF//DTD HTML LEVEL 3//EN" => 1, |
| 1799 |
|
"-//IETF//DTD HTML LEVEL 3//EN//3.0" => 1, |
| 1800 |
|
"-//IETF//DTD HTML STRICT LEVEL 0//EN" => 1, |
| 1801 |
|
"-//IETF//DTD HTML STRICT LEVEL 0//EN//2.0" => 1, |
| 1802 |
|
"-//IETF//DTD HTML STRICT LEVEL 1//EN" => 1, |
| 1803 |
|
"-//IETF//DTD HTML STRICT LEVEL 1//EN//2.0" => 1, |
| 1804 |
|
"-//IETF//DTD HTML STRICT LEVEL 2//EN" => 1, |
| 1805 |
|
"-//IETF//DTD HTML STRICT LEVEL 2//EN//2.0" => 1, |
| 1806 |
|
"-//IETF//DTD HTML STRICT LEVEL 3//EN" => 1, |
| 1807 |
|
"-//IETF//DTD HTML STRICT LEVEL 3//EN//3.0" => 1, |
| 1808 |
|
"-//IETF//DTD HTML STRICT//EN" => 1, |
| 1809 |
|
"-//IETF//DTD HTML STRICT//EN//2.0" => 1, |
| 1810 |
|
"-//IETF//DTD HTML STRICT//EN//3.0" => 1, |
| 1811 |
|
"-//IETF//DTD HTML//EN" => 1, |
| 1812 |
|
"-//IETF//DTD HTML//EN//2.0" => 1, |
| 1813 |
|
"-//IETF//DTD HTML//EN//3.0" => 1, |
| 1814 |
|
"-//METRIUS//DTD METRIUS PRESENTATIONAL//EN" => 1, |
| 1815 |
|
"-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML STRICT//EN" => 1, |
| 1816 |
|
"-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML//EN" => 1, |
| 1817 |
|
"-//MICROSOFT//DTD INTERNET EXPLORER 2.0 TABLES//EN" => 1, |
| 1818 |
|
"-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML STRICT//EN" => 1, |
| 1819 |
|
"-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML//EN" => 1, |
| 1820 |
|
"-//MICROSOFT//DTD INTERNET EXPLORER 3.0 TABLES//EN" => 1, |
| 1821 |
|
"-//NETSCAPE COMM. CORP.//DTD HTML//EN" => 1, |
| 1822 |
|
"-//NETSCAPE COMM. CORP.//DTD STRICT HTML//EN" => 1, |
| 1823 |
|
"-//O'REILLY AND ASSOCIATES//DTD HTML 2.0//EN" => 1, |
| 1824 |
|
"-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED 1.0//EN" => 1, |
| 1825 |
|
"-//SPYGLASS//DTD HTML 2.0 EXTENDED//EN" => 1, |
| 1826 |
|
"-//SQ//DTD HTML 2.0 HOTMETAL + EXTENSIONS//EN" => 1, |
| 1827 |
|
"-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA HTML//EN" => 1, |
| 1828 |
|
"-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA STRICT HTML//EN" => 1, |
| 1829 |
|
"-//W3C//DTD HTML 3 1995-03-24//EN" => 1, |
| 1830 |
|
"-//W3C//DTD HTML 3.2 DRAFT//EN" => 1, |
| 1831 |
|
"-//W3C//DTD HTML 3.2 FINAL//EN" => 1, |
| 1832 |
|
"-//W3C//DTD HTML 3.2//EN" => 1, |
| 1833 |
|
"-//W3C//DTD HTML 3.2S DRAFT//EN" => 1, |
| 1834 |
|
"-//W3C//DTD HTML 4.0 FRAMESET//EN" => 1, |
| 1835 |
|
"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN" => 1, |
| 1836 |
|
"-//W3C//DTD HTML EXPERIMETNAL 19960712//EN" => 1, |
| 1837 |
|
"-//W3C//DTD HTML EXPERIMENTAL 970421//EN" => 1, |
| 1838 |
|
"-//W3C//DTD W3 HTML//EN" => 1, |
| 1839 |
|
"-//W3O//DTD W3 HTML 3.0//EN" => 1, |
| 1840 |
|
"-//W3O//DTD W3 HTML 3.0//EN//" => 1, |
| 1841 |
|
"-//W3O//DTD W3 HTML STRICT 3.0//EN//" => 1, |
| 1842 |
|
"-//WEBTECHS//DTD MOZILLA HTML 2.0//EN" => 1, |
| 1843 |
|
"-//WEBTECHS//DTD MOZILLA HTML//EN" => 1, |
| 1844 |
|
"-/W3C/DTD HTML 4.0 TRANSITIONAL/EN" => 1, |
| 1845 |
|
"HTML" => 1, |
| 1846 |
|
}->{$pubid}) { |
| 1847 |
|
$self->{document}->manakai_compat_mode ('quirks'); |
| 1848 |
|
} elsif ($pubid eq "-//W3C//DTD HTML 4.01 FRAMESET//EN" or |
| 1849 |
|
$pubid eq "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN") { |
| 1850 |
|
if (defined $token->{system_identifier}) { |
| 1851 |
|
$self->{document}->manakai_compat_mode ('quirks'); |
| 1852 |
|
} else { |
| 1853 |
|
$self->{document}->manakai_compat_mode ('limited quirks'); |
| 1854 |
} |
} |
| 1855 |
|
} elsif ($pubid eq "-//W3C//DTD XHTML 1.0 Frameset//EN" or |
| 1856 |
|
$pubid eq "-//W3C//DTD XHTML 1.0 Transitional//EN") { |
| 1857 |
|
$self->{document}->manakai_compat_mode ('limited quirks'); |
| 1858 |
} |
} |
|
## ISSUE: Spec currently left this case undefined. |
|
|
!!!parse-error (type => 'missing DOCTYPE'); |
|
|
#$phase = 'root element'; |
|
|
## reprocess |
|
|
#redo B; |
|
|
return; |
|
|
} else { |
|
|
die "$0: $token->{type}: Unknown token"; |
|
| 1859 |
} |
} |
| 1860 |
} # B |
if (defined $token->{system_identifier}) { |
| 1861 |
|
my $sysid = $token->{system_identifier}; |
| 1862 |
|
$sysid =~ tr/A-Z/a-z/; |
| 1863 |
|
if ($sysid eq "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd") { |
| 1864 |
|
$self->{document}->manakai_compat_mode ('quirks'); |
| 1865 |
|
} |
| 1866 |
|
} |
| 1867 |
|
|
| 1868 |
|
## Go to the root element phase. |
| 1869 |
|
!!!next-token; |
| 1870 |
|
return; |
| 1871 |
|
} elsif ({ |
| 1872 |
|
'start tag' => 1, |
| 1873 |
|
'end tag' => 1, |
| 1874 |
|
'end-of-file' => 1, |
| 1875 |
|
}->{$token->{type}}) { |
| 1876 |
|
!!!parse-error (type => 'no DOCTYPE'); |
| 1877 |
|
$self->{document}->manakai_compat_mode ('quirks'); |
| 1878 |
|
## Go to the root element phase |
| 1879 |
|
## reprocess |
| 1880 |
|
return; |
| 1881 |
|
} elsif ($token->{type} eq 'character') { |
| 1882 |
|
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { # \x0D |
| 1883 |
|
## Ignore the token |
| 1884 |
|
unless (length $token->{data}) { |
| 1885 |
|
## Stay in the phase |
| 1886 |
|
!!!next-token; |
| 1887 |
|
redo INITIAL; |
| 1888 |
|
} |
| 1889 |
|
} |
| 1890 |
|
|
| 1891 |
|
!!!parse-error (type => 'no DOCTYPE'); |
| 1892 |
|
$self->{document}->manakai_compat_mode ('quirks'); |
| 1893 |
|
## Go to the root element phase |
| 1894 |
|
## reprocess |
| 1895 |
|
return; |
| 1896 |
|
} elsif ($token->{type} eq 'comment') { |
| 1897 |
|
my $comment = $self->{document}->create_comment ($token->{data}); |
| 1898 |
|
$self->{document}->append_child ($comment); |
| 1899 |
|
|
| 1900 |
|
## Stay in the phase. |
| 1901 |
|
!!!next-token; |
| 1902 |
|
redo INITIAL; |
| 1903 |
|
} else { |
| 1904 |
|
die "$0: $token->{type}: Unknown token"; |
| 1905 |
|
} |
| 1906 |
|
} # INITIAL |
| 1907 |
} # _tree_construction_initial |
} # _tree_construction_initial |
| 1908 |
|
|
| 1909 |
sub _tree_construction_root_element ($) { |
sub _tree_construction_root_element ($) { |
| 2726 |
return; |
return; |
| 2727 |
} elsif ({ |
} elsif ({ |
| 2728 |
b => 1, big => 1, em => 1, font => 1, i => 1, |
b => 1, big => 1, em => 1, font => 1, i => 1, |
| 2729 |
nobr => 1, s => 1, small => 1, strile => 1, |
s => 1, small => 1, strile => 1, |
| 2730 |
strong => 1, tt => 1, u => 1, |
strong => 1, tt => 1, u => 1, |
| 2731 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 2732 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 2736 |
|
|
| 2737 |
!!!next-token; |
!!!next-token; |
| 2738 |
return; |
return; |
| 2739 |
|
} elsif ($token->{tag_name} eq 'nobr') { |
| 2740 |
|
$reconstruct_active_formatting_elements->($insert_to_current); |
| 2741 |
|
|
| 2742 |
|
## has a |nobr| element in scope |
| 2743 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 2744 |
|
my $node = $self->{open_elements}->[$_]; |
| 2745 |
|
if ($node->[1] eq 'nobr') { |
| 2746 |
|
!!!back-token; |
| 2747 |
|
$token = {type => 'end tag', tag_name => 'nobr'}; |
| 2748 |
|
return; |
| 2749 |
|
} elsif ({ |
| 2750 |
|
table => 1, caption => 1, td => 1, th => 1, |
| 2751 |
|
button => 1, marquee => 1, object => 1, html => 1, |
| 2752 |
|
}->{$node->[1]}) { |
| 2753 |
|
last INSCOPE; |
| 2754 |
|
} |
| 2755 |
|
} # INSCOPE |
| 2756 |
|
|
| 2757 |
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 2758 |
|
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
| 2759 |
|
|
| 2760 |
|
!!!next-token; |
| 2761 |
|
return; |
| 2762 |
} elsif ($token->{tag_name} eq 'button') { |
} elsif ($token->{tag_name} eq 'button') { |
| 2763 |
## has a button element in scope |
## has a button element in scope |
| 2764 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 2984 |
} |
} |
| 2985 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 2986 |
if ($token->{tag_name} eq 'body') { |
if ($token->{tag_name} eq 'body') { |
| 2987 |
if (@{$self->{open_elements}} > 1 and $self->{open_elements}->[1]->[1] eq 'body') { |
if (@{$self->{open_elements}} > 1 and |
| 2988 |
## ISSUE: There is an issue in the spec. |
$self->{open_elements}->[1]->[1] eq 'body') { |
| 2989 |
if ($self->{open_elements}->[-1]->[1] ne 'body') { |
for (@{$self->{open_elements}}) { |
| 2990 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
unless ({ |
| 2991 |
|
dd => 1, dt => 1, li => 1, p => 1, td => 1, |
| 2992 |
|
th => 1, tr => 1, body => 1, html => 1, |
| 2993 |
|
}->{$_->[1]}) { |
| 2994 |
|
!!!parse-error (type => 'not closed:'.$_->[1]); |
| 2995 |
|
} |
| 2996 |
} |
} |
| 2997 |
|
|
| 2998 |
$self->{insertion_mode} = 'after body'; |
$self->{insertion_mode} = 'after body'; |
| 2999 |
!!!next-token; |
!!!next-token; |
| 3000 |
return; |
return; |
| 5118 |
## Step 1 # MUST |
## Step 1 # MUST |
| 5119 |
my $this_doc = $node->owner_document; |
my $this_doc = $node->owner_document; |
| 5120 |
my $doc = $this_doc->implementation->create_document; |
my $doc = $this_doc->implementation->create_document; |
| 5121 |
## TODO: Mark as HTML document |
$doc->manakai_is_html (1); |
| 5122 |
my $p = $class->new; |
my $p = $class->new; |
| 5123 |
$p->{document} = $doc; |
$p->{document} = $doc; |
| 5124 |
|
|