/[suikacvs]/markup/html/whatpm/Whatpm/HTML.pm.src
Suika

Diff of /markup/html/whatpm/Whatpm/HTML.pm.src

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.172 by wakaba, Sun Sep 14 03:07:58 2008 UTC revision 1.177 by wakaba, Sun Sep 14 09:05:54 2008 UTC
# Line 561  sub parse_byte_stream ($$$$;$$) { Line 561  sub parse_byte_stream ($$$$;$$) {
561    my $char_onerror = sub {    my $char_onerror = sub {
562      my (undef, $type, %opt) = @_;      my (undef, $type, %opt) = @_;
563      !!!parse-error (layer => 'encode',      !!!parse-error (layer => 'encode',
564                      %opt, type => $type,                      line => $self->{line}, column => $self->{column} + 1,
565                      line => $self->{line}, column => $self->{column} + 1);                      %opt, type => $type);
566      if ($opt{octets}) {      if ($opt{octets}) {
567        ${$opt{octets}} = "\x{FFFD}"; # relacement character        ${$opt{octets}} = "\x{FFFD}"; # relacement character
568      }      }
# Line 1743  sub _get_next_token ($) { Line 1743  sub _get_next_token ($) {
1743        } else {        } else {
1744          !!!cp (100);          !!!cp (100);
1745          $self->{current_attribute}->{value} .= chr ($self->{next_char});          $self->{current_attribute}->{value} .= chr ($self->{next_char});
1746            $self->{read_until}->($self->{current_attribute}->{value},
1747                                  q["&],
1748                                  length $self->{current_attribute}->{value});
1749    
1750          ## Stay in the state          ## Stay in the state
1751          !!!next-input-character;          !!!next-input-character;
1752          redo A;          redo A;
# Line 1790  sub _get_next_token ($) { Line 1794  sub _get_next_token ($) {
1794        } else {        } else {
1795          !!!cp (106);          !!!cp (106);
1796          $self->{current_attribute}->{value} .= chr ($self->{next_char});          $self->{current_attribute}->{value} .= chr ($self->{next_char});
1797            $self->{read_until}->($self->{current_attribute}->{value},
1798                                  q['&],
1799                                  length $self->{current_attribute}->{value});
1800    
1801          ## Stay in the state          ## Stay in the state
1802          !!!next-input-character;          !!!next-input-character;
1803          redo A;          redo A;
# Line 1872  sub _get_next_token ($) { Line 1880  sub _get_next_token ($) {
1880            !!!cp (116);            !!!cp (116);
1881          }          }
1882          $self->{current_attribute}->{value} .= chr ($self->{next_char});          $self->{current_attribute}->{value} .= chr ($self->{next_char});
1883            $self->{read_until}->($self->{current_attribute}->{value},
1884                                  q["'=& >],
1885                                  length $self->{current_attribute}->{value});
1886    
1887          ## Stay in the state          ## Stay in the state
1888          !!!next-input-character;          !!!next-input-character;
1889          redo A;          redo A;
# Line 2016  sub _get_next_token ($) { Line 2028  sub _get_next_token ($) {
2028        } else {        } else {
2029          !!!cp (126);          !!!cp (126);
2030          $self->{current_token}->{data} .= chr ($self->{next_char}); # comment          $self->{current_token}->{data} .= chr ($self->{next_char}); # comment
2031            $self->{read_until}->($self->{current_token}->{data},
2032                                  q[>],
2033                                  length $self->{current_token}->{data});
2034    
2035          ## Stay in the state.          ## Stay in the state.
2036          !!!next-input-character;          !!!next-input-character;
2037          redo A;          redo A;
# Line 2250  sub _get_next_token ($) { Line 2266  sub _get_next_token ($) {
2266        } else {        } else {
2267          !!!cp (147);          !!!cp (147);
2268          $self->{current_token}->{data} .= chr ($self->{next_char}); # comment          $self->{current_token}->{data} .= chr ($self->{next_char}); # comment
2269            $self->{read_until}->($self->{current_token}->{data},
2270                                  q[-],
2271                                  length $self->{current_token}->{data});
2272    
2273          ## Stay in the state          ## Stay in the state
2274          !!!next-input-character;          !!!next-input-character;
2275          redo A;          redo A;
# Line 2615  sub _get_next_token ($) { Line 2635  sub _get_next_token ($) {
2635          !!!cp (190);          !!!cp (190);
2636          $self->{current_token}->{public_identifier} # DOCTYPE          $self->{current_token}->{public_identifier} # DOCTYPE
2637              .= chr $self->{next_char};              .= chr $self->{next_char};
2638            $self->{read_until}->($self->{current_token}->{public_identifier},
2639                                  q[">],
2640                                  length $self->{current_token}->{public_identifier});
2641    
2642          ## Stay in the state          ## Stay in the state
2643          !!!next-input-character;          !!!next-input-character;
2644          redo A;          redo A;
# Line 2651  sub _get_next_token ($) { Line 2675  sub _get_next_token ($) {
2675          !!!cp (194);          !!!cp (194);
2676          $self->{current_token}->{public_identifier} # DOCTYPE          $self->{current_token}->{public_identifier} # DOCTYPE
2677              .= chr $self->{next_char};              .= chr $self->{next_char};
2678            $self->{read_until}->($self->{current_token}->{public_identifier},
2679                                  q['>],
2680                                  length $self->{current_token}->{public_identifier});
2681    
2682          ## Stay in the state          ## Stay in the state
2683          !!!next-input-character;          !!!next-input-character;
2684          redo A;          redo A;
# Line 2787  sub _get_next_token ($) { Line 2815  sub _get_next_token ($) {
2815          !!!cp (210);          !!!cp (210);
2816          $self->{current_token}->{system_identifier} # DOCTYPE          $self->{current_token}->{system_identifier} # DOCTYPE
2817              .= chr $self->{next_char};              .= chr $self->{next_char};
2818            $self->{read_until}->($self->{current_token}->{system_identifier},
2819                                  q[">],
2820                                  length $self->{current_token}->{system_identifier});
2821    
2822          ## Stay in the state          ## Stay in the state
2823          !!!next-input-character;          !!!next-input-character;
2824          redo A;          redo A;
# Line 2823  sub _get_next_token ($) { Line 2855  sub _get_next_token ($) {
2855          !!!cp (214);          !!!cp (214);
2856          $self->{current_token}->{system_identifier} # DOCTYPE          $self->{current_token}->{system_identifier} # DOCTYPE
2857              .= chr $self->{next_char};              .= chr $self->{next_char};
2858            $self->{read_until}->($self->{current_token}->{system_identifier},
2859                                  q['>],
2860                                  length $self->{current_token}->{system_identifier});
2861    
2862          ## Stay in the state          ## Stay in the state
2863          !!!next-input-character;          !!!next-input-character;
2864          redo A;          redo A;
# Line 2883  sub _get_next_token ($) { Line 2919  sub _get_next_token ($) {
2919          redo A;          redo A;
2920        } else {        } else {
2921          !!!cp (221);          !!!cp (221);
2922            my $s = '';
2923            $self->{read_until}->($s, q[>], 0);
2924    
2925          ## Stay in the state          ## Stay in the state
2926          !!!next-input-character;          !!!next-input-character;
2927          redo A;          redo A;
# Line 2911  sub _get_next_token ($) { Line 2950  sub _get_next_token ($) {
2950        } else {        } else {
2951          !!!cp (221.4);          !!!cp (221.4);
2952          $self->{current_token}->{data} .= chr $self->{next_char};          $self->{current_token}->{data} .= chr $self->{next_char};
2953            $self->{read_until}->($self->{current_token}->{data},
2954                                  q<]>,
2955                                  length $self->{current_token}->{data});
2956    
2957          ## Stay in the state.          ## Stay in the state.
2958          !!!next-input-character;          !!!next-input-character;
2959          redo A;          redo A;
# Line 3297  sub _get_next_token ($) { Line 3340  sub _get_next_token ($) {
3340          !!!cp (1026);          !!!cp (1026);
3341          !!!parse-error (type => 'bare ero',          !!!parse-error (type => 'bare ero',
3342                          line => $self->{line_prev},                          line => $self->{line_prev},
3343                          column => $self->{column_prev});                          column => $self->{column_prev} - length $self->{state_keyword});
3344          $data = '&' . $self->{state_keyword};          $data = '&' . $self->{state_keyword};
3345          #          #
3346        }        }
# Line 4435  sub _tree_construction_main ($) { Line 4478  sub _tree_construction_main ($) {
4478            unless ($self->{insertion_mode} == BEFORE_HEAD_IM) {            unless ($self->{insertion_mode} == BEFORE_HEAD_IM) {
4479              !!!cp ('t88.2');              !!!cp ('t88.2');
4480              $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);              $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
4481                #
4482            } else {            } else {
4483              !!!cp ('t88.1');              !!!cp ('t88.1');
4484              ## Ignore the token.              ## Ignore the token.
4485              !!!next-token;              #
             next B;  
4486            }            }
4487            unless (length $token->{data}) {            unless (length $token->{data}) {
4488              !!!cp ('t88');              !!!cp ('t88');
4489              !!!next-token;              !!!next-token;
4490              next B;              next B;
4491            }            }
4492    ## TODO: set $token->{column} appropriately
4493          }          }
4494    
4495          if ($self->{insertion_mode} == BEFORE_HEAD_IM) {          if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
# Line 7690  sub _tree_construction_main ($) { Line 7734  sub _tree_construction_main ($) {
7734    ## TODO: script stuffs    ## TODO: script stuffs
7735  } # _tree_construct_main  } # _tree_construct_main
7736    
7737  sub set_inner_html ($$$;$) {  sub set_inner_html ($$$$;$) {
7738    my $class = shift;    my $class = shift;
7739    my $node = shift;    my $node = shift;
7740    my $s = \$_[0];    #my $s = \$_[0];
7741    my $onerror = $_[1];    my $onerror = $_[1];
7742    my $get_wrapper = $_[2] || sub ($) { return $_[0] };    my $get_wrapper = $_[2] || sub ($) { return $_[0] };
7743    
# Line 7714  sub set_inner_html ($$$;$) { Line 7758  sub set_inner_html ($$$;$) {
7758      }      }
7759    
7760      ## Step 3, 4, 5 # MUST      ## Step 3, 4, 5 # MUST
7761      $class->parse_char_string ($$s => $node, $onerror, $get_wrapper);      $class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper);
7762    } elsif ($nt == 1) {    } elsif ($nt == 1) {
7763      ## TODO: If non-html element      ## TODO: If non-html element
7764    
# Line 7733  sub set_inner_html ($$$;$) { Line 7777  sub set_inner_html ($$$;$) {
7777      my $i = 0;      my $i = 0;
7778      $p->{line_prev} = $p->{line} = 1;      $p->{line_prev} = $p->{line} = 1;
7779      $p->{column_prev} = $p->{column} = 0;      $p->{column_prev} = $p->{column} = 0;
7780        require Whatpm::Charset::DecodeHandle;
7781        my $input = Whatpm::Charset::DecodeHandle::CharString->new (\($_[0]));
7782        $input = $get_wrapper->($input);
7783      $p->{set_next_char} = sub {      $p->{set_next_char} = sub {
7784        my $self = shift;        my $self = shift;
7785    
7786        pop @{$self->{prev_char}};        pop @{$self->{prev_char}};
7787        unshift @{$self->{prev_char}}, $self->{next_char};        unshift @{$self->{prev_char}}, $self->{next_char};
7788    
7789        $self->{next_char} = -1 and return if $i >= length $$s;        my $char;
7790        $self->{next_char} = ord substr $$s, $i++, 1;        if (defined $self->{next_next_char}) {
7791            $char = $self->{next_next_char};
7792            delete $self->{next_next_char};
7793          } else {
7794            $char = $input->getc;
7795          }
7796          $self->{next_char} = -1 and return unless defined $char;
7797          $self->{next_char} = ord $char;
7798    
7799        ($p->{line_prev}, $p->{column_prev}) = ($p->{line}, $p->{column});        ($p->{line_prev}, $p->{column_prev}) = ($p->{line}, $p->{column});
7800        $p->{column}++;        $p->{column}++;
# Line 7750  sub set_inner_html ($$$;$) { Line 7804  sub set_inner_html ($$$;$) {
7804          $p->{column} = 0;          $p->{column} = 0;
7805          !!!cp ('i1');          !!!cp ('i1');
7806        } elsif ($self->{next_char} == 0x000D) { # CR        } elsif ($self->{next_char} == 0x000D) { # CR
7807          $i++ if substr ($$s, $i, 1) eq "\x0A";  ## TODO: support for abort/streaming
7808            my $next = $input->getc;
7809            if (defined $next and $next ne "\x0A") {
7810              $self->{next_next_char} = $next;
7811            }
7812          $self->{next_char} = 0x000A; # LF # MUST          $self->{next_char} = 0x000A; # LF # MUST
7813          $p->{line}++;          $p->{line}++;
7814          $p->{column} = 0;          $p->{column} = 0;
# Line 7796  sub set_inner_html ($$$;$) { Line 7854  sub set_inner_html ($$$;$) {
7854      $p->{next_char} = -1;      $p->{next_char} = -1;
7855    
7856      $p->{read_until} = sub {      $p->{read_until} = sub {
7857        ## TODO: ...        #my ($scalar, $specials_range, $offset) = @_;
7858        return 0;        my $specials_range = $_[1];
7859      }; # $p->{read_until};        return 0 if defined $p->{next_next_char};
7860          my $count = $input->manakai_read_until
7861            ($_[0],
7862             qr/(?![$specials_range\x{FDD0}-\x{FDDF}\x{FFFE}\x{FFFF}\x{1FFFE}\x{1FFFF}\x{2FFFE}\x{2FFFF}\x{3FFFE}\x{3FFFF}\x{4FFFE}\x{4FFFF}\x{5FFFE}\x{5FFFF}\x{6FFFE}\x{6FFFF}\x{7FFFE}\x{7FFFF}\x{8FFFE}\x{8FFFF}\x{9FFFE}\x{9FFFF}\x{AFFFE}\x{AFFFF}\x{BFFFE}\x{BFFFF}\x{CFFFE}\x{CFFFF}\x{DFFFE}\x{DFFFF}\x{EFFFE}\x{EFFFF}\x{FFFFE}\x{FFFFF}])[\x20-\x7E\xA0-\x{D7FF}\x{E000}-\x{10FFFD}]/,
7863             $_[2]);
7864          if ($count) {
7865            $p->{column} += $count;
7866            $p->{column_prev} += $count;
7867            $p->{prev_char} = [-1, -1, -1];
7868            $p->{next_char} = -1;
7869          }
7870          return $count;
7871        }; # $p->{read_until}
7872    
7873      my $ponerror = $onerror || sub {      my $ponerror = $onerror || sub {
7874        my (%opt) = @_;        my (%opt) = @_;

Legend:
Removed from v.1.172  
changed lines
  Added in v.1.177

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24