| 568 |
my $before_leave = sub { |
my $before_leave = sub { |
| 569 |
if (exists $self->{current_token}->{attributes} # start tag or end tag |
if (exists $self->{current_token}->{attributes} # start tag or end tag |
| 570 |
->{$self->{current_attribute}->{name}}) { # MUST |
->{$self->{current_attribute}->{name}}) { # MUST |
| 571 |
!!!parse-error (type => 'dupulicate attribute'); |
!!!parse-error (type => 'duplicate attribute'); |
| 572 |
## Discard $self->{current_attribute} # MUST |
## Discard $self->{current_attribute} # MUST |
| 573 |
} else { |
} else { |
| 574 |
$self->{current_token}->{attributes}->{$self->{current_attribute}->{name}} |
$self->{current_token}->{attributes}->{$self->{current_attribute}->{name}} |
| 1644 |
redo X; |
redo X; |
| 1645 |
} elsif (not defined $code) { # no hexadecimal digit |
} elsif (not defined $code) { # no hexadecimal digit |
| 1646 |
!!!parse-error (type => 'bare hcro'); |
!!!parse-error (type => 'bare hcro'); |
| 1647 |
|
!!!back-next-input-character ($x_char, $self->{next_input_character}); |
| 1648 |
$self->{next_input_character} = 0x0023; # # |
$self->{next_input_character} = 0x0023; # # |
|
!!!back-next-input-character ($x_char); |
|
| 1649 |
return undef; |
return undef; |
| 1650 |
} elsif ($self->{next_input_character} == 0x003B) { # ; |
} elsif ($self->{next_input_character} == 0x003B) { # ; |
| 1651 |
!!!next-input-character; |
!!!next-input-character; |
| 1717 |
!!!next-input-character; |
!!!next-input-character; |
| 1718 |
|
|
| 1719 |
my $value = $entity_name; |
my $value = $entity_name; |
| 1720 |
my $match; |
my $match = 0; |
| 1721 |
require Whatpm::_NamedEntityList; |
require Whatpm::_NamedEntityList; |
| 1722 |
our $EntityChar; |
our $EntityChar; |
| 1723 |
|
|
| 1737 |
$match = 1; |
$match = 1; |
| 1738 |
!!!next-input-character; |
!!!next-input-character; |
| 1739 |
last; |
last; |
| 1740 |
} elsif (not $in_attr) { |
} else { |
| 1741 |
$value = $EntityChar->{$entity_name}; |
$value = $EntityChar->{$entity_name}; |
| 1742 |
$match = -1; |
$match = -1; |
| 1743 |
} else { |
!!!next-input-character; |
|
$value .= chr $self->{next_input_character}; |
|
| 1744 |
} |
} |
| 1745 |
} else { |
} else { |
| 1746 |
$value .= chr $self->{next_input_character}; |
$value .= chr $self->{next_input_character}; |
| 1747 |
|
$match *= 2; |
| 1748 |
|
!!!next-input-character; |
| 1749 |
} |
} |
|
!!!next-input-character; |
|
| 1750 |
} |
} |
| 1751 |
|
|
| 1752 |
if ($match > 0) { |
if ($match > 0) { |
| 1753 |
return {type => 'character', data => $value}; |
return {type => 'character', data => $value}; |
| 1754 |
} elsif ($match < 0) { |
} elsif ($match < 0) { |
| 1755 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc'); |
| 1756 |
return {type => 'character', data => $value}; |
if ($in_attr and $match < -1) { |
| 1757 |
|
return {type => 'character', data => '&'.$entity_name}; |
| 1758 |
|
} else { |
| 1759 |
|
return {type => 'character', data => $value}; |
| 1760 |
|
} |
| 1761 |
} else { |
} else { |
| 1762 |
!!!parse-error (type => 'bare ero'); |
!!!parse-error (type => 'bare ero'); |
| 1763 |
## NOTE: No characters are consumed in the spec. |
## NOTE: No characters are consumed in the spec. |
| 3335 |
}; # $in_body |
}; # $in_body |
| 3336 |
|
|
| 3337 |
B: { |
B: { |
| 3338 |
if ($self->{insertion_mode} ne 'trailing end') { |
if ($token->{type} eq 'DOCTYPE') { |
| 3339 |
if ($token->{type} eq 'DOCTYPE') { |
!!!parse-error (type => 'DOCTYPE in the middle'); |
| 3340 |
!!!parse-error (type => 'in html:#DOCTYPE'); |
## Ignore the token |
| 3341 |
## Ignore the token |
## Stay in the phase |
| 3342 |
## Stay in the phase |
!!!next-token; |
| 3343 |
!!!next-token; |
redo B; |
| 3344 |
redo B; |
} elsif ($token->{type} eq 'end-of-file') { |
| 3345 |
} elsif ($token->{type} eq 'start tag' and |
if ($token->{insertion_mode} ne 'trailing end') { |
|
$token->{tag_name} eq 'html') { |
|
|
## ISSUE: "aa<html>" is not a parse error. |
|
|
## ISSUE: "<html>" in fragment is not a parse error. |
|
|
unless ($token->{first_start_tag}) { |
|
|
!!!parse-error (type => 'not first start tag'); |
|
|
} |
|
|
my $top_el = $self->{open_elements}->[0]->[0]; |
|
|
for my $attr_name (keys %{$token->{attributes}}) { |
|
|
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
|
|
$top_el->set_attribute_ns |
|
|
(undef, [undef, $attr_name], |
|
|
$token->{attributes}->{$attr_name}->{value}); |
|
|
} |
|
|
} |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'end-of-file') { |
|
| 3346 |
## Generate implied end tags |
## Generate implied end tags |
| 3347 |
if ({ |
if ({ |
| 3348 |
dd => 1, dt => 1, li => 1, p => 1, td => 1, th => 1, tr => 1, |
dd => 1, dt => 1, li => 1, p => 1, td => 1, th => 1, tr => 1, |
| 3362 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3363 |
} |
} |
| 3364 |
|
|
|
## Stop parsing |
|
|
last B; |
|
|
|
|
| 3365 |
## ISSUE: There is an issue in the spec. |
## ISSUE: There is an issue in the spec. |
| 3366 |
|
} |
| 3367 |
|
|
| 3368 |
|
## Stop parsing |
| 3369 |
|
last B; |
| 3370 |
|
} elsif ($token->{type} eq 'start tag' and |
| 3371 |
|
$token->{tag_name} eq 'html') { |
| 3372 |
|
if ($self->{insertion_mode} eq 'trailing end') { |
| 3373 |
|
## Turn into the main phase |
| 3374 |
|
!!!parse-error (type => 'after html:html'); |
| 3375 |
|
$self->{insertion_mode} = $previous_insertion_mode; |
| 3376 |
|
} |
| 3377 |
|
|
| 3378 |
|
## ISSUE: "aa<html>" is not a parse error. |
| 3379 |
|
## ISSUE: "<html>" in fragment is not a parse error. |
| 3380 |
|
unless ($token->{first_start_tag}) { |
| 3381 |
|
!!!parse-error (type => 'not first start tag'); |
| 3382 |
|
} |
| 3383 |
|
my $top_el = $self->{open_elements}->[0]->[0]; |
| 3384 |
|
for my $attr_name (keys %{$token->{attributes}}) { |
| 3385 |
|
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
| 3386 |
|
$top_el->set_attribute_ns |
| 3387 |
|
(undef, [undef, $attr_name], |
| 3388 |
|
$token->{attributes}->{$attr_name}->{value}); |
| 3389 |
|
} |
| 3390 |
|
} |
| 3391 |
|
!!!next-token; |
| 3392 |
|
redo B; |
| 3393 |
|
} elsif ($token->{type} eq 'comment') { |
| 3394 |
|
my $comment = $self->{document}->create_comment ($token->{data}); |
| 3395 |
|
if ($self->{insertion_mode} eq 'trailing end') { |
| 3396 |
|
$self->{document}->append_child ($comment); |
| 3397 |
|
} elsif ($self->{insertion_mode} eq 'after body') { |
| 3398 |
|
$self->{open_elements}->[0]->[0]->append_child ($comment); |
| 3399 |
} else { |
} else { |
| 3400 |
if ($self->{insertion_mode} eq 'before head') { |
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
| 3401 |
|
} |
| 3402 |
|
!!!next-token; |
| 3403 |
|
redo B; |
| 3404 |
|
} elsif ($self->{insertion_mode} eq 'before head') { |
| 3405 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 3406 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3407 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3417 |
$self->{insertion_mode} = 'in head'; |
$self->{insertion_mode} = 'in head'; |
| 3418 |
## reprocess |
## reprocess |
| 3419 |
redo B; |
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; |
|
| 3420 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 3421 |
my $attr = $token->{tag_name} eq 'head' ? $token->{attributes} : {}; |
my $attr = $token->{tag_name} eq 'head' ? $token->{attributes} : {}; |
| 3422 |
!!!create-element ($self->{head_element}, 'head', $attr); |
!!!create-element ($self->{head_element}, 'head', $attr); |
| 3468 |
} |
} |
| 3469 |
|
|
| 3470 |
# |
# |
|
} 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; |
|
| 3471 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 3472 |
if ({base => ($self->{insertion_mode} eq 'in head' or |
if ({base => ($self->{insertion_mode} eq 'in head' or |
| 3473 |
$self->{insertion_mode} eq 'after head'), |
$self->{insertion_mode} eq 'after head'), |
| 3646 |
|
|
| 3647 |
!!!next-token; |
!!!next-token; |
| 3648 |
redo B; |
redo B; |
|
} elsif ($token->{type} eq 'comment') { |
|
|
## NOTE: There is a code clone of "comment in body". |
|
|
my $comment = $self->{document}->create_comment ($token->{data}); |
|
|
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
|
|
!!!next-token; |
|
|
redo B; |
|
| 3649 |
} else { |
} else { |
| 3650 |
$in_body->($insert_to_current); |
$in_body->($insert_to_current); |
| 3651 |
redo B; |
redo B; |
| 3709 |
|
|
| 3710 |
!!!next-token; |
!!!next-token; |
| 3711 |
redo B; |
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; |
|
| 3712 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 3713 |
if ({ |
if ({ |
| 3714 |
caption => 1, |
caption => 1, |
| 3875 |
|
|
| 3876 |
!!!next-token; |
!!!next-token; |
| 3877 |
redo B; |
redo B; |
|
} elsif ($token->{type} eq 'comment') { |
|
|
## NOTE: This is a code clone of "comment in body". |
|
|
my $comment = $self->{document}->create_comment ($token->{data}); |
|
|
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
|
|
!!!next-token; |
|
|
redo B; |
|
| 3878 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 3879 |
if ({ |
if ({ |
| 3880 |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
| 4056 |
} |
} |
| 4057 |
|
|
| 4058 |
# |
# |
|
} 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; |
|
| 4059 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 4060 |
if ($token->{tag_name} eq 'col') { |
if ($token->{tag_name} eq 'col') { |
| 4061 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4161 |
|
|
| 4162 |
!!!next-token; |
!!!next-token; |
| 4163 |
redo B; |
redo B; |
|
} elsif ($token->{type} eq 'comment') { |
|
|
## Copied from 'in table' |
|
|
my $comment = $self->{document}->create_comment ($token->{data}); |
|
|
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
|
|
!!!next-token; |
|
|
redo B; |
|
| 4164 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 4165 |
if ({ |
if ({ |
| 4166 |
tr => 1, |
tr => 1, |
| 4440 |
|
|
| 4441 |
!!!next-token; |
!!!next-token; |
| 4442 |
redo B; |
redo B; |
|
} elsif ($token->{type} eq 'comment') { |
|
|
## Copied from 'in table' |
|
|
my $comment = $self->{document}->create_comment ($token->{data}); |
|
|
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
|
|
!!!next-token; |
|
|
redo B; |
|
| 4443 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 4444 |
if ($token->{tag_name} eq 'th' or |
if ($token->{tag_name} eq 'th' or |
| 4445 |
$token->{tag_name} eq 'td') { |
$token->{tag_name} eq 'td') { |
| 4699 |
|
|
| 4700 |
!!!next-token; |
!!!next-token; |
| 4701 |
redo B; |
redo B; |
|
} elsif ($token->{type} eq 'comment') { |
|
|
## NOTE: This is a code clone of "comment in body". |
|
|
my $comment = $self->{document}->create_comment ($token->{data}); |
|
|
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
|
|
!!!next-token; |
|
|
redo B; |
|
| 4702 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 4703 |
if ({ |
if ({ |
| 4704 |
caption => 1, col => 1, colgroup => 1, |
caption => 1, col => 1, colgroup => 1, |
| 4835 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 4836 |
!!!next-token; |
!!!next-token; |
| 4837 |
redo B; |
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; |
|
| 4838 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 4839 |
if ($token->{tag_name} eq 'option') { |
if ($token->{tag_name} eq 'option') { |
| 4840 |
if ($self->{open_elements}->[-1]->[1] eq 'option') { |
if ($self->{open_elements}->[-1]->[1] eq 'option') { |
| 5020 |
} |
} |
| 5021 |
|
|
| 5022 |
# |
# |
| 5023 |
!!!parse-error (type => 'after body:#'.$token->{type}); |
!!!parse-error (type => 'after body:#character'); |
|
} elsif ($token->{type} eq 'comment') { |
|
|
my $comment = $self->{document}->create_comment ($token->{data}); |
|
|
$self->{open_elements}->[0]->[0]->append_child ($comment); |
|
|
!!!next-token; |
|
|
redo B; |
|
| 5024 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 5025 |
!!!parse-error (type => 'after body:'.$token->{tag_name}); |
!!!parse-error (type => 'after body:'.$token->{tag_name}); |
| 5026 |
# |
# |
| 5041 |
!!!parse-error (type => 'after body:/'.$token->{tag_name}); |
!!!parse-error (type => 'after body:/'.$token->{tag_name}); |
| 5042 |
} |
} |
| 5043 |
} else { |
} else { |
| 5044 |
!!!parse-error (type => 'after body:#'.$token->{type}); |
die "$0: $token->{type}: Unknown token type"; |
| 5045 |
} |
} |
| 5046 |
|
|
| 5047 |
$self->{insertion_mode} = 'in body'; |
$self->{insertion_mode} = 'in body'; |
| 5048 |
## reprocess |
## reprocess |
| 5049 |
redo B; |
redo B; |
| 5050 |
} elsif ($self->{insertion_mode} eq 'in frameset') { |
} elsif ($self->{insertion_mode} eq 'in frameset') { |
| 5051 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 5052 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 5053 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
|
|
|
|
unless (length $token->{data}) { |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} |
|
| 5054 |
|
|
| 5055 |
# |
unless (length $token->{data}) { |
|
} elsif ($token->{type} eq 'comment') { |
|
|
my $comment = $self->{document}->create_comment ($token->{data}); |
|
|
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
|
| 5056 |
!!!next-token; |
!!!next-token; |
| 5057 |
redo B; |
redo B; |
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ($token->{tag_name} eq 'frameset') { |
|
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'frame') { |
|
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
|
pop @{$self->{open_elements}}; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'noframes') { |
|
|
$in_body->($insert_to_current); |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} elsif ($token->{type} eq 'end tag') { |
|
|
if ($token->{tag_name} eq 'frameset') { |
|
|
if ($self->{open_elements}->[-1]->[1] eq 'html' and |
|
|
@{$self->{open_elements}} == 1) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
} else { |
|
|
pop @{$self->{open_elements}}; |
|
|
!!!next-token; |
|
|
} |
|
|
|
|
|
## if not inner_html and |
|
|
if ($self->{open_elements}->[-1]->[1] ne 'frameset') { |
|
|
$self->{insertion_mode} = 'after frameset'; |
|
|
} |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} else { |
|
|
# |
|
| 5058 |
} |
} |
| 5059 |
|
} |
| 5060 |
if (defined $token->{tag_name}) { |
|
| 5061 |
!!!parse-error (type => 'in frameset:'.($token->{type} eq 'end tag' ? '/' : '').$token->{tag_name}); |
!!!parse-error (type => 'in frameset:#character'); |
| 5062 |
|
## Ignore the token |
| 5063 |
|
!!!next-token; |
| 5064 |
|
redo B; |
| 5065 |
|
} elsif ($token->{type} eq 'start tag') { |
| 5066 |
|
if ($token->{tag_name} eq 'frameset') { |
| 5067 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 5068 |
|
!!!next-token; |
| 5069 |
|
redo B; |
| 5070 |
|
} elsif ($token->{tag_name} eq 'frame') { |
| 5071 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 5072 |
|
pop @{$self->{open_elements}}; |
| 5073 |
|
!!!next-token; |
| 5074 |
|
redo B; |
| 5075 |
|
} elsif ($token->{tag_name} eq 'noframes') { |
| 5076 |
|
$in_body->($insert_to_current); |
| 5077 |
|
redo B; |
| 5078 |
|
} else { |
| 5079 |
|
!!!parse-error (type => 'in frameset:'.$token->{tag_name}); |
| 5080 |
|
## Ignore the token |
| 5081 |
|
!!!next-token; |
| 5082 |
|
redo B; |
| 5083 |
|
} |
| 5084 |
|
} elsif ($token->{type} eq 'end tag') { |
| 5085 |
|
if ($token->{tag_name} eq 'frameset') { |
| 5086 |
|
if ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5087 |
|
@{$self->{open_elements}} == 1) { |
| 5088 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 5089 |
|
## Ignore the token |
| 5090 |
|
!!!next-token; |
| 5091 |
} else { |
} else { |
| 5092 |
!!!parse-error (type => 'in frameset:#'.$token->{type}); |
pop @{$self->{open_elements}}; |
| 5093 |
|
!!!next-token; |
| 5094 |
} |
} |
| 5095 |
|
|
| 5096 |
|
if (not defined $self->{inner_html_node} and |
| 5097 |
|
$self->{open_elements}->[-1]->[1] ne 'frameset') { |
| 5098 |
|
$self->{insertion_mode} = 'after frameset'; |
| 5099 |
|
} |
| 5100 |
|
redo B; |
| 5101 |
|
} else { |
| 5102 |
|
!!!parse-error (type => 'in frameset:/'.$token->{tag_name}); |
| 5103 |
## Ignore the token |
## Ignore the token |
| 5104 |
!!!next-token; |
!!!next-token; |
| 5105 |
redo B; |
redo B; |
| 5106 |
} elsif ($self->{insertion_mode} eq 'after frameset') { |
} |
| 5107 |
if ($token->{type} eq 'character') { |
} else { |
| 5108 |
|
die "$0: $token->{type}: Unknown token type"; |
| 5109 |
|
} |
| 5110 |
|
} elsif ($self->{insertion_mode} eq 'after frameset') { |
| 5111 |
|
if ($token->{type} eq 'character') { |
| 5112 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 5113 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 5114 |
|
|
| 5129 |
} |
} |
| 5130 |
redo B; |
redo B; |
| 5131 |
} |
} |
| 5132 |
} elsif ($token->{type} eq 'comment') { |
|
| 5133 |
my $comment = $self->{document}->create_comment ($token->{data}); |
die qq[$0: Character "$token->{data}"]; |
| 5134 |
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
} elsif ($token->{type} eq 'start tag') { |
| 5135 |
!!!next-token; |
if ($token->{tag_name} eq 'noframes') { |
| 5136 |
redo B; |
$in_body->($insert_to_current); |
| 5137 |
} elsif ($token->{type} eq 'start tag') { |
redo B; |
| 5138 |
if ($token->{tag_name} eq 'noframes') { |
} else { |
| 5139 |
$in_body->($insert_to_current); |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}); |
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} elsif ($token->{type} eq 'end tag') { |
|
|
if ($token->{tag_name} eq 'html') { |
|
|
$previous_insertion_mode = $self->{insertion_mode}; |
|
|
$self->{insertion_mode} = 'trailing end'; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} else { |
|
|
die "$0: $token->{type}: Unknown token type"; |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'after frameset:'.($token->{tag_name} eq 'end tag' ? '/' : '').$token->{tag_name}); |
|
| 5140 |
## Ignore the token |
## Ignore the token |
| 5141 |
!!!next-token; |
!!!next-token; |
| 5142 |
redo B; |
redo B; |
| 5143 |
|
} |
| 5144 |
## ISSUE: An issue in spec there |
} elsif ($token->{type} eq 'end tag') { |
| 5145 |
|
if ($token->{tag_name} eq 'html') { |
| 5146 |
|
$previous_insertion_mode = $self->{insertion_mode}; |
| 5147 |
|
$self->{insertion_mode} = 'trailing end'; |
| 5148 |
|
!!!next-token; |
| 5149 |
|
redo B; |
| 5150 |
} else { |
} else { |
| 5151 |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
!!!parse-error (type => 'after frameset:/'.$token->{tag_name}); |
| 5152 |
|
## Ignore the token |
| 5153 |
|
!!!next-token; |
| 5154 |
|
redo B; |
| 5155 |
} |
} |
| 5156 |
|
} else { |
| 5157 |
|
die "$0: $token->{type}: Unknown token type"; |
| 5158 |
} |
} |
| 5159 |
|
|
| 5160 |
|
## ISSUE: An issue in spec here |
| 5161 |
} elsif ($self->{insertion_mode} eq 'trailing end') { |
} elsif ($self->{insertion_mode} eq 'trailing end') { |
| 5162 |
## states in the main stage is preserved yet # MUST |
## states in the main stage is preserved yet # MUST |
| 5163 |
|
|
| 5164 |
if ($token->{type} eq 'DOCTYPE') { |
if ($token->{type} eq 'character') { |
|
!!!parse-error (type => 'after html:#DOCTYPE'); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'comment') { |
|
|
my $comment = $self->{document}->create_comment ($token->{data}); |
|
|
$self->{document}->append_child ($comment); |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'character') { |
|
| 5165 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 5166 |
my $data = $1; |
my $data = $1; |
| 5167 |
## As if in the main phase. |
## As if in the main phase. |
| 5182 |
$self->{insertion_mode} = $previous_insertion_mode; |
$self->{insertion_mode} = $previous_insertion_mode; |
| 5183 |
## reprocess |
## reprocess |
| 5184 |
redo B; |
redo B; |
| 5185 |
} elsif ($token->{type} eq 'start tag' or |
} elsif ($token->{type} eq 'start tag') { |
| 5186 |
$token->{type} eq 'end tag') { |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
| 5187 |
!!!parse-error (type => 'after html:'.($token->{type} eq 'end tag' ? '/' : '').$token->{tag_name}); |
$self->{insertion_mode} = $previous_insertion_mode; |
| 5188 |
|
## reprocess |
| 5189 |
|
redo B; |
| 5190 |
|
} elsif ($token->{type} eq 'end tag') { |
| 5191 |
|
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
| 5192 |
$self->{insertion_mode} = $previous_insertion_mode; |
$self->{insertion_mode} = $previous_insertion_mode; |
| 5193 |
## reprocess |
## reprocess |
| 5194 |
redo B; |
redo B; |
|
} elsif ($token->{type} eq 'end-of-file') { |
|
|
## Stop parsing |
|
|
last B; |
|
| 5195 |
} else { |
} else { |
| 5196 |
die "$0: $token->{type}: Unknown token"; |
die "$0: $token->{type}: Unknown token"; |
| 5197 |
} |
} |
| 5198 |
|
} else { |
| 5199 |
|
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
| 5200 |
} |
} |
| 5201 |
} # B |
} # B |
| 5202 |
|
|