--- test/html-webhacc/cc.cgi 2007/07/15 16:39:10 1.9 +++ test/html-webhacc/cc.cgi 2007/07/17 13:52:54 1.13 @@ -15,7 +15,9 @@ $s =~ s//>/g; $s =~ s/"/"/g; - $s =~ s!([\x00-\x09\x0B-\x1F\x7F-\x80])!sprintf 'U+%04X', ord $1!ge; + $s =~ s{([\x00-\x09\x0B-\x1F\x7F-\xA0\x{FEFF}\x{FFFC}-\x{FFFF}])}{ + sprintf 'U+%04X', ord $1; + }ge; return $s; } # htescape @@ -28,6 +30,8 @@ exit; } + binmode STDOUT, ':utf8'; + require Message::DOM::DOMImplementation; my $dom = Message::DOM::DOMImplementation->new; @@ -46,7 +50,8 @@ -

Web Document Conformance Checker (beta)

+

Web Document Conformance Checker +(beta)

@@ -80,6 +85,8 @@ if ($input->{media_type} eq 'text/html') { require Encode; require Whatpm::HTML; + + $input->{charset} ||= 'ISO-8859-1'; ## TODO: for now. my $t = Encode::decode ($input->{charset}, $input->{s}); @@ -87,22 +94,21 @@

Parse Errors

-
-]; +
]; push @nav, ['#parse-errors' => 'Parse Error']; my $onerror = sub { my (%opt) = @_; - my ($cls, $msg) = get_text ($opt{type}, $opt{level}); + my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); if ($opt{column} > 0) { print STDOUT qq[
Line $opt{line} column $opt{column}
\n]; } else { $opt{line} = $opt{line} - 1 || 1; print STDOUT qq[
Line $opt{line}
\n]; } - $opt{type} =~ tr/ /-/; - $opt{type} =~ s/\|/%7C/g; - $msg .= qq[ [Description]]; + $type =~ tr/ /-/; + $type =~ s/\|/%7C/g; + $msg .= qq[ [Description]]; print STDOUT qq[
$msg
\n]; }; @@ -115,8 +121,7 @@ Whatpm::HTML->parse_string ($t => $doc, $onerror); } - print STDOUT qq[ -
+ print STDOUT qq[
]; @@ -185,11 +190,10 @@ require Whatpm::ContentChecker; my $onerror = sub { my %opt = @_; - my ($cls, $msg) = get_text ($opt{type}, $opt{level}); - $opt{type} = $opt{level} . ':' . $opt{type} if defined $opt{level}; - $opt{type} =~ tr/ /-/; - $opt{type} =~ s/\|/%7C/g; - $msg .= qq[ [Description]]; + my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); + $type =~ tr/ /-/; + $type =~ s/\|/%7C/g; + $msg .= qq[ [Description]]; print STDOUT qq[
] . get_node_link ($opt{node}) . qq[
\n
], $msg, "
\n"; }; @@ -224,7 +228,9 @@ $i++; print STDOUT qq[

] . get_node_link ($table_el) . q[

]; - + + ## TODO: Make |ContentChecker| return |form_table| result + ## so that this script don't have to run the algorithm twice. my $table = Whatpm::HTMLTable->form_table ($table_el); for (@{$table->{column_group}}, @{$table->{column}}, $table->{caption}) { @@ -246,6 +252,7 @@ for (@$_) { $_->{id} = refaddr $_->{element} if defined $_->{element}; delete $_->{element}; + $_->{is_header} = $_->{is_header} ? 1 : 0; } } } @@ -258,6 +265,22 @@ print STDOUT qq[
]; } + if (keys %{$elements->{id}}) { + print STDOUT qq[ +
+

Identifiers

+ +
+]; + for my $id (sort {$a cmp $b} keys %{$elements->{id}}) { + print STDOUT qq[
@{[htescape $id]}
]; + for (@{$elements->{id}->{$id}}) { + print STDOUT qq[
].get_node_link ($_).qq[
]; + } + } + print STDOUT qq[
]; + } + if (keys %{$elements->{term}}) { print STDOUT qq[
@@ -493,14 +516,16 @@ { if (defined $Msg->{$type}) { my $msg = $Msg->{$type}->[1]; - $msg =~ s/\$([0-9]+)/defined $arg[$1] ? htescape ($arg[$1]) : '(undef)'/ge; - return ($Msg->{$type}->[0], $msg); + $msg =~ s{\$([0-9]+)}{ + defined $arg[$1] ? htescape ($arg[$1]) : '(undef)'; + }ge; + return ($type, $Msg->{$type}->[0], $msg); } elsif ($type =~ s/:([^:]*)$//) { unshift @arg, $1; redo; } } - return ('', htescape ($_[0])); + return ($type, '', htescape ($_[0])); } # get_text } @@ -667,4 +692,4 @@ =cut -## $Date: 2007/07/15 16:39:10 $ +## $Date: 2007/07/17 13:52:54 $