3647 |
|
|
3648 |
## ISSUE: An issue in the spec. |
## ISSUE: An issue in the spec. |
3649 |
} elsif ($self->{insertion_mode} eq 'in body' or |
} elsif ($self->{insertion_mode} eq 'in body' or |
3650 |
|
$self->{insertion_mode} eq 'in cell' or |
3651 |
$self->{insertion_mode} eq 'in caption') { |
$self->{insertion_mode} eq 'in caption') { |
3652 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
3653 |
## NOTE: There is a code clone of "character in body". |
## NOTE: There is a code clone of "character in body". |
3661 |
if ({ |
if ({ |
3662 |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
3663 |
td => 1, tfoot => 1, th => 1, thead => 1, tr => 1, |
td => 1, tfoot => 1, th => 1, thead => 1, tr => 1, |
3664 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}}) { |
3665 |
$self->{insertion_mode} eq 'in caption') { |
if ($self->{insertion_mode} eq 'in cell') { |
3666 |
!!!parse-error (type => 'not closed:caption'); |
## have an element in table scope |
3667 |
|
my $tn; |
3668 |
## As if </caption> |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
3669 |
## have a table element in table scope |
my $node = $self->{open_elements}->[$_]; |
3670 |
my $i; |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
3671 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
$tn = $node->[1]; |
3672 |
my $node = $self->{open_elements}->[$_]; |
last INSCOPE; |
3673 |
if ($node->[1] eq 'caption') { |
} elsif ({ |
3674 |
$i = $_; |
table => 1, html => 1, |
3675 |
last INSCOPE; |
}->{$node->[1]}) { |
3676 |
} elsif ({ |
last INSCOPE; |
3677 |
table => 1, html => 1, |
} |
3678 |
}->{$node->[1]}) { |
} # INSCOPE |
3679 |
last INSCOPE; |
unless (defined $tn) { |
3680 |
} |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
3681 |
} # INSCOPE |
## Ignore the token |
3682 |
unless (defined $i) { |
!!!next-token; |
3683 |
!!!parse-error (type => 'unmatched end tag:caption'); |
redo B; |
3684 |
## Ignore the token |
} |
3685 |
!!!next-token; |
|
3686 |
redo B; |
## Close the cell |
|
} |
|
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
3687 |
!!!back-token; # <?> |
!!!back-token; # <?> |
3688 |
$token = {type => 'end tag', tag_name => 'caption'}; |
$token = {type => 'end tag', tag_name => $tn}; |
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
3689 |
redo B; |
redo B; |
3690 |
|
} elsif ($self->{insertion_mode} eq 'in caption') { |
3691 |
|
!!!parse-error (type => 'not closed:caption'); |
3692 |
|
|
3693 |
|
## As if </caption> |
3694 |
|
## have a table element in table scope |
3695 |
|
my $i; |
3696 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
3697 |
|
my $node = $self->{open_elements}->[$_]; |
3698 |
|
if ($node->[1] eq 'caption') { |
3699 |
|
$i = $_; |
3700 |
|
last INSCOPE; |
3701 |
|
} elsif ({ |
3702 |
|
table => 1, html => 1, |
3703 |
|
}->{$node->[1]}) { |
3704 |
|
last INSCOPE; |
3705 |
|
} |
3706 |
|
} # INSCOPE |
3707 |
|
unless (defined $i) { |
3708 |
|
!!!parse-error (type => 'unmatched end tag:caption'); |
3709 |
|
## Ignore the token |
3710 |
|
!!!next-token; |
3711 |
|
redo B; |
3712 |
|
} |
3713 |
|
|
3714 |
|
## generate implied end tags |
3715 |
|
if ({ |
3716 |
|
dd => 1, dt => 1, li => 1, p => 1, |
3717 |
|
td => 1, th => 1, tr => 1, |
3718 |
|
tbody => 1, tfoot=> 1, thead => 1, |
3719 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
3720 |
|
!!!back-token; # <?> |
3721 |
|
$token = {type => 'end tag', tag_name => 'caption'}; |
3722 |
|
!!!back-token; |
3723 |
|
$token = {type => 'end tag', |
3724 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
3725 |
|
redo B; |
3726 |
|
} |
3727 |
|
|
3728 |
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
3729 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
3730 |
|
} |
3731 |
|
|
3732 |
|
splice @{$self->{open_elements}}, $i; |
3733 |
|
|
3734 |
|
$clear_up_to_marker->(); |
3735 |
|
|
3736 |
|
$self->{insertion_mode} = 'in table'; |
3737 |
|
|
3738 |
|
## reprocess |
3739 |
|
redo B; |
3740 |
|
} else { |
3741 |
|
# |
3742 |
} |
} |
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in table'; |
|
|
|
|
|
## reprocess |
|
|
redo B; |
|
3743 |
} else { |
} else { |
3744 |
# |
# |
3745 |
} |
} |
3746 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
3747 |
if ($token->{tag_name} eq 'caption' and |
if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') { |
3748 |
$self->{insertion_mode} eq 'in caption') { |
if ($self->{insertion_mode} eq 'in cell') { |
3749 |
## have a table element in table scope |
## have an element in table scope |
3750 |
|
my $i; |
3751 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
3752 |
|
my $node = $self->{open_elements}->[$_]; |
3753 |
|
if ($node->[1] eq $token->{tag_name}) { |
3754 |
|
$i = $_; |
3755 |
|
last INSCOPE; |
3756 |
|
} elsif ({ |
3757 |
|
table => 1, html => 1, |
3758 |
|
}->{$node->[1]}) { |
3759 |
|
last INSCOPE; |
3760 |
|
} |
3761 |
|
} # INSCOPE |
3762 |
|
unless (defined $i) { |
3763 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
3764 |
|
## Ignore the token |
3765 |
|
!!!next-token; |
3766 |
|
redo B; |
3767 |
|
} |
3768 |
|
|
3769 |
|
## generate implied end tags |
3770 |
|
if ({ |
3771 |
|
dd => 1, dt => 1, li => 1, p => 1, |
3772 |
|
td => ($token->{tag_name} eq 'th'), |
3773 |
|
th => ($token->{tag_name} eq 'td'), |
3774 |
|
tr => 1, |
3775 |
|
tbody => 1, tfoot=> 1, thead => 1, |
3776 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
3777 |
|
!!!back-token; |
3778 |
|
$token = {type => 'end tag', |
3779 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
3780 |
|
redo B; |
3781 |
|
} |
3782 |
|
|
3783 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
3784 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
3785 |
|
} |
3786 |
|
|
3787 |
|
splice @{$self->{open_elements}}, $i; |
3788 |
|
|
3789 |
|
$clear_up_to_marker->(); |
3790 |
|
|
3791 |
|
$self->{insertion_mode} = 'in row'; |
3792 |
|
|
3793 |
|
!!!next-token; |
3794 |
|
redo B; |
3795 |
|
} elsif ($self->{insertion_mode} eq 'in caption') { |
3796 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
3797 |
|
## Ignore the token |
3798 |
|
!!!next-token; |
3799 |
|
redo B; |
3800 |
|
} else { |
3801 |
|
# |
3802 |
|
} |
3803 |
|
} elsif ($token->{tag_name} eq 'caption') { |
3804 |
|
if ($self->{insertion_mode} eq 'in caption') { |
3805 |
|
## have a table element in table scope |
3806 |
|
my $i; |
3807 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
3808 |
|
my $node = $self->{open_elements}->[$_]; |
3809 |
|
if ($node->[1] eq $token->{tag_name}) { |
3810 |
|
$i = $_; |
3811 |
|
last INSCOPE; |
3812 |
|
} elsif ({ |
3813 |
|
table => 1, html => 1, |
3814 |
|
}->{$node->[1]}) { |
3815 |
|
last INSCOPE; |
3816 |
|
} |
3817 |
|
} # INSCOPE |
3818 |
|
unless (defined $i) { |
3819 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
3820 |
|
## Ignore the token |
3821 |
|
!!!next-token; |
3822 |
|
redo B; |
3823 |
|
} |
3824 |
|
|
3825 |
|
## generate implied end tags |
3826 |
|
if ({ |
3827 |
|
dd => 1, dt => 1, li => 1, p => 1, |
3828 |
|
td => 1, th => 1, tr => 1, |
3829 |
|
tbody => 1, tfoot=> 1, thead => 1, |
3830 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
3831 |
|
!!!back-token; |
3832 |
|
$token = {type => 'end tag', |
3833 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
3834 |
|
redo B; |
3835 |
|
} |
3836 |
|
|
3837 |
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
3838 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
3839 |
|
} |
3840 |
|
|
3841 |
|
splice @{$self->{open_elements}}, $i; |
3842 |
|
|
3843 |
|
$clear_up_to_marker->(); |
3844 |
|
|
3845 |
|
$self->{insertion_mode} = 'in table'; |
3846 |
|
|
3847 |
|
!!!next-token; |
3848 |
|
redo B; |
3849 |
|
} elsif ($self->{insertion_mode} eq 'in cell') { |
3850 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
3851 |
|
## Ignore the token |
3852 |
|
!!!next-token; |
3853 |
|
redo B; |
3854 |
|
} else { |
3855 |
|
# |
3856 |
|
} |
3857 |
|
} elsif ({ |
3858 |
|
table => 1, tbody => 1, tfoot => 1, |
3859 |
|
thead => 1, tr => 1, |
3860 |
|
}->{$token->{tag_name}} and |
3861 |
|
$self->{insertion_mode} eq 'in cell') { |
3862 |
|
## have an element in table scope |
3863 |
my $i; |
my $i; |
3864 |
|
my $tn; |
3865 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
3866 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
3867 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
3868 |
$i = $_; |
$i = $_; |
3869 |
last INSCOPE; |
last INSCOPE; |
3870 |
|
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
3871 |
|
$tn = $node->[1]; |
3872 |
|
## NOTE: There is exactly one |td| or |th| element |
3873 |
|
## in scope in the stack of open elements by definition. |
3874 |
} elsif ({ |
} elsif ({ |
3875 |
table => 1, html => 1, |
table => 1, html => 1, |
3876 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
3883 |
!!!next-token; |
!!!next-token; |
3884 |
redo B; |
redo B; |
3885 |
} |
} |
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in table'; |
|
3886 |
|
|
3887 |
!!!next-token; |
## Close the cell |
3888 |
|
!!!back-token; # </?> |
3889 |
|
$token = {type => 'end tag', tag_name => $tn}; |
3890 |
redo B; |
redo B; |
3891 |
} elsif ($token->{tag_name} eq 'table' and |
} elsif ($token->{tag_name} eq 'table' and |
3892 |
$self->{insertion_mode} eq 'in caption') { |
$self->{insertion_mode} eq 'in caption') { |
3940 |
## reprocess |
## reprocess |
3941 |
redo B; |
redo B; |
3942 |
} elsif ({ |
} elsif ({ |
3943 |
body => 1, col => 1, colgroup => 1, |
body => 1, col => 1, colgroup => 1, html => 1, |
3944 |
html => 1, tbody => 1, td => 1, tfoot => 1, |
}->{$token->{tag_name}}) { |
3945 |
th => 1, thead => 1, tr => 1, |
if ($self->{insertion_mode} eq 'in cell' or |
3946 |
|
$self->{insertion_mode} eq 'in caption') { |
3947 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
3948 |
|
## Ignore the token |
3949 |
|
!!!next-token; |
3950 |
|
redo B; |
3951 |
|
} else { |
3952 |
|
# |
3953 |
|
} |
3954 |
|
} elsif ({ |
3955 |
|
tbody => 1, tfoot => 1, |
3956 |
|
thead => 1, tr => 1, |
3957 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}} and |
3958 |
$self->{insertion_mode} eq 'in caption') { |
$self->{insertion_mode} eq 'in caption') { |
3959 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
3966 |
} else { |
} else { |
3967 |
# |
# |
3968 |
} |
} |
3969 |
|
|
3970 |
$in_body->($insert_to_current); |
$in_body->($insert_to_current); |
3971 |
redo B; |
redo B; |
3972 |
} elsif ($self->{insertion_mode} eq 'in table') { |
} elsif ($self->{insertion_mode} eq 'in table') { |
4830 |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
4831 |
$in_body->($insert_to_foster); |
$in_body->($insert_to_foster); |
4832 |
redo B; |
redo B; |
|
} elsif ($self->{insertion_mode} eq 'in cell') { |
|
|
if ($token->{type} eq 'character') { |
|
|
## NOTE: This is a code clone of "character in body". |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ({ |
|
|
caption => 1, col => 1, colgroup => 1, |
|
|
tbody => 1, td => 1, tfoot => 1, th => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## have an element in table scope |
|
|
my $tn; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
|
$tn = $node->[1]; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $tn) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Close the cell |
|
|
!!!back-token; # <?> |
|
|
$token = {type => 'end tag', tag_name => $tn}; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} elsif ($token->{type} eq 'end tag') { |
|
|
if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') { |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => ($token->{tag_name} eq 'th'), |
|
|
th => ($token->{tag_name} eq 'td'), |
|
|
tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in row'; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
body => 1, caption => 1, col => 1, |
|
|
colgroup => 1, html => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, tbody => 1, tfoot => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
my $tn; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
|
$tn = $node->[1]; |
|
|
## NOTE: There is exactly one |td| or |th| element |
|
|
## in scope in the stack of open elements by definition. |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Close the cell |
|
|
!!!back-token; # </?> |
|
|
$token = {type => 'end tag', tag_name => $tn}; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} else { |
|
|
# |
|
|
} |
|
|
|
|
|
$in_body->($insert_to_current); |
|
|
redo B; |
|
4833 |
} elsif ($self->{insertion_mode} eq 'in select') { |
} elsif ($self->{insertion_mode} eq 'in select') { |
4834 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
4835 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |