Parent Directory
|
Revision Log
++ ChangeLog 21 Sep 2008 05:08:51 -0000 2008-09-21 Wakaba <wakaba@suika.fam.cx> * error-description-source.xml: An error for non-supported charset="" parameter is added. ++ html/WebHACC/Language/ChangeLog 21 Sep 2008 05:09:27 -0000 2008-09-21 Wakaba <wakaba@suika.fam.cx> * HTML.pm (generate_syntax_error_section): Now |charset:not supported| is also an error that might invalidate the validation result.
| 1 | wakaba | 1.1 | package WebHACC::Language::HTML; |
| 2 | use strict; | ||
| 3 | require WebHACC::Language::DOM; | ||
| 4 | push our @ISA, 'WebHACC::Language::DOM'; | ||
| 5 | |||
| 6 | sub new ($) { | ||
| 7 | return bless {}, shift; | ||
| 8 | } # new | ||
| 9 | |||
| 10 | sub generate_syntax_error_section ($) { | ||
| 11 | my $self = shift; | ||
| 12 | |||
| 13 | wakaba | 1.4 | require Message::DOM::DOMImplementation; |
| 14 | wakaba | 1.1 | require Encode; |
| 15 | require Whatpm::HTML; | ||
| 16 | |||
| 17 | my $out = $self->output; | ||
| 18 | wakaba | 1.3 | $out->start_section (role => 'parse-errors'); |
| 19 | $out->start_error_list (role => 'parse-errors'); | ||
| 20 | wakaba | 1.5 | $self->result->layer_applicable ('syntax'); |
| 21 | wakaba | 1.1 | |
| 22 | my $input = $self->input; | ||
| 23 | my $result = $self->result; | ||
| 24 | |||
| 25 | my $onerror = sub { | ||
| 26 | wakaba | 1.7 | my %opt = @_; |
| 27 | $result->add_error (layer => 'syntax', %opt); | ||
| 28 | |||
| 29 | if ($opt{type} eq 'chardecode:no error') { | ||
| 30 | $self->result->layer_uncertain ('encode'); | ||
| 31 | wakaba | 1.12 | } elsif ($opt{type} eq 'chardecode:fallback' or |
| 32 | $opt{type} eq 'charset:not supported') { | ||
| 33 | wakaba | 1.7 | $self->result->layer_uncertain ('charset'); |
| 34 | $self->result->layer_uncertain ('syntax'); | ||
| 35 | $self->result->layer_uncertain ('structure'); | ||
| 36 | $self->result->layer_uncertain ('semantics'); | ||
| 37 | } | ||
| 38 | wakaba | 1.1 | }; |
| 39 | |||
| 40 | wakaba | 1.10 | $self->result->layer_applicable ('charset'); |
| 41 | my $char_checker = sub ($) { | ||
| 42 | require Whatpm::Charset::UnicodeChecker; | ||
| 43 | wakaba | 1.11 | return Whatpm::Charset::UnicodeChecker->new_handle ($_[0], 'html5'); |
| 44 | wakaba | 1.10 | }; # $char_checker |
| 45 | |||
| 46 | wakaba | 1.1 | my $dom = Message::DOM::DOMImplementation->new; |
| 47 | my $doc = $dom->create_document; | ||
| 48 | my $el; | ||
| 49 | my $inner_html_element = $input->{inner_html_element}; | ||
| 50 | if (defined $inner_html_element and length $inner_html_element) { | ||
| 51 | wakaba |