--- test/html-webhacc/cc.cgi 2007/06/27 14:36:45 1.4 +++ test/html-webhacc/cc.cgi 2007/07/01 06:21:46 1.7 @@ -33,6 +33,8 @@ exit; } + load_text_catalog ('en'); ## TODO: conneg + my @nav; print STDOUT qq[Content-Type: text/html; charset=utf-8 @@ -88,13 +90,14 @@ my $onerror = sub { my (%opt) = @_; + my ($cls, $msg) = get_text ($opt{type}, $opt{level}); if ($opt{column} > 0) { - print STDOUT qq[
Line $opt{line} column $opt{column}
\n]; + print STDOUT qq[
Line $opt{line} column $opt{column}
\n]; } else { - $opt{line}--; - print STDOUT qq[
Line $opt{line}
\n]; + $opt{line} = $opt{line} - 1 || 1; + print STDOUT qq[
Line $opt{line}
\n]; } - print STDOUT qq[
@{[htescape $opt{type}]}
\n]; + print STDOUT qq[
$msg
\n]; }; $doc = $dom->create_document; @@ -133,8 +136,7 @@

Parse Errors

-
-]; +
]; push @nav, ['#parse-errors' => 'Parse Error']; my $onerror = sub { @@ -150,8 +152,7 @@ $doc = Message::DOM::XMLParserTemp->parse_byte_stream ($fh => $dom, $onerror, charset => 'utf-8'); - print STDOUT qq[ -
+ print STDOUT qq[
]; } else { @@ -182,28 +183,96 @@

Document Errors

-
-]; +
]; push @nav, ['#document-errors' => 'Document Error']; require Whatpm::ContentChecker; my $onerror = sub { my %opt = @_; - print STDOUT qq[
], - htescape get_node_path ($opt{node}), - "
\n
", htescape $opt{type}, "
\n"; + my ($cls, $msg) = get_text ($opt{type}, $opt{level}); + print STDOUT qq[
] . get_node_link ($opt{node}) . + qq[
\n
], $msg, "
\n"; }; + my $elements; if ($el) { - Whatpm::ContentChecker->check_element ($el, $onerror); + $elements = Whatpm::ContentChecker->check_element ($el, $onerror); } else { - Whatpm::ContentChecker->check_document ($doc, $onerror); + $elements = Whatpm::ContentChecker->check_document ($doc, $onerror); } - print STDOUT qq[ -
+ print STDOUT qq[
]; + + if (@{$elements->{table}}) { + require JSON; + + print STDOUT qq[ +
+

Tables

+ + + + +]; + + my $i = 0; + for my $table_el (@{$elements->{table}}) { + $i++; + print STDOUT qq[

] . + get_node_link ($table_el) . q[

]; + + my $table = Whatpm::HTMLTable->form_table ($table_el); + + for (@{$table->{column_group}}, @{$table->{column}}, $table->{caption}) { + next unless $_; + delete $_->{element}; + } + + for (@{$table->{row_group}}) { + next unless $_; + next unless $_->{element}; + $_->{type} = $_->{element}->manakai_local_name; + delete $_->{element}; + } + + for (@{$table->{cell}}) { + next unless $_; + for (@{$_}) { + next unless $_; + for (@$_) { + $_->{id} = refaddr $_->{element} if defined $_->{element}; + delete $_->{element}; + } + } + } + + print STDOUT '
]; + } + + print STDOUT qq[
]; + } + + if (keys %{$elements->{term}}) { + print STDOUT qq[ +
+

Terms

+ +
+]; + for my $term (sort {$a cmp $b} keys %{$elements->{term}}) { + print STDOUT qq[
@{[htescape $term]}
]; + for (@{$elements->{term}->{$term}}) { + print STDOUT qq[
].get_node_link ($_).qq[
]; + } + } + print STDOUT qq[
]; + } } ## TODO: Show result @@ -226,12 +295,16 @@ my $s = $_[0]; my $i = 1; print STDOUT qq[
    \n]; - while ($$s =~ /\G([^\x0A]*?)\x0D?\x0A/gc) { - print STDOUT qq[
  1. ], htescape $1, "
  2. \n"; - $i++; - } - if ($$s =~ /\G([^\x0A]+)/gc) { - print STDOUT qq[
  3. ], htescape $1, "
  4. \n"; + if (length $$s) { + while ($$s =~ /\G([^\x0A]*?)\x0D?\x0A/gc) { + print STDOUT qq[
  5. ], htescape $1, "
  6. \n"; + $i++; + } + if ($$s =~ /\G([^\x0A]+)/gc) { + print STDOUT qq[
  7. ], htescape $1, "
  8. \n"; + } + } else { + print STDOUT q[
  9. ]; } print STDOUT "
"; } # print_input_string @@ -265,9 +338,11 @@ $r .= ''; } - if ($node->has_child_nodes) { + if ($child->has_child_nodes) { $r .= '
    '; - unshift @node, @{$child->child_nodes}, '
'; + unshift @node, @{$child->child_nodes}, ''; + } else { + $r .= ''; } } elsif ($nt == $child->TEXT_NODE) { $r .= qq'
  • ' . htescape ($child->data) . '
  • '; @@ -276,16 +351,20 @@ } elsif ($nt == $child->COMMENT_NODE) { $r .= qq'
  • <!--' . htescape ($child->data) . '-->
  • '; } elsif ($nt == $child->DOCUMENT_NODE) { - $r .= qq'
  • Document
  • '; + $r .= qq'
  • Document'; + $r .= qq[]; if ($child->has_child_nodes) { - $r .= '
      '; - unshift @node, @{$child->child_nodes}, '
    '; + $r .= '
      '; + unshift @node, @{$child->child_nodes}, '
  • '; } } elsif ($nt == $child->DOCUMENT_TYPE_NODE) { - $r .= qq'
  • <!DOCTYPE>