| 326 |
} elsif ($self->{state} eq 'close tag open') { |
} elsif ($self->{state} eq 'close tag open') { |
| 327 |
if ($self->{content_model_flag} eq 'RCDATA' or |
if ($self->{content_model_flag} eq 'RCDATA' or |
| 328 |
$self->{content_model_flag} eq 'CDATA') { |
$self->{content_model_flag} eq 'CDATA') { |
| 329 |
my @next_char; |
if (defined $self->{last_emitted_start_tag_name}) { |
| 330 |
TAGNAME: for (my $i = 0; $i < length $self->{last_emitted_start_tag_name}; $i++) { |
my @next_char; |
| 331 |
|
TAGNAME: for (my $i = 0; $i < length $self->{last_emitted_start_tag_name}; $i++) { |
| 332 |
|
push @next_char, $self->{next_input_character}; |
| 333 |
|
my $c = ord substr ($self->{last_emitted_start_tag_name}, $i, 1); |
| 334 |
|
my $C = 0x0061 <= $c && $c <= 0x007A ? $c - 0x0020 : $c; |
| 335 |
|
if ($self->{next_input_character} == $c or $self->{next_input_character} == $C) { |
| 336 |
|
!!!next-input-character; |
| 337 |
|
next TAGNAME; |
| 338 |
|
} else { |
| 339 |
|
$self->{next_input_character} = shift @next_char; # reconsume |
| 340 |
|
!!!back-next-input-character (@next_char); |
| 341 |
|
$self->{state} = 'data'; |
| 342 |
|
|
| 343 |
|
!!!emit ({type => 'character', data => '</'}); |
| 344 |
|
|
| 345 |
|
redo A; |
| 346 |
|
} |
| 347 |
|
} |
| 348 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_input_character}; |
| 349 |
my $c = ord substr ($self->{last_emitted_start_tag_name}, $i, 1); |
|
| 350 |
my $C = 0x0061 <= $c && $c <= 0x007A ? $c - 0x0020 : $c; |
unless ($self->{next_input_character} == 0x0009 or # HT |
| 351 |
if ($self->{next_input_character} == $c or $self->{next_input_character} == $C) { |
$self->{next_input_character} == 0x000A or # LF |
| 352 |
!!!next-input-character; |
$self->{next_input_character} == 0x000B or # VT |
| 353 |
next TAGNAME; |
$self->{next_input_character} == 0x000C or # FF |
| 354 |
} else { |
$self->{next_input_character} == 0x0020 or # SP |
| 355 |
|
$self->{next_input_character} == 0x003E or # > |
| 356 |
|
$self->{next_input_character} == 0x002F or # / |
| 357 |
|
$self->{next_input_character} == -1) { |
| 358 |
$self->{next_input_character} = shift @next_char; # reconsume |
$self->{next_input_character} = shift @next_char; # reconsume |
| 359 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 360 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
|
|
|
| 361 |
!!!emit ({type => 'character', data => '</'}); |
!!!emit ({type => 'character', data => '</'}); |
|
|
|
| 362 |
redo A; |
redo A; |
| 363 |
|
} else { |
| 364 |
|
$self->{next_input_character} = shift @next_char; |
| 365 |
|
!!!back-next-input-character (@next_char); |
| 366 |
|
# and consume... |
| 367 |
} |
} |
| 368 |
} |
} else { |
| 369 |
push @next_char, $self->{next_input_character}; |
## No start tag token has ever been emitted |
| 370 |
|
# next-input-character is already done |
|
unless ($self->{next_input_character} == 0x0009 or # HT |
|
|
$self->{next_input_character} == 0x000A or # LF |
|
|
$self->{next_input_character} == 0x000B or # VT |
|
|
$self->{next_input_character} == 0x000C or # FF |
|
|
$self->{next_input_character} == 0x0020 or # SP |
|
|
$self->{next_input_character} == 0x003E or # > |
|
|
$self->{next_input_character} == 0x002F or # / |
|
|
$self->{next_input_character} == -1) { |
|
|
$self->{next_input_character} = shift @next_char; # reconsume |
|
|
!!!back-next-input-character (@next_char); |
|
| 371 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
|
|
|
| 372 |
!!!emit ({type => 'character', data => '</'}); |
!!!emit ({type => 'character', data => '</'}); |
|
|
|
| 373 |
redo A; |
redo A; |
|
} else { |
|
|
$self->{next_input_character} = shift @next_char; |
|
|
!!!back-next-input-character (@next_char); |
|
|
# and consume... |
|
| 374 |
} |
} |
| 375 |
} |
} |
| 376 |
|
|
| 431 |
!!!next-input-character; |
!!!next-input-character; |
| 432 |
|
|
| 433 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 434 |
|
|
| 435 |
redo A; |
redo A; |
| 436 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_input_character} and |
| 456 |
# reconsume |
# reconsume |
| 457 |
|
|
| 458 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 459 |
|
|
| 460 |
redo A; |
redo A; |
| 461 |
} elsif ($self->{next_input_character} == 0x002F) { # / |
} elsif ($self->{next_input_character} == 0x002F) { # / |
| 502 |
!!!next-input-character; |
!!!next-input-character; |
| 503 |
|
|
| 504 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 505 |
|
|
| 506 |
redo A; |
redo A; |
| 507 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_input_character} and |
| 540 |
# reconsume |
# reconsume |
| 541 |
|
|
| 542 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 543 |
|
|
| 544 |
redo A; |
redo A; |
| 545 |
} else { |
} else { |
| 591 |
!!!next-input-character; |
!!!next-input-character; |
| 592 |
|
|
| 593 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 594 |
|
|
| 595 |
redo A; |
redo A; |
| 596 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_input_character} and |
| 630 |
# reconsume |
# reconsume |
| 631 |
|
|
| 632 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 633 |
|
|
| 634 |
redo A; |
redo A; |
| 635 |
} else { |
} else { |
| 666 |
!!!next-input-character; |
!!!next-input-character; |
| 667 |
|
|
| 668 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 669 |
|
|
| 670 |
redo A; |
redo A; |
| 671 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_input_character} and |
| 704 |
# reconsume |
# reconsume |
| 705 |
|
|
| 706 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 707 |
|
|
| 708 |
redo A; |
redo A; |
| 709 |
} else { |
} else { |
| 749 |
!!!next-input-character; |
!!!next-input-character; |
| 750 |
|
|
| 751 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 752 |
|
|
| 753 |
redo A; |
redo A; |
| 754 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 767 |
## reconsume |
## reconsume |
| 768 |
|
|
| 769 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 770 |
|
|
| 771 |
redo A; |
redo A; |
| 772 |
} else { |
} else { |
| 801 |
## reconsume |
## reconsume |
| 802 |
|
|
| 803 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 804 |
|
|
| 805 |
redo A; |
redo A; |
| 806 |
} else { |
} else { |
| 835 |
## reconsume |
## reconsume |
| 836 |
|
|
| 837 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 838 |
|
|
| 839 |
redo A; |
redo A; |
| 840 |
} else { |
} else { |
| 872 |
!!!next-input-character; |
!!!next-input-character; |
| 873 |
|
|
| 874 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 875 |
|
|
| 876 |
redo A; |
redo A; |
| 877 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 890 |
## reconsume |
## reconsume |
| 891 |
|
|
| 892 |
!!!emit ($self->{current_token}); # start tag or end tag |
!!!emit ($self->{current_token}); # start tag or end tag |
|
undef $self->{current_token}; |
|
| 893 |
|
|
| 894 |
redo A; |
redo A; |
| 895 |
} else { |
} else { |
| 948 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_input_character}; |
| 949 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_input_character} == 0x002D) { # - |
| 950 |
$self->{current_token} = {type => 'comment', data => ''}; |
$self->{current_token} = {type => 'comment', data => ''}; |
| 951 |
$self->{state} = 'comment'; |
$self->{state} = 'comment start'; |
| 952 |
!!!next-input-character; |
!!!next-input-character; |
| 953 |
redo A; |
redo A; |
| 954 |
} |
} |
| 998 |
|
|
| 999 |
## ISSUE: typos in spec: chacacters, is is a parse error |
## ISSUE: typos in spec: chacacters, is is a parse error |
| 1000 |
## ISSUE: spec is somewhat unclear on "is the first character that will be in the comment"; what is "that will be in the comment" is what the algorithm defines, isn't it? |
## ISSUE: spec is somewhat unclear on "is the first character that will be in the comment"; what is "that will be in the comment" is what the algorithm defines, isn't it? |
| 1001 |
|
} elsif ($self->{state} eq 'comment start') { |
| 1002 |
|
if ($self->{next_input_character} == 0x002D) { # - |
| 1003 |
|
$self->{state} = 'comment start dash'; |
| 1004 |
|
!!!next-input-character; |
| 1005 |
|
redo A; |
| 1006 |
|
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1007 |
|
!!!parse-error (type => 'bogus comment'); |
| 1008 |
|
$self->{state} = 'data'; |
| 1009 |
|
!!!next-input-character; |
| 1010 |
|
|
| 1011 |
|
!!!emit ($self->{current_token}); # comment |
| 1012 |
|
|
| 1013 |
|
redo A; |
| 1014 |
|
} elsif ($self->{next_input_character} == -1) { |
| 1015 |
|
!!!parse-error (type => 'unclosed comment'); |
| 1016 |
|
$self->{state} = 'data'; |
| 1017 |
|
## reconsume |
| 1018 |
|
|
| 1019 |
|
!!!emit ($self->{current_token}); # comment |
| 1020 |
|
|
| 1021 |
|
redo A; |
| 1022 |
|
} else { |
| 1023 |
|
$self->{current_token}->{data} # comment |
| 1024 |
|
.= chr ($self->{next_input_character}); |
| 1025 |
|
$self->{state} = 'comment'; |
| 1026 |
|
!!!next-input-character; |
| 1027 |
|
redo A; |
| 1028 |
|
} |
| 1029 |
|
} elsif ($self->{state} eq 'comment start dash') { |
| 1030 |
|
if ($self->{next_input_character} == 0x002D) { # - |
| 1031 |
|
$self->{state} = 'comment end'; |
| 1032 |
|
!!!next-input-character; |
| 1033 |
|
redo A; |
| 1034 |
|
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 1035 |
|
!!!parse-error (type => 'bogus comment'); |
| 1036 |
|
$self->{state} = 'data'; |
| 1037 |
|
!!!next-input-character; |
| 1038 |
|
|
| 1039 |
|
!!!emit ($self->{current_token}); # comment |
| 1040 |
|
|
| 1041 |
|
redo A; |
| 1042 |
|
} elsif ($self->{next_input_character} == -1) { |
| 1043 |
|
!!!parse-error (type => 'unclosed comment'); |
| 1044 |
|
$self->{state} = 'data'; |
| 1045 |
|
## reconsume |
| 1046 |
|
|
| 1047 |
|
!!!emit ($self->{current_token}); # comment |
| 1048 |
|
|
| 1049 |
|
redo A; |
| 1050 |
|
} else { |
| 1051 |
|
$self->{current_token}->{data} # comment |
| 1052 |
|
.= chr ($self->{next_input_character}); |
| 1053 |
|
$self->{state} = 'comment'; |
| 1054 |
|
!!!next-input-character; |
| 1055 |
|
redo A; |
| 1056 |
|
} |
| 1057 |
} elsif ($self->{state} eq 'comment') { |
} elsif ($self->{state} eq 'comment') { |
| 1058 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_input_character} == 0x002D) { # - |
| 1059 |
$self->{state} = 'comment dash'; |
$self->{state} = 'comment end dash'; |
| 1060 |
!!!next-input-character; |
!!!next-input-character; |
| 1061 |
redo A; |
redo A; |
| 1062 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1065 |
## reconsume |
## reconsume |
| 1066 |
|
|
| 1067 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
|
undef $self->{current_token}; |
|
| 1068 |
|
|
| 1069 |
redo A; |
redo A; |
| 1070 |
} else { |
} else { |
| 1073 |
!!!next-input-character; |
!!!next-input-character; |
| 1074 |
redo A; |
redo A; |
| 1075 |
} |
} |
| 1076 |
} elsif ($self->{state} eq 'comment dash') { |
} elsif ($self->{state} eq 'comment end dash') { |
| 1077 |
if ($self->{next_input_character} == 0x002D) { # - |
if ($self->{next_input_character} == 0x002D) { # - |
| 1078 |
$self->{state} = 'comment end'; |
$self->{state} = 'comment end'; |
| 1079 |
!!!next-input-character; |
!!!next-input-character; |
| 1084 |
## reconsume |
## reconsume |
| 1085 |
|
|
| 1086 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
|
undef $self->{current_token}; |
|
| 1087 |
|
|
| 1088 |
redo A; |
redo A; |
| 1089 |
} else { |
} else { |
| 1098 |
!!!next-input-character; |
!!!next-input-character; |
| 1099 |
|
|
| 1100 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
|
undef $self->{current_token}; |
|
| 1101 |
|
|
| 1102 |
redo A; |
redo A; |
| 1103 |
} elsif ($self->{next_input_character} == 0x002D) { # - |
} elsif ($self->{next_input_character} == 0x002D) { # - |
| 1112 |
## reconsume |
## reconsume |
| 1113 |
|
|
| 1114 |
!!!emit ($self->{current_token}); # comment |
!!!emit ($self->{current_token}); # comment |
|
undef $self->{current_token}; |
|
| 1115 |
|
|
| 1116 |
redo A; |
redo A; |
| 1117 |
} else { |
} else { |
| 1186 |
!!!next-input-character; |
!!!next-input-character; |
| 1187 |
|
|
| 1188 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1189 |
|
|
| 1190 |
redo A; |
redo A; |
| 1191 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1195 |
|
|
| 1196 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1197 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1198 |
|
|
| 1199 |
redo A; |
redo A; |
| 1200 |
} else { |
} else { |
| 1218 |
!!!next-input-character; |
!!!next-input-character; |
| 1219 |
|
|
| 1220 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1221 |
|
|
| 1222 |
redo A; |
redo A; |
| 1223 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1227 |
|
|
| 1228 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1229 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1230 |
|
|
| 1231 |
redo A; |
redo A; |
| 1232 |
} elsif ($self->{next_input_character} == 0x0050 or # P |
} elsif ($self->{next_input_character} == 0x0050 or # P |
| 1318 |
|
|
| 1319 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1320 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1321 |
|
|
| 1322 |
redo A; |
redo A; |
| 1323 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1328 |
|
|
| 1329 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1330 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1331 |
|
|
| 1332 |
redo A; |
redo A; |
| 1333 |
} else { |
} else { |
| 1349 |
|
|
| 1350 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1351 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1352 |
|
|
| 1353 |
redo A; |
redo A; |
| 1354 |
} else { |
} else { |
| 1371 |
|
|
| 1372 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1373 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1374 |
|
|
| 1375 |
redo A; |
redo A; |
| 1376 |
} else { |
} else { |
| 1403 |
!!!next-input-character; |
!!!next-input-character; |
| 1404 |
|
|
| 1405 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1406 |
|
|
| 1407 |
redo A; |
redo A; |
| 1408 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1413 |
|
|
| 1414 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1415 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1416 |
|
|
| 1417 |
redo A; |
redo A; |
| 1418 |
} else { |
} else { |
| 1446 |
|
|
| 1447 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1448 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1449 |
|
|
| 1450 |
redo A; |
redo A; |
| 1451 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1456 |
|
|
| 1457 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1458 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1459 |
|
|
| 1460 |
redo A; |
redo A; |
| 1461 |
} else { |
} else { |
| 1477 |
|
|
| 1478 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1479 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1480 |
|
|
| 1481 |
redo A; |
redo A; |
| 1482 |
} else { |
} else { |
| 1499 |
|
|
| 1500 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1501 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1502 |
|
|
| 1503 |
redo A; |
redo A; |
| 1504 |
} else { |
} else { |
| 1521 |
!!!next-input-character; |
!!!next-input-character; |
| 1522 |
|
|
| 1523 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1524 |
|
|
| 1525 |
redo A; |
redo A; |
| 1526 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1531 |
|
|
| 1532 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1533 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1534 |
|
|
| 1535 |
redo A; |
redo A; |
| 1536 |
} else { |
} else { |
| 1546 |
|
|
| 1547 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1548 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1549 |
|
|
| 1550 |
redo A; |
redo A; |
| 1551 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 1555 |
|
|
| 1556 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1557 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
|
undef $self->{current_token}; |
|
| 1558 |
|
|
| 1559 |
redo A; |
redo A; |
| 1560 |
} else { |
} else { |
| 1572 |
|
|
| 1573 |
sub _tokenize_attempt_to_consume_an_entity ($) { |
sub _tokenize_attempt_to_consume_an_entity ($) { |
| 1574 |
my $self = shift; |
my $self = shift; |
| 1575 |
|
|
| 1576 |
if ($self->{next_input_character} == 0x0023) { # # |
if ({ |
| 1577 |
|
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
| 1578 |
|
0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & # 0x000D # CR |
| 1579 |
|
}->{$self->{next_input_character}}) { |
| 1580 |
|
## Don't consume |
| 1581 |
|
## No error |
| 1582 |
|
return undef; |
| 1583 |
|
} elsif ($self->{next_input_character} == 0x0023) { # # |
| 1584 |
!!!next-input-character; |
!!!next-input-character; |
| 1585 |
if ($self->{next_input_character} == 0x0078 or # x |
if ($self->{next_input_character} == 0x0078 or # x |
| 1586 |
$self->{next_input_character} == 0x0058) { # X |
$self->{next_input_character} == 0x0058) { # X |
| 2128 |
} |
} |
| 2129 |
}; # $clear_up_to_marker |
}; # $clear_up_to_marker |
| 2130 |
|
|
| 2131 |
my $style_start_tag = sub { |
my $parse_rcdata = sub ($$) { |
| 2132 |
my $style_el; !!!create-element ($style_el, 'style', $token->{attributes}); |
my ($content_model_flag, $insert) = @_; |
| 2133 |
## $self->{insertion_mode} eq 'in head' and ... (always true) |
|
| 2134 |
(($self->{insertion_mode} eq 'in head' and defined $self->{head_element}) |
## Step 1 |
| 2135 |
? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
my $start_tag_name = $token->{tag_name}; |
| 2136 |
->append_child ($style_el); |
my $el; |
| 2137 |
$self->{content_model_flag} = 'CDATA'; |
!!!create-element ($el, $start_tag_name, $token->{attributes}); |
| 2138 |
|
|
| 2139 |
|
## Step 2 |
| 2140 |
|
$insert->($el); # /context node/->append_child ($el) |
| 2141 |
|
|
| 2142 |
|
## Step 3 |
| 2143 |
|
$self->{content_model_flag} = $content_model_flag; # CDATA or RCDATA |
| 2144 |
delete $self->{escape}; # MUST |
delete $self->{escape}; # MUST |
| 2145 |
|
|
| 2146 |
|
## Step 4 |
| 2147 |
my $text = ''; |
my $text = ''; |
| 2148 |
!!!next-token; |
!!!next-token; |
| 2149 |
while ($token->{type} eq 'character') { |
while ($token->{type} eq 'character') { # or until stop tokenizing |
| 2150 |
$text .= $token->{data}; |
$text .= $token->{data}; |
| 2151 |
!!!next-token; |
!!!next-token; |
| 2152 |
} # stop if non-character token or tokenizer stops tokenising |
} |
| 2153 |
|
|
| 2154 |
|
## Step 5 |
| 2155 |
if (length $text) { |
if (length $text) { |
| 2156 |
$style_el->manakai_append_text ($text); |
my $text = $self->{document}->create_text_node ($text); |
| 2157 |
|
$el->append_child ($text); |
| 2158 |
} |
} |
| 2159 |
|
|
| 2160 |
|
## Step 6 |
| 2161 |
$self->{content_model_flag} = 'PCDATA'; |
$self->{content_model_flag} = 'PCDATA'; |
| 2162 |
|
|
| 2163 |
if ($token->{type} eq 'end tag' and $token->{tag_name} eq 'style') { |
## Step 7 |
| 2164 |
|
if ($token->{type} eq 'end tag' and $token->{tag_name} eq $start_tag_name) { |
| 2165 |
## Ignore the token |
## Ignore the token |
| 2166 |
} else { |
} else { |
| 2167 |
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
!!!parse-error (type => 'in '.$content_model_flag.':#'.$token->{type}); |
|
## ISSUE: And ignore? |
|
| 2168 |
} |
} |
| 2169 |
!!!next-token; |
!!!next-token; |
| 2170 |
}; # $style_start_tag |
}; # $parse_rcdata |
| 2171 |
|
|
| 2172 |
my $script_start_tag = sub { |
my $script_start_tag = sub ($) { |
| 2173 |
|
my $insert = $_[0]; |
| 2174 |
my $script_el; |
my $script_el; |
| 2175 |
!!!create-element ($script_el, 'script', $token->{attributes}); |
!!!create-element ($script_el, 'script', $token->{attributes}); |
| 2176 |
## TODO: mark as "parser-inserted" |
## TODO: mark as "parser-inserted" |
| 2204 |
} else { |
} else { |
| 2205 |
## TODO: $old_insertion_point = current insertion point |
## TODO: $old_insertion_point = current insertion point |
| 2206 |
## TODO: insertion point = just before the next input character |
## TODO: insertion point = just before the next input character |
| 2207 |
|
|
| 2208 |
(($self->{insertion_mode} eq 'in head' and defined $self->{head_element}) |
$insert->($script_el); |
|
? $self->{head_element} : $self->{open_elements}->[-1]->[0])->append_child ($script_el); |
|
| 2209 |
|
|
| 2210 |
## TODO: insertion point = $old_insertion_point (might be "undefined") |
## TODO: insertion point = $old_insertion_point (might be "undefined") |
| 2211 |
|
|
| 2399 |
}; # $formatting_end_tag |
}; # $formatting_end_tag |
| 2400 |
|
|
| 2401 |
my $insert_to_current = sub { |
my $insert_to_current = sub { |
| 2402 |
$self->{open_elements}->[-1]->[0]->append_child (shift); |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
| 2403 |
}; # $insert_to_current |
}; # $insert_to_current |
| 2404 |
|
|
| 2405 |
my $insert_to_foster = sub { |
my $insert_to_foster = sub { |
| 2437 |
my $insert = shift; |
my $insert = shift; |
| 2438 |
if ($token->{type} eq 'start tag') { |
if ($token->{type} eq 'start tag') { |
| 2439 |
if ($token->{tag_name} eq 'script') { |
if ($token->{tag_name} eq 'script') { |
| 2440 |
$script_start_tag->(); |
## NOTE: This is an "as if in head" code clone |
| 2441 |
|
$script_start_tag->($insert); |
| 2442 |
return; |
return; |
| 2443 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 2444 |
$style_start_tag->(); |
## NOTE: This is an "as if in head" code clone |
| 2445 |
|
$parse_rcdata->('CDATA', $insert); |
| 2446 |
return; |
return; |
| 2447 |
} elsif ({ |
} elsif ({ |
| 2448 |
base => 1, link => 1, meta => 1, |
base => 1, link => 1, meta => 1, |
| 2449 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 2450 |
!!!parse-error (type => 'in body:'.$token->{tag_name}); |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
| 2451 |
## NOTE: This is an "as if in head" code clone |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 2452 |
my $el; |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
|
!!!create-element ($el, $token->{tag_name}, $token->{attributes}); |
|
|
if (defined $self->{head_element}) { |
|
|
$self->{head_element}->append_child ($el); |
|
|
} else { |
|
|
$insert->($el); |
|
|
} |
|
|
|
|
| 2453 |
!!!next-token; |
!!!next-token; |
| 2454 |
return; |
return; |
| 2455 |
} elsif ($token->{tag_name} eq 'title') { |
} elsif ($token->{tag_name} eq 'title') { |
| 2456 |
!!!parse-error (type => 'in body:title'); |
!!!parse-error (type => 'in body:title'); |
| 2457 |
## NOTE: There is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 2458 |
my $title_el; |
$parse_rcdata->('RCDATA', $insert); |
|
!!!create-element ($title_el, 'title', $token->{attributes}); |
|
|
(defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
|
|
->append_child ($title_el); |
|
|
$self->{content_model_flag} = 'RCDATA'; |
|
|
delete $self->{escape}; # MUST |
|
|
|
|
|
my $text = ''; |
|
|
!!!next-token; |
|
|
while ($token->{type} eq 'character') { |
|
|
$text .= $token->{data}; |
|
|
!!!next-token; |
|
|
} |
|
|
if (length $text) { |
|
|
$title_el->manakai_append_text ($text); |
|
|
} |
|
|
|
|
|
$self->{content_model_flag} = 'PCDATA'; |
|
|
|
|
|
if ($token->{type} eq 'end tag' and |
|
|
$token->{tag_name} eq 'title') { |
|
|
## Ignore the token |
|
|
} else { |
|
|
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
|
|
## ISSUE: And ignore? |
|
|
} |
|
|
!!!next-token; |
|
| 2459 |
return; |
return; |
| 2460 |
} elsif ($token->{tag_name} eq 'body') { |
} elsif ($token->{tag_name} eq 'body') { |
| 2461 |
!!!parse-error (type => 'in body:body'); |
!!!parse-error (type => 'in body:body'); |
| 2669 |
} |
} |
| 2670 |
} # INSCOPE |
} # INSCOPE |
| 2671 |
|
|
| 2672 |
|
## NOTE: See <http://html5.org/tools/web-apps-tracker?from=925&to=926> |
| 2673 |
## has an element in scope |
## has an element in scope |
| 2674 |
my $i; |
#my $i; |
| 2675 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
#INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 2676 |
my $node = $self->{open_elements}->[$_]; |
# my $node = $self->{open_elements}->[$_]; |
| 2677 |
if ({ |
# if ({ |
| 2678 |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
# h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 2679 |
}->{$node->[1]}) { |
# }->{$node->[1]}) { |
| 2680 |
$i = $_; |
# $i = $_; |
| 2681 |
last INSCOPE; |
# last INSCOPE; |
| 2682 |
} elsif ({ |
# } elsif ({ |
| 2683 |
table => 1, caption => 1, td => 1, th => 1, |
# table => 1, caption => 1, td => 1, th => 1, |
| 2684 |
button => 1, marquee => 1, object => 1, html => 1, |
# button => 1, marquee => 1, object => 1, html => 1, |
| 2685 |
}->{$node->[1]}) { |
# }->{$node->[1]}) { |
| 2686 |
last INSCOPE; |
# last INSCOPE; |
| 2687 |
} |
# } |
| 2688 |
} # INSCOPE |
#} # INSCOPE |
| 2689 |
|
# |
| 2690 |
if (defined $i) { |
#if (defined $i) { |
| 2691 |
!!!parse-error (type => 'in hn:hn'); |
# !!! parse-error (type => 'in hn:hn'); |
| 2692 |
splice @{$self->{open_elements}}, $i; |
# splice @{$self->{open_elements}}, $i; |
| 2693 |
} |
#} |
| 2694 |
|
|
| 2695 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 2696 |
|
|
| 2801 |
return; |
return; |
| 2802 |
} elsif ($token->{tag_name} eq 'xmp') { |
} elsif ($token->{tag_name} eq 'xmp') { |
| 2803 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 2804 |
|
$parse_rcdata->('CDATA', $insert); |
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
|
|
|
$self->{content_model_flag} = 'CDATA'; |
|
|
delete $self->{escape}; # MUST |
|
|
|
|
|
!!!next-token; |
|
| 2805 |
return; |
return; |
| 2806 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 2807 |
## has a p element in scope |
## has a p element in scope |
| 2879 |
return; |
return; |
| 2880 |
} else { |
} else { |
| 2881 |
my $at = $token->{attributes}; |
my $at = $token->{attributes}; |
| 2882 |
|
my $form_attrs; |
| 2883 |
|
$form_attrs->{action} = $at->{action} if $at->{action}; |
| 2884 |
|
my $prompt_attr = $at->{prompt}; |
| 2885 |
$at->{name} = {name => 'name', value => 'isindex'}; |
$at->{name} = {name => 'name', value => 'isindex'}; |
| 2886 |
|
delete $at->{action}; |
| 2887 |
|
delete $at->{prompt}; |
| 2888 |
my @tokens = ( |
my @tokens = ( |
| 2889 |
{type => 'start tag', tag_name => 'form'}, |
{type => 'start tag', tag_name => 'form', |
| 2890 |
|
attributes => $form_attrs}, |
| 2891 |
{type => 'start tag', tag_name => 'hr'}, |
{type => 'start tag', tag_name => 'hr'}, |
| 2892 |
{type => 'start tag', tag_name => 'p'}, |
{type => 'start tag', tag_name => 'p'}, |
| 2893 |
{type => 'start tag', tag_name => 'label'}, |
{type => 'start tag', tag_name => 'label'}, |
| 2894 |
{type => 'character', |
); |
| 2895 |
data => 'This is a searchable index. Insert your search keywords here: '}, # SHOULD |
if ($prompt_attr) { |
| 2896 |
## TODO: make this configurable |
push @tokens, {type => 'character', data => $prompt_attr->{value}}; |
| 2897 |
|
} else { |
| 2898 |
|
push @tokens, {type => 'character', |
| 2899 |
|
data => 'This is a searchable index. Insert your search keywords here: '}; # SHOULD |
| 2900 |
|
## TODO: make this configurable |
| 2901 |
|
} |
| 2902 |
|
push @tokens, |
| 2903 |
{type => 'start tag', tag_name => 'input', attributes => $at}, |
{type => 'start tag', tag_name => 'input', attributes => $at}, |
| 2904 |
#{type => 'character', data => ''}, # SHOULD |
#{type => 'character', data => ''}, # SHOULD |
| 2905 |
{type => 'end tag', tag_name => 'label'}, |
{type => 'end tag', tag_name => 'label'}, |
| 2906 |
{type => 'end tag', tag_name => 'p'}, |
{type => 'end tag', tag_name => 'p'}, |
| 2907 |
{type => 'start tag', tag_name => 'hr'}, |
{type => 'start tag', tag_name => 'hr'}, |
| 2908 |
{type => 'end tag', tag_name => 'form'}, |
{type => 'end tag', tag_name => 'form'}; |
|
); |
|
| 2909 |
$token = shift @tokens; |
$token = shift @tokens; |
| 2910 |
!!!back-token (@tokens); |
!!!back-token (@tokens); |
| 2911 |
return; |
return; |
| 2912 |
} |
} |
| 2913 |
} elsif ({ |
} elsif ($token->{tag_name} eq 'textarea') { |
|
textarea => 1, |
|
|
iframe => 1, |
|
|
noembed => 1, |
|
|
noframes => 1, |
|
|
noscript => 0, ## TODO: 1 if scripting is enabled |
|
|
}->{$token->{tag_name}}) { |
|
| 2914 |
my $tag_name = $token->{tag_name}; |
my $tag_name = $token->{tag_name}; |
| 2915 |
my $el; |
my $el; |
| 2916 |
!!!create-element ($el, $token->{tag_name}, $token->{attributes}); |
!!!create-element ($el, $token->{tag_name}, $token->{attributes}); |
| 2917 |
|
|
| 2918 |
if ($token->{tag_name} eq 'textarea') { |
## TODO: $self->{form_element} if defined |
| 2919 |
## TODO: $self->{form_element} if defined |
$self->{content_model_flag} = 'RCDATA'; |
|
$self->{content_model_flag} = 'RCDATA'; |
|
|
} else { |
|
|
$self->{content_model_flag} = 'CDATA'; |
|
|
} |
|
| 2920 |
delete $self->{escape}; # MUST |
delete $self->{escape}; # MUST |
| 2921 |
|
|
| 2922 |
$insert->($el); |
$insert->($el); |
| 2923 |
|
|
| 2924 |
my $text = ''; |
my $text = ''; |
| 2925 |
if ($token->{tag_name} eq 'textarea') { |
!!!next-token; |
| 2926 |
!!!next-token; |
if ($token->{type} eq 'character') { |
| 2927 |
if ($token->{type} eq 'character') { |
$token->{data} =~ s/^\x0A//; |
| 2928 |
$token->{data} =~ s/^\x0A//; |
unless (length $token->{data}) { |
| 2929 |
unless (length $token->{data}) { |
!!!next-token; |
|
!!!next-token; |
|
|
} |
|
| 2930 |
} |
} |
|
} else { |
|
|
!!!next-token; |
|
| 2931 |
} |
} |
| 2932 |
while ($token->{type} eq 'character') { |
while ($token->{type} eq 'character') { |
| 2933 |
$text .= $token->{data}; |
$text .= $token->{data}; |
| 2943 |
$token->{tag_name} eq $tag_name) { |
$token->{tag_name} eq $tag_name) { |
| 2944 |
## Ignore the token |
## Ignore the token |
| 2945 |
} else { |
} else { |
| 2946 |
if ($token->{tag_name} eq 'textarea') { |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
|
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
|
|
} else { |
|
|
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
|
|
} |
|
|
## ISSUE: And ignore? |
|
| 2947 |
} |
} |
| 2948 |
!!!next-token; |
!!!next-token; |
| 2949 |
return; |
return; |
| 2950 |
|
} elsif ({ |
| 2951 |
|
iframe => 1, |
| 2952 |
|
noembed => 1, |
| 2953 |
|
noframes => 1, |
| 2954 |
|
noscript => 0, ## TODO: 1 if scripting is enabled |
| 2955 |
|
}->{$token->{tag_name}}) { |
| 2956 |
|
$parse_rcdata->('CDATA', $insert); |
| 2957 |
|
return; |
| 2958 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select') { |
| 2959 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 2960 |
|
|
| 2985 |
} |
} |
| 2986 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 2987 |
if ($token->{tag_name} eq 'body') { |
if ($token->{tag_name} eq 'body') { |
| 2988 |
if (@{$self->{open_elements}} > 1 and $self->{open_elements}->[1]->[1] eq 'body') { |
if (@{$self->{open_elements}} > 1 and |
| 2989 |
## ISSUE: There is an issue in the spec. |
$self->{open_elements}->[1]->[1] eq 'body') { |
| 2990 |
if ($self->{open_elements}->[-1]->[1] ne 'body') { |
for (@{$self->{open_elements}}) { |
| 2991 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
unless ({ |
| 2992 |
|
dd => 1, dt => 1, li => 1, p => 1, td => 1, |
| 2993 |
|
th => 1, tr => 1, body => 1, html => 1, |
| 2994 |
|
}->{$_->[1]}) { |
| 2995 |
|
!!!parse-error (type => 'not closed:'.$_->[1]); |
| 2996 |
|
} |
| 2997 |
} |
} |
| 2998 |
|
|
| 2999 |
$self->{insertion_mode} = 'after body'; |
$self->{insertion_mode} = 'after body'; |
| 3000 |
!!!next-token; |
!!!next-token; |
| 3001 |
return; |
return; |
| 3201 |
#not $phrasing_category->{$node->[1]} and |
#not $phrasing_category->{$node->[1]} and |
| 3202 |
($special_category->{$node->[1]} or |
($special_category->{$node->[1]} or |
| 3203 |
$scoping_category->{$node->[1]})) { |
$scoping_category->{$node->[1]})) { |
| 3204 |
!!!parse-error (type => 'not closed:'.$node->[1]); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3205 |
## Ignore the token |
## Ignore the token |
| 3206 |
!!!next-token; |
!!!next-token; |
| 3207 |
last S2; |
last S2; |
| 3304 |
} |
} |
| 3305 |
redo B; |
redo B; |
| 3306 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 3307 |
if ($token->{tag_name} eq 'html') { |
if ({head => 1, body => 1, html => 1}->{$token->{tag_name}}) { |
| 3308 |
## As if <head> |
## As if <head> |
| 3309 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head'); |
| 3310 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3314 |
redo B; |
redo B; |
| 3315 |
} else { |
} else { |
| 3316 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3317 |
## Ignore the token |
## Ignore the token ## ISSUE: An issue in the spec. |
| 3318 |
!!!next-token; |
!!!next-token; |
| 3319 |
redo B; |
redo B; |
| 3320 |
} |
} |
| 3321 |
} else { |
} else { |
| 3322 |
die "$0: $token->{type}: Unknown type"; |
die "$0: $token->{type}: Unknown type"; |
| 3323 |
} |
} |
| 3324 |
} elsif ($self->{insertion_mode} eq 'in head') { |
} elsif ($self->{insertion_mode} eq 'in head' or |
| 3325 |
|
$self->{insertion_mode} eq 'in head noscript' or |
| 3326 |
|
$self->{insertion_mode} eq 'after head') { |
| 3327 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 3328 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3329 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3340 |
!!!next-token; |
!!!next-token; |
| 3341 |
redo B; |
redo B; |
| 3342 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 3343 |
if ($token->{tag_name} eq 'title') { |
if ({base => ($self->{insertion_mode} eq 'in head' or |
| 3344 |
## NOTE: There is an "as if in head" code clone |
$self->{insertion_mode} eq 'after head'), |
| 3345 |
my $title_el; |
link => 1, meta => 1}->{$token->{tag_name}}) { |
| 3346 |
!!!create-element ($title_el, 'title', $token->{attributes}); |
## NOTE: There is a "as if in head" code clone. |
| 3347 |
(defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
if ($self->{insertion_mode} eq 'after head') { |
| 3348 |
->append_child ($title_el); |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3349 |
$self->{content_model_flag} = 'RCDATA'; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3350 |
delete $self->{escape}; # MUST |
} |
| 3351 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3352 |
my $text = ''; |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3353 |
|
pop @{$self->{open_elements}} |
| 3354 |
|
if $self->{insertion_mode} eq 'after head'; |
| 3355 |
!!!next-token; |
!!!next-token; |
| 3356 |
while ($token->{type} eq 'character') { |
redo B; |
| 3357 |
$text .= $token->{data}; |
} elsif ($token->{tag_name} eq 'title' and |
| 3358 |
|
$self->{insertion_mode} eq 'in head') { |
| 3359 |
|
## NOTE: There is a "as if in head" code clone. |
| 3360 |
|
if ($self->{insertion_mode} eq 'after head') { |
| 3361 |
|
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3362 |
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3363 |
|
} |
| 3364 |
|
$parse_rcdata->('RCDATA', $insert_to_current); |
| 3365 |
|
pop @{$self->{open_elements}} |
| 3366 |
|
if $self->{insertion_mode} eq 'after head'; |
| 3367 |
|
redo B; |
| 3368 |
|
} elsif ($token->{tag_name} eq 'style') { |
| 3369 |
|
## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and |
| 3370 |
|
## insertion mode 'in head') |
| 3371 |
|
## NOTE: There is a "as if in head" code clone. |
| 3372 |
|
if ($self->{insertion_mode} eq 'after head') { |
| 3373 |
|
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3374 |
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3375 |
|
} |
| 3376 |
|
$parse_rcdata->('CDATA', $insert_to_current); |
| 3377 |
|
pop @{$self->{open_elements}} |
| 3378 |
|
if $self->{insertion_mode} eq 'after head'; |
| 3379 |
|
redo B; |
| 3380 |
|
} elsif ($token->{tag_name} eq 'noscript') { |
| 3381 |
|
if ($self->{insertion_mode} eq 'in head') { |
| 3382 |
|
## NOTE: and scripting is disalbed |
| 3383 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3384 |
|
$self->{insertion_mode} = 'in head noscript'; |
| 3385 |
!!!next-token; |
!!!next-token; |
| 3386 |
} |
redo B; |
| 3387 |
if (length $text) { |
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
| 3388 |
$title_el->manakai_append_text ($text); |
!!!parse-error (type => 'noscript in noscript'); |
|
} |
|
|
|
|
|
$self->{content_model_flag} = 'PCDATA'; |
|
|
|
|
|
if ($token->{type} eq 'end tag' and |
|
|
$token->{tag_name} eq 'title') { |
|
| 3389 |
## Ignore the token |
## Ignore the token |
| 3390 |
|
redo B; |
| 3391 |
} else { |
} else { |
| 3392 |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
# |
|
## ISSUE: And ignore? |
|
| 3393 |
} |
} |
| 3394 |
|
} elsif ($token->{tag_name} eq 'head' and |
| 3395 |
|
$self->{insertion_mode} ne 'after head') { |
| 3396 |
|
!!!parse-error (type => 'in head:head'); # or in head noscript |
| 3397 |
|
## Ignore the token |
| 3398 |
!!!next-token; |
!!!next-token; |
| 3399 |
redo B; |
redo B; |
| 3400 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($self->{insertion_mode} ne 'in head noscript' and |
| 3401 |
$style_start_tag->(); |
$token->{tag_name} eq 'script') { |
| 3402 |
|
if ($self->{insertion_mode} eq 'after head') { |
| 3403 |
|
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3404 |
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3405 |
|
} |
| 3406 |
|
## NOTE: There is a "as if in head" code clone. |
| 3407 |
|
$script_start_tag->($insert_to_current); |
| 3408 |
|
pop @{$self->{open_elements}} |
| 3409 |
|
if $self->{insertion_mode} eq 'after head'; |
| 3410 |
redo B; |
redo B; |
| 3411 |
} elsif ($token->{tag_name} eq 'script') { |
} elsif ($self->{insertion_mode} eq 'after head' and |
| 3412 |
$script_start_tag->(); |
$token->{tag_name} eq 'body') { |
| 3413 |
redo B; |
!!!insert-element ('body', $token->{attributes}); |
| 3414 |
} elsif ({base => 1, link => 1, meta => 1}->{$token->{tag_name}}) { |
$self->{insertion_mode} = 'in body'; |
|
## NOTE: There are "as if in head" code clones |
|
|
my $el; |
|
|
!!!create-element ($el, $token->{tag_name}, $token->{attributes}); |
|
|
(defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
|
|
->append_child ($el); |
|
|
|
|
| 3415 |
!!!next-token; |
!!!next-token; |
| 3416 |
redo B; |
redo B; |
| 3417 |
} elsif ($token->{tag_name} eq 'head') { |
} elsif ($self->{insertion_mode} eq 'after head' and |
| 3418 |
!!!parse-error (type => 'in head:head'); |
$token->{tag_name} eq 'frameset') { |
| 3419 |
## Ignore the token |
!!!insert-element ('frameset', $token->{attributes}); |
| 3420 |
|
$self->{insertion_mode} = 'in frameset'; |
| 3421 |
!!!next-token; |
!!!next-token; |
| 3422 |
redo B; |
redo B; |
| 3423 |
} else { |
} else { |
| 3424 |
# |
# |
| 3425 |
} |
} |
| 3426 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 3427 |
if ($token->{tag_name} eq 'head') { |
if ($self->{insertion_mode} eq 'in head' and |
| 3428 |
if ($self->{open_elements}->[-1]->[1] eq 'head') { |
$token->{tag_name} eq 'head') { |
| 3429 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
|
} else { |
|
|
!!!parse-error (type => 'unmatched end tag:head'); |
|
|
} |
|
| 3430 |
$self->{insertion_mode} = 'after head'; |
$self->{insertion_mode} = 'after head'; |
| 3431 |
!!!next-token; |
!!!next-token; |
| 3432 |
redo B; |
redo B; |
| 3433 |
} elsif ($token->{tag_name} eq 'html') { |
} elsif ($self->{insertion_mode} eq 'in head noscript' and |
| 3434 |
|
$token->{tag_name} eq 'noscript') { |
| 3435 |
|
pop @{$self->{open_elements}}; |
| 3436 |
|
$self->{insertion_mode} = 'in head'; |
| 3437 |
|
!!!next-token; |
| 3438 |
|
redo B; |
| 3439 |
|
} elsif ($self->{insertion_mode} eq 'in head' and |
| 3440 |
|
($token->{tag_name} eq 'body' or |
| 3441 |
|
$token->{tag_name} eq 'html')) { |
| 3442 |
# |
# |
| 3443 |
} else { |
} elsif ($self->{insertion_mode} ne 'after head') { |
| 3444 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3445 |
## Ignore the token |
## Ignore the token |
| 3446 |
!!!next-token; |
!!!next-token; |
| 3447 |
redo B; |
redo B; |
| 3448 |
|
} else { |
| 3449 |
|
# |
| 3450 |
} |
} |
| 3451 |
} else { |
} else { |
| 3452 |
# |
# |
| 3453 |
} |
} |
| 3454 |
|
|
| 3455 |
if ($self->{open_elements}->[-1]->[1] eq 'head') { |
## As if </head> or </noscript> or <body> |
| 3456 |
## As if </head> |
if ($self->{insertion_mode} eq 'in head') { |
| 3457 |
|
pop @{$self->{open_elements}}; |
| 3458 |
|
$self->{insertion_mode} = 'after head'; |
| 3459 |
|
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
| 3460 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3461 |
|
!!!parse-error (type => 'in noscript:'.(defined $token->{tag_name} ? ($token->{type} eq 'end tag' ? '/' : '') . $token->{tag_name} : '#' . $token->{type})); |
| 3462 |
|
$self->{insertion_mode} = 'in head'; |
| 3463 |
|
} else { # 'after head' |
| 3464 |
|
!!!insert-element ('body'); |
| 3465 |
|
$self->{insertion_mode} = 'in body'; |
| 3466 |
} |
} |
|
$self->{insertion_mode} = 'after head'; |
|
| 3467 |
## reprocess |
## reprocess |
| 3468 |
redo B; |
redo B; |
| 3469 |
|
|
| 3470 |
## ISSUE: An issue in the spec. |
## ISSUE: An issue in the spec. |
|
} elsif ($self->{insertion_mode} eq 'after head') { |
|
|
if ($token->{type} eq 'character') { |
|
|
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
|
|
unless (length $token->{data}) { |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} |
|
|
|
|
|
# |
|
|
} elsif ($token->{type} eq 'comment') { |
|
|
my $comment = $self->{document}->create_comment ($token->{data}); |
|
|
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ($token->{tag_name} eq 'body') { |
|
|
!!!insert-element ('body', $token->{attributes}); |
|
|
$self->{insertion_mode} = 'in body'; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'frameset') { |
|
|
!!!insert-element ('frameset', $token->{attributes}); |
|
|
$self->{insertion_mode} = 'in frameset'; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
base => 1, link => 1, meta => 1, |
|
|
script => 1, style => 1, title => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
|
|
$self->{insertion_mode} = 'in head'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} else { |
|
|
# |
|
|
} |
|
|
|
|
|
## As if <body> |
|
|
!!!insert-element ('body'); |
|
|
$self->{insertion_mode} = 'in body'; |
|
|
## reprocess |
|
|
redo B; |
|
| 3471 |
} elsif ($self->{insertion_mode} eq 'in body') { |
} elsif ($self->{insertion_mode} eq 'in body') { |
| 3472 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 3473 |
## NOTE: There is a code clone of "character in body". |
## NOTE: There is a code clone of "character in body". |
| 5305 |
spacer => 1, wbr => 1, |
spacer => 1, wbr => 1, |
| 5306 |
}->{$tag_name}; |
}->{$tag_name}; |
| 5307 |
|
|
| 5308 |
|
$s .= "\x0A" if $tag_name eq 'pre' or $tag_name eq 'textarea'; |
| 5309 |
|
|
| 5310 |
if (not $in_cdata and { |
if (not $in_cdata and { |
| 5311 |
style => 1, script => 1, xmp => 1, iframe => 1, |
style => 1, script => 1, xmp => 1, iframe => 1, |
| 5312 |
noembed => 1, noframes => 1, noscript => 1, |
noembed => 1, noframes => 1, noscript => 1, |