349 |
my $column = 0; |
my $column = 0; |
350 |
$self->{set_next_input_character} = sub { |
$self->{set_next_input_character} = sub { |
351 |
my $self = shift; |
my $self = shift; |
352 |
|
|
353 |
|
pop @{$self->{prev_input_character}}; |
354 |
|
unshift @{$self->{prev_input_character}}, $self->{next_input_character}; |
355 |
|
|
356 |
$self->{next_input_character} = -1 and return if $i >= length $$s; |
$self->{next_input_character} = -1 and return if $i >= length $$s; |
357 |
$self->{next_input_character} = ord substr $$s, $i++, 1; |
$self->{next_input_character} = ord substr $$s, $i++, 1; |
358 |
$column++; |
$column++; |
381 |
$self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_input_character} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
382 |
} |
} |
383 |
}; |
}; |
384 |
|
$self->{prev_input_character} = [-1, -1, -1]; |
385 |
|
$self->{next_input_character} = -1; |
386 |
|
|
387 |
my $onerror = $_[2] || sub { |
my $onerror = $_[2] || sub { |
388 |
my (%opt) = @_; |
my (%opt) = @_; |
467 |
} else { |
} else { |
468 |
# |
# |
469 |
} |
} |
470 |
|
} elsif ($self->{next_input_character} == 0x002D) { # - |
471 |
|
if ($self->{content_model_flag} eq 'RCDATA' or |
472 |
|
$self->{content_model_flag} eq 'CDATA') { |
473 |
|
unless ($self->{escape}) { |
474 |
|
if ($self->{prev_input_character}->[0] == 0x002D and # - |
475 |
|
$self->{prev_input_character}->[1] == 0x0021 and # ! |
476 |
|
$self->{prev_input_character}->[2] == 0x003C) { # < |
477 |
|
$self->{escape} = 1; |
478 |
|
} |
479 |
|
} |
480 |
|
} |
481 |
|
|
482 |
|
# |
483 |
} elsif ($self->{next_input_character} == 0x003C) { # < |
} elsif ($self->{next_input_character} == 0x003C) { # < |
484 |
if ($self->{content_model_flag} ne 'PLAINTEXT') { |
if ($self->{content_model_flag} eq 'PCDATA' or |
485 |
|
(($self->{content_model_flag} eq 'CDATA' or |
486 |
|
$self->{content_model_flag} eq 'RCDATA') and |
487 |
|
not $self->{escape})) { |
488 |
$self->{state} = 'tag open'; |
$self->{state} = 'tag open'; |
489 |
!!!next-input-character; |
!!!next-input-character; |
490 |
redo A; |
redo A; |
491 |
} else { |
} else { |
492 |
# |
# |
493 |
} |
} |
494 |
|
} elsif ($self->{next_input_character} == 0x003E) { # > |
495 |
|
if ($self->{escape} and |
496 |
|
($self->{content_model_flag} eq 'RCDATA' or |
497 |
|
$self->{content_model_flag} eq 'CDATA')) { |
498 |
|
if ($self->{prev_input_character}->[0] == 0x002D and # - |
499 |
|
$self->{prev_input_character}->[1] == 0x002D) { # - |
500 |
|
delete $self->{escape}; |
501 |
|
} |
502 |
|
} |
503 |
|
|
504 |
|
# |
505 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
506 |
!!!emit ({type => 'end-of-file'}); |
!!!emit ({type => 'end-of-file'}); |
507 |
last A; ## TODO: ok? |
last A; ## TODO: ok? |
1957 |
? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
1958 |
->append_child ($style_el); |
->append_child ($style_el); |
1959 |
$self->{content_model_flag} = 'CDATA'; |
$self->{content_model_flag} = 'CDATA'; |
1960 |
|
delete $self->{escape}; # MUST |
1961 |
|
|
1962 |
my $text = ''; |
my $text = ''; |
1963 |
!!!next-token; |
!!!next-token; |
1986 |
## TODO: mark as "parser-inserted" |
## TODO: mark as "parser-inserted" |
1987 |
|
|
1988 |
$self->{content_model_flag} = 'CDATA'; |
$self->{content_model_flag} = 'CDATA'; |
1989 |
|
delete $self->{escape}; # MUST |
1990 |
|
|
1991 |
my $text = ''; |
my $text = ''; |
1992 |
!!!next-token; |
!!!next-token; |
2276 |
(defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
(defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
2277 |
->append_child ($title_el); |
->append_child ($title_el); |
2278 |
$self->{content_model_flag} = 'RCDATA'; |
$self->{content_model_flag} = 'RCDATA'; |
2279 |
|
delete $self->{escape}; # MUST |
2280 |
|
|
2281 |
my $text = ''; |
my $text = ''; |
2282 |
!!!next-token; |
!!!next-token; |
2623 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
2624 |
|
|
2625 |
$self->{content_model_flag} = 'CDATA'; |
$self->{content_model_flag} = 'CDATA'; |
2626 |
|
delete $self->{escape}; # MUST |
2627 |
|
|
2628 |
!!!next-token; |
!!!next-token; |
2629 |
return; |
return; |
2740 |
} else { |
} else { |
2741 |
$self->{content_model_flag} = 'CDATA'; |
$self->{content_model_flag} = 'CDATA'; |
2742 |
} |
} |
2743 |
|
delete $self->{escape}; # MUST |
2744 |
|
|
2745 |
$insert->($el); |
$insert->($el); |
2746 |
|
|
3163 |
(defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
(defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
3164 |
->append_child ($title_el); |
->append_child ($title_el); |
3165 |
$self->{content_model_flag} = 'RCDATA'; |
$self->{content_model_flag} = 'RCDATA'; |
3166 |
|
delete $self->{escape}; # MUST |
3167 |
|
|
3168 |
my $text = ''; |
my $text = ''; |
3169 |
!!!next-token; |
!!!next-token; |