| 20 |
return $s; |
return $s; |
| 21 |
} # htescape |
} # htescape |
| 22 |
|
|
| 23 |
|
my @nav; |
| 24 |
|
my %time; |
| 25 |
|
require Message::DOM::DOMImplementation; |
| 26 |
|
my $dom = Message::DOM::DOMImplementation->new; |
| 27 |
|
{ |
| 28 |
use Message::CGI::HTTP; |
use Message::CGI::HTTP; |
| 29 |
my $http = Message::CGI::HTTP->new; |
my $http = Message::CGI::HTTP->new; |
| 30 |
|
|
| 36 |
binmode STDOUT, ':utf8'; |
binmode STDOUT, ':utf8'; |
| 37 |
$| = 1; |
$| = 1; |
| 38 |
|
|
|
require Message::DOM::DOMImplementation; |
|
|
my $dom = Message::DOM::DOMImplementation->new; |
|
|
|
|
| 39 |
load_text_catalog ('en'); ## TODO: conneg |
load_text_catalog ('en'); ## TODO: conneg |
| 40 |
|
|
|
my @nav; |
|
| 41 |
print STDOUT qq[Content-Type: text/html; charset=utf-8 |
print STDOUT qq[Content-Type: text/html; charset=utf-8 |
| 42 |
|
|
| 43 |
<!DOCTYPE html> |
<!DOCTYPE html> |
| 54 |
$| = 0; |
$| = 0; |
| 55 |
my $input = get_input_document ($http, $dom); |
my $input = get_input_document ($http, $dom); |
| 56 |
my $char_length = 0; |
my $char_length = 0; |
|
my %time; |
|
| 57 |
|
|
| 58 |
print qq[ |
print qq[ |
| 59 |
<div id="document-info" class="section"> |
<div id="document-info" class="section"> |
| 88 |
</div> |
</div> |
| 89 |
]; |
]; |
| 90 |
|
|
| 91 |
|
$input->{id_prefix} = ''; |
| 92 |
|
#$input->{nested} = 0; |
| 93 |
my $result = {conforming_min => 1, conforming_max => 1}; |
my $result = {conforming_min => 1, conforming_max => 1}; |
| 94 |
check_and_print ($input => $result); |
check_and_print ($input => $result); |
| 95 |
print_result_section ($result); |
print_result_section ($result); |
| 118 |
} |
} |
| 119 |
|
|
| 120 |
exit; |
exit; |
| 121 |
|
} |
| 122 |
|
|
| 123 |
sub add_error ($$$) { |
sub add_error ($$$) { |
| 124 |
my ($layer, $err, $result) = @_; |
my ($layer, $err, $result) = @_; |
| 132 |
} elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { |
} elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { |
| 133 |
$result->{$layer}->{unsupported}++; |
$result->{$layer}->{unsupported}++; |
| 134 |
$result->{unsupported} = 1; |
$result->{unsupported} = 1; |
| 135 |
|
} elsif ($err->{level} eq 'i') { |
| 136 |
|
# |
| 137 |
} else { |
} else { |
| 138 |
$result->{$layer}->{must}++; |
$result->{$layer}->{must}++; |
| 139 |
$result->{$layer}->{score_max} -= 2; |
$result->{$layer}->{score_max} -= 2; |
| 152 |
|
|
| 153 |
sub check_and_print ($$) { |
sub check_and_print ($$) { |
| 154 |
my ($input, $result) = @_; |
my ($input, $result) = @_; |
|
$input->{id_prefix} = ''; |
|
|
#$input->{nested} = 1/0; |
|
| 155 |
|
|
| 156 |
print_http_header_section ($input, $result); |
print_http_header_section ($input, $result); |
| 157 |
|
|
| 158 |
my $doc; |
my $doc; |
| 159 |
my $el; |
my $el; |
| 160 |
|
my $cssom; |
| 161 |
my $manifest; |
my $manifest; |
| 162 |
|
my @subdoc; |
| 163 |
|
|
| 164 |
if ($input->{media_type} eq 'text/html') { |
if ($input->{media_type} eq 'text/html') { |
| 165 |
($doc, $el) = print_syntax_error_html_section ($input, $result); |
($doc, $el) = print_syntax_error_html_section ($input, $result); |
| 166 |
print_source_string_section |
print_source_string_section |
| 167 |
(\($input->{s}), $input->{charset} || $doc->input_encoding); |
($input, |
| 168 |
|
\($input->{s}), |
| 169 |
|
$input->{charset} || $doc->input_encoding); |
| 170 |
} elsif ({ |
} elsif ({ |
| 171 |
'text/xml' => 1, |
'text/xml' => 1, |
| 172 |
'application/atom+xml' => 1, |
'application/atom+xml' => 1, |
| 176 |
'application/xml' => 1, |
'application/xml' => 1, |
| 177 |
}->{$input->{media_type}}) { |
}->{$input->{media_type}}) { |
| 178 |
($doc, $el) = print_syntax_error_xml_section ($input, $result); |
($doc, $el) = print_syntax_error_xml_section ($input, $result); |
| 179 |
print_source_string_section (\($input->{s}), $doc->input_encoding); |
print_source_string_section ($input, |
| 180 |
|
\($input->{s}), |
| 181 |
|
$doc->input_encoding); |
| 182 |
|
} elsif ($input->{media_type} eq 'text/css') { |
| 183 |
|
$cssom = print_syntax_error_css_section ($input, $result); |
| 184 |
|
print_source_string_section |
| 185 |
|
($input, \($input->{s}), |
| 186 |
|
$cssom->manakai_input_encoding); |
| 187 |
} elsif ($input->{media_type} eq 'text/cache-manifest') { |
} elsif ($input->{media_type} eq 'text/cache-manifest') { |
| 188 |
## TODO: MUST be text/cache-manifest |
## TODO: MUST be text/cache-manifest |
| 189 |
$manifest = print_syntax_error_manifest_section ($input, $result); |
$manifest = print_syntax_error_manifest_section ($input, $result); |
| 190 |
print_source_string_section (\($input->{s}), 'utf-8'); |
print_source_string_section ($input, \($input->{s}), |
| 191 |
|
'utf-8'); |
| 192 |
} else { |
} else { |
| 193 |
## TODO: Change HTTP status code?? |
## TODO: Change HTTP status code?? |
| 194 |
print_result_unknown_type_section ($input, $result); |
print_result_unknown_type_section ($input, $result); |
| 195 |
} |
} |
| 196 |
|
|
| 197 |
if (defined $doc or defined $el) { |
if (defined $doc or defined $el) { |
| 198 |
|
$doc->document_uri ($input->{uri}); |
| 199 |
|
$doc->manakai_entity_base_uri ($input->{base_uri}); |
| 200 |
print_structure_dump_dom_section ($input, $doc, $el); |
print_structure_dump_dom_section ($input, $doc, $el); |
| 201 |
my $elements = print_structure_error_dom_section |
my $elements = print_structure_error_dom_section |
| 202 |
($input, $doc, $el, $result); |
($input, $doc, $el, $result, sub { |
| 203 |
|
push @subdoc, shift; |
| 204 |
|
}); |
| 205 |
print_table_section ($input, $elements->{table}) if @{$elements->{table}}; |
print_table_section ($input, $elements->{table}) if @{$elements->{table}}; |
| 206 |
print_id_section ($input, $elements->{id}) if keys %{$elements->{id}}; |
print_listing_section ({ |
| 207 |
print_term_section ($input, $elements->{term}) if keys %{$elements->{term}}; |
id => 'identifiers', label => 'IDs', heading => 'Identifiers', |
| 208 |
print_class_section ($input, $elements->{class}) if keys %{$elements->{class}}; |
}, $input, $elements->{id}) if keys %{$elements->{id}}; |
| 209 |
|
print_listing_section ({ |
| 210 |
|
id => 'terms', label => 'Terms', heading => 'Terms', |
| 211 |
|
}, $input, $elements->{term}) if keys %{$elements->{term}}; |
| 212 |
|
print_listing_section ({ |
| 213 |
|
id => 'classes', label => 'Classes', heading => 'Classes', |
| 214 |
|
}, $input, $elements->{class}) if keys %{$elements->{class}}; |
| 215 |
|
} elsif (defined $cssom) { |
| 216 |
|
print_structure_dump_cssom_section ($input, $cssom); |
| 217 |
|
## TODO: CSSOM validation |
| 218 |
|
add_error ('structure', {level => 'u'} => $result); |
| 219 |
} elsif (defined $manifest) { |
} elsif (defined $manifest) { |
| 220 |
print_structure_dump_manifest_section ($input, $manifest); |
print_structure_dump_manifest_section ($input, $manifest); |
| 221 |
print_structure_error_manifest_section ($input, $manifest, $result); |
print_structure_error_manifest_section ($input, $manifest, $result); |
| 222 |
} |
} |
| 223 |
|
|
| 224 |
|
my $id_prefix = 0; |
| 225 |
|
for my $subinput (@subdoc) { |
| 226 |
|
$subinput->{id_prefix} = 'subdoc-' . ++$id_prefix; |
| 227 |
|
$subinput->{nested} = 1; |
| 228 |
|
$subinput->{base_uri} = $subinput->{container_node}->base_uri |
| 229 |
|
unless defined $subinput->{base_uri}; |
| 230 |
|
my $ebaseuri = htescape ($subinput->{base_uri}); |
| 231 |
|
push @nav, ['#' . $subinput->{id_prefix} => 'Sub #' . $id_prefix]; |
| 232 |
|
print STDOUT qq[<div id="$subinput->{id_prefix}" class=section> |
| 233 |
|
<h2>Subdocument #$id_prefix</h2> |
| 234 |
|
|
| 235 |
|
<dl> |
| 236 |
|
<dt>Internet Media Type</dt> |
| 237 |
|
<dd><code class="MIME" lang="en">@{[htescape $subinput->{media_type}]}</code> |
| 238 |
|
<dt>Container Node</dt> |
| 239 |
|
<dd>@{[get_node_link ($input, $subinput->{container_node})]}</dd> |
| 240 |
|
<dt>Base <abbr title="Uniform Resource Identifiers">URI</abbr></dt> |
| 241 |
|
<dd><code class=URI><<a href="$ebaseuri">$ebaseuri</a>></code></dd> |
| 242 |
|
</dl>]; |
| 243 |
|
|
| 244 |
|
$subinput->{id_prefix} .= '-'; |
| 245 |
|
check_and_print ($subinput => $result); |
| 246 |
|
|
| 247 |
|
print STDOUT qq[</div>]; |
| 248 |
|
} |
| 249 |
} # check_and_print |
} # check_and_print |
| 250 |
|
|
| 251 |
sub print_http_header_section ($$) { |
sub print_http_header_section ($$) { |
| 252 |
my ($input, $result) = @_; |
my ($input, $result) = @_; |
| 253 |
return unless defined $input->{header_status_code} or |
return unless defined $input->{header_status_code} or |
| 254 |
defined $input->{header_status_text} or |
defined $input->{header_status_text} or |
| 255 |
@{$input->{header_field}}; |
@{$input->{header_field} or []}; |
| 256 |
|
|
| 257 |
push @nav, ['#source-header' => 'HTTP Header'] unless $input->{nested}; |
push @nav, ['#source-header' => 'HTTP Header'] unless $input->{nested}; |
| 258 |
print STDOUT qq[<div id="$input->{id_prefix}source-header" class="section"> |
print STDOUT qq[<div id="$input->{id_prefix}source-header" class="section"> |
| 298 |
my $onerror = sub { |
my $onerror = sub { |
| 299 |
my (%opt) = @_; |
my (%opt) = @_; |
| 300 |
my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); |
my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); |
| 301 |
if ($opt{column} > 0) { |
print STDOUT qq[<dt class="$cls">], get_error_label ($input, \%opt), |
| 302 |
print STDOUT qq[<dt class="$cls"><a href="#line-$opt{line}">Line $opt{line}</a> column $opt{column}</dt>\n]; |
qq[</dt>]; |
|
} else { |
|
|
$opt{line} = $opt{line} - 1 || 1; |
|
|
print STDOUT qq[<dt class="$cls"><a href="#line-$opt{line}">Line $opt{line}</a></dt>\n]; |
|
|
} |
|
| 303 |
$type =~ tr/ /-/; |
$type =~ tr/ /-/; |
| 304 |
$type =~ s/\|/%7C/g; |
$type =~ s/\|/%7C/g; |
| 305 |
$msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]]; |
$msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]]; |
| 311 |
|
|
| 312 |
my $doc = $dom->create_document; |
my $doc = $dom->create_document; |
| 313 |
my $el; |
my $el; |
| 314 |
my $inner_html_element = $http->get_parameter ('e'); |
my $inner_html_element = $input->{inner_html_element}; |
| 315 |
if (defined $inner_html_element and length $inner_html_element) { |
if (defined $inner_html_element and length $inner_html_element) { |
| 316 |
$input->{charset} ||= 'windows-1252'; ## TODO: for now. |
$input->{charset} ||= 'windows-1252'; ## TODO: for now. |
| 317 |
my $time1 = time; |
my $time1 = time; |
| 352 |
my $onerror = sub { |
my $onerror = sub { |
| 353 |
my $err = shift; |
my $err = shift; |
| 354 |
my $line = $err->location->line_number; |
my $line = $err->location->line_number; |
| 355 |
print STDOUT qq[<dt><a href="#line-$line">Line $line</a> column ]; |
print STDOUT qq[<dt><a href="#$input->{id_prefix}line-$line">Line $line</a> column ]; |
| 356 |
print STDOUT $err->location->column_number, "</dt><dd>"; |
print STDOUT $err->location->column_number, "</dt><dd>"; |
| 357 |
print STDOUT htescape $err->text, "</dd>\n"; |
print STDOUT htescape $err->text, "</dd>\n"; |
| 358 |
|
|
| 379 |
return ($doc, undef); |
return ($doc, undef); |
| 380 |
} # print_syntax_error_xml_section |
} # print_syntax_error_xml_section |
| 381 |
|
|
| 382 |
|
sub get_css_parser () { |
| 383 |
|
our $CSSParser; |
| 384 |
|
return $CSSParser if $CSSParser; |
| 385 |
|
|
| 386 |
|
require Whatpm::CSS::Parser; |
| 387 |
|
my $p = Whatpm::CSS::Parser->new; |
| 388 |
|
|
| 389 |
|
$p->{prop}->{$_} = 1 for qw/ |
| 390 |
|
alignment-baseline |
| 391 |
|
background background-attachment background-color background-image |
| 392 |
|
background-position background-position-x background-position-y |
| 393 |
|
background-repeat border border-bottom border-bottom-color |
| 394 |
|
border-bottom-style border-bottom-width border-collapse border-color |
| 395 |
|
border-left border-left-color |
| 396 |
|
border-left-style border-left-width border-right border-right-color |
| 397 |
|
border-right-style border-right-width |
| 398 |
|
border-spacing -manakai-border-spacing-x -manakai-border-spacing-y |
| 399 |
|
border-style border-top border-top-color border-top-style border-top-width |
| 400 |
|
border-width bottom |
| 401 |
|
caption-side clear clip color content counter-increment counter-reset |
| 402 |
|
cursor direction display dominant-baseline empty-cells float font |
| 403 |
|
font-family font-size font-size-adjust font-stretch |
| 404 |
|
font-style font-variant font-weight height left |
| 405 |
|
letter-spacing line-height |
| 406 |
|
list-style list-style-image list-style-position list-style-type |
| 407 |
|
margin margin-bottom margin-left margin-right margin-top marker-offset |
| 408 |
|
marks max-height max-width min-height min-width opacity -moz-opacity |
| 409 |
|
orphans outline outline-color outline-style outline-width overflow |
| 410 |
|
overflow-x overflow-y |
| 411 |
|
padding padding-bottom padding-left padding-right padding-top |
| 412 |
|
page page-break-after page-break-before page-break-inside |
| 413 |
|
position quotes right size table-layout |
| 414 |
|
text-align text-anchor text-decoration text-indent text-transform |
| 415 |
|
top unicode-bidi vertical-align visibility white-space width widows |
| 416 |
|
word-spacing writing-mode z-index |
| 417 |
|
/; |
| 418 |
|
$p->{prop_value}->{display}->{$_} = 1 for qw/ |
| 419 |
|
block clip inline inline-block inline-table list-item none |
| 420 |
|
table table-caption table-cell table-column table-column-group |
| 421 |
|
table-header-group table-footer-group table-row table-row-group |
| 422 |
|
compact marker |
| 423 |
|
/; |
| 424 |
|
$p->{prop_value}->{position}->{$_} = 1 for qw/ |
| 425 |
|
absolute fixed relative static |
| 426 |
|
/; |
| 427 |
|
$p->{prop_value}->{float}->{$_} = 1 for qw/ |
| 428 |
|
left right none |
| 429 |
|
/; |
| 430 |
|
$p->{prop_value}->{clear}->{$_} = 1 for qw/ |
| 431 |
|
left right none both |
| 432 |
|
/; |
| 433 |
|
$p->{prop_value}->{direction}->{ltr} = 1; |
| 434 |
|
$p->{prop_value}->{direction}->{rtl} = 1; |
| 435 |
|
$p->{prop_value}->{marks}->{crop} = 1; |
| 436 |
|
$p->{prop_value}->{marks}->{cross} = 1; |
| 437 |
|
$p->{prop_value}->{'unicode-bidi'}->{$_} = 1 for qw/ |
| 438 |
|
normal bidi-override embed |
| 439 |
|
/; |
| 440 |
|
for my $prop_name (qw/overflow overflow-x overflow-y/) { |
| 441 |
|
$p->{prop_value}->{$prop_name}->{$_} = 1 for qw/ |
| 442 |
|
visible hidden scroll auto -webkit-marquee -moz-hidden-unscrollable |
| 443 |
|
/; |
| 444 |
|
} |
| 445 |
|
$p->{prop_value}->{visibility}->{$_} = 1 for qw/ |
| 446 |
|
visible hidden collapse |
| 447 |
|
/; |
| 448 |
|
$p->{prop_value}->{'list-style-type'}->{$_} = 1 for qw/ |
| 449 |
|
disc circle square decimal decimal-leading-zero |
| 450 |
|
lower-roman upper-roman lower-greek lower-latin |
| 451 |
|
upper-latin armenian georgian lower-alpha upper-alpha none |
| 452 |
|
hebrew cjk-ideographic hiragana katakana hiragana-iroha |
| 453 |
|
katakana-iroha |
| 454 |
|
/; |
| 455 |
|
$p->{prop_value}->{'list-style-position'}->{outside} = 1; |
| 456 |
|
$p->{prop_value}->{'list-style-position'}->{inside} = 1; |
| 457 |
|
$p->{prop_value}->{'page-break-before'}->{$_} = 1 for qw/ |
| 458 |
|
auto always avoid left right |
| 459 |
|
/; |
| 460 |
|
$p->{prop_value}->{'page-break-after'}->{$_} = 1 for qw/ |
| 461 |
|
auto always avoid left right |
| 462 |
|
/; |
| 463 |
|
$p->{prop_value}->{'page-break-inside'}->{auto} = 1; |
| 464 |
|
$p->{prop_value}->{'page-break-inside'}->{avoid} = 1; |
| 465 |
|
$p->{prop_value}->{'background-repeat'}->{$_} = 1 for qw/ |
| 466 |
|
repeat repeat-x repeat-y no-repeat |
| 467 |
|
/; |
| 468 |
|
$p->{prop_value}->{'background-attachment'}->{scroll} = 1; |
| 469 |
|
$p->{prop_value}->{'background-attachment'}->{fixed} = 1; |
| 470 |
|
$p->{prop_value}->{'font-size'}->{$_} = 1 for qw/ |
| 471 |
|
xx-small x-small small medium large x-large xx-large |
| 472 |
|
-manakai-xxx-large -webkit-xxx-large |
| 473 |
|
larger smaller |
| 474 |
|
/; |
| 475 |
|
$p->{prop_value}->{'font-style'}->{normal} = 1; |
| 476 |
|
$p->{prop_value}->{'font-style'}->{italic} = 1; |
| 477 |
|
$p->{prop_value}->{'font-style'}->{oblique} = 1; |
| 478 |
|
$p->{prop_value}->{'font-variant'}->{normal} = 1; |
| 479 |
|
$p->{prop_value}->{'font-variant'}->{'small-caps'} = 1; |
| 480 |
|
$p->{prop_value}->{'font-stretch'}->{$_} = 1 for |
| 481 |
|
qw/normal wider narrower ultra-condensed extra-condensed |
| 482 |
|
condensed semi-condensed semi-expanded expanded |
| 483 |
|
extra-expanded ultra-expanded/; |
| 484 |
|
$p->{prop_value}->{'text-align'}->{$_} = 1 for qw/ |
| 485 |
|
left right center justify begin end |
| 486 |
|
/; |
| 487 |
|
$p->{prop_value}->{'text-transform'}->{$_} = 1 for qw/ |
| 488 |
|
capitalize uppercase lowercase none |
| 489 |
|
/; |
| 490 |
|
$p->{prop_value}->{'white-space'}->{$_} = 1 for qw/ |
| 491 |
|
normal pre nowrap pre-line pre-wrap -moz-pre-wrap |
| 492 |
|
/; |
| 493 |
|
$p->{prop_value}->{'writing-mode'}->{$_} = 1 for qw/ |
| 494 |
|
lr rl tb lr-tb rl-tb tb-rl |
| 495 |
|
/; |
| 496 |
|
$p->{prop_value}->{'text-anchor'}->{$_} = 1 for qw/ |
| 497 |
|
start middle end |
| 498 |
|
/; |
| 499 |
|
$p->{prop_value}->{'dominant-baseline'}->{$_} = 1 for qw/ |
| 500 |
|
auto use-script no-change reset-size ideographic alphabetic |
| 501 |
|
hanging mathematical central middle text-after-edge text-before-edge |
| 502 |
|
/; |
| 503 |
|
$p->{prop_value}->{'alignment-baseline'}->{$_} = 1 for qw/ |
| 504 |
|
auto baseline before-edge text-before-edge middle central |
| 505 |
|
after-edge text-after-edge ideographic alphabetic hanging |
| 506 |
|
mathematical |
| 507 |
|
/; |
| 508 |
|
$p->{prop_value}->{'text-decoration'}->{$_} = 1 for qw/ |
| 509 |
|
none blink underline overline line-through |
| 510 |
|
/; |
| 511 |
|
$p->{prop_value}->{'caption-side'}->{$_} = 1 for qw/ |
| 512 |
|
top bottom left right |
| 513 |
|
/; |
| 514 |
|
$p->{prop_value}->{'table-layout'}->{auto} = 1; |
| 515 |
|
$p->{prop_value}->{'table-layout'}->{fixed} = 1; |
| 516 |
|
$p->{prop_value}->{'border-collapse'}->{collapse} = 1; |
| 517 |
|
$p->{prop_value}->{'border-collapse'}->{separate} = 1; |
| 518 |
|
$p->{prop_value}->{'empty-cells'}->{show} = 1; |
| 519 |
|
$p->{prop_value}->{'empty-cells'}->{hide} = 1; |
| 520 |
|
$p->{prop_value}->{cursor}->{$_} = 1 for qw/ |
| 521 |
|
auto crosshair default pointer move e-resize ne-resize nw-resize n-resize |
| 522 |
|
se-resize sw-resize s-resize w-resize text wait help progress |
| 523 |
|
/; |
| 524 |
|
for my $prop (qw/border-top-style border-left-style |
| 525 |
|
border-bottom-style border-right-style outline-style/) { |
| 526 |
|
$p->{prop_value}->{$prop}->{$_} = 1 for qw/ |
| 527 |
|
none hidden dotted dashed solid double groove ridge inset outset |
| 528 |
|
/; |
| 529 |
|
} |
| 530 |
|
for my $prop (qw/color background-color |
| 531 |
|
border-bottom-color border-left-color border-right-color |
| 532 |
|
border-top-color border-color/) { |
| 533 |
|
$p->{prop_value}->{$prop}->{transparent} = 1; |
| 534 |
|
$p->{prop_value}->{$prop}->{flavor} = 1; |
| 535 |
|
$p->{prop_value}->{$prop}->{'-manakai-default'} = 1; |
| 536 |
|
} |
| 537 |
|
$p->{prop_value}->{'outline-color'}->{invert} = 1; |
| 538 |
|
$p->{prop_value}->{'outline-color'}->{'-manakai-invert-or-currentcolor'} = 1; |
| 539 |
|
$p->{pseudo_class}->{$_} = 1 for qw/ |
| 540 |
|
active checked disabled empty enabled first-child first-of-type |
| 541 |
|
focus hover indeterminate last-child last-of-type link only-child |
| 542 |
|
only-of-type root target visited |
| 543 |
|
lang nth-child nth-last-child nth-of-type nth-last-of-type not |
| 544 |
|
-manakai-contains -manakai-current |
| 545 |
|
/; |
| 546 |
|
$p->{pseudo_element}->{$_} = 1 for qw/ |
| 547 |
|
after before first-letter first-line |
| 548 |
|
/; |
| 549 |
|
|
| 550 |
|
return $CSSParser = $p; |
| 551 |
|
} # get_css_parser |
| 552 |
|
|
| 553 |
|
sub print_syntax_error_css_section ($$) { |
| 554 |
|
my ($input, $result) = @_; |
| 555 |
|
|
| 556 |
|
print STDOUT qq[ |
| 557 |
|
<div id="$input->{id_prefix}parse-errors" class="section"> |
| 558 |
|
<h2>Parse Errors</h2> |
| 559 |
|
|
| 560 |
|
<dl>]; |
| 561 |
|
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested}; |
| 562 |
|
|
| 563 |
|
my $p = get_css_parser (); |
| 564 |
|
$p->init; |
| 565 |
|
$p->{onerror} = sub { |
| 566 |
|
my (%opt) = @_; |
| 567 |
|
my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); |
| 568 |
|
if ($opt{token}) { |
| 569 |
|
print STDOUT qq[<dt class="$cls"><a href="#$input->{id_prefix}line-$opt{token}->{line}">Line $opt{token}->{line}</a> column $opt{token}->{column}]; |
| 570 |
|
} else { |
| 571 |
|
print STDOUT qq[<dt class="$cls">Unknown location]; |
| 572 |
|
} |
| 573 |
|
if (defined $opt{value}) { |
| 574 |
|
print STDOUT qq[ (<code>@{[htescape ($opt{value})]}</code>)]; |
| 575 |
|
} elsif (defined $opt{token}) { |
| 576 |
|
print STDOUT qq[ (<code>@{[htescape (Whatpm::CSS::Tokenizer->serialize_token ($opt{token}))]}</code>)]; |
| 577 |
|
} |
| 578 |
|
$type =~ tr/ /-/; |
| 579 |
|
$type =~ s/\|/%7C/g; |
| 580 |
|
$msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]]; |
| 581 |
|
print STDOUT qq[<dd class="$cls">], get_error_level_label (\%opt); |
| 582 |
|
print STDOUT qq[$msg</dd>\n]; |
| 583 |
|
|
| 584 |
|
add_error ('syntax', \%opt => $result); |
| 585 |
|
}; |
| 586 |
|
$p->{href} = $input->{uri}; |
| 587 |
|
$p->{base_uri} = $input->{base_uri}; |
| 588 |
|
|
| 589 |
|
# if ($parse_mode eq 'q') { |
| 590 |
|
# $p->{unitless_px} = 1; |
| 591 |
|
# $p->{hashless_color} = 1; |
| 592 |
|
# } |
| 593 |
|
|
| 594 |
|
## TODO: Make $input->{s} a ref. |
| 595 |
|
|
| 596 |
|
my $s = \$input->{s}; |
| 597 |
|
my $charset; |
| 598 |
|
unless ($input->{is_char_string}) { |
| 599 |
|
require Encode; |
| 600 |
|
if (defined $input->{charset}) {## TODO: IANA->Perl |
| 601 |
|
$charset = $input->{charset}; |
| 602 |
|
$s = \(Encode::decode ($input->{charset}, $$s)); |
| 603 |
|
} else { |
| 604 |
|
## TODO: charset detection |
| 605 |
|
$s = \(Encode::decode ($charset = 'utf-8', $$s)); |
| 606 |
|
} |
| 607 |
|
} |
| 608 |
|
|
| 609 |
|
my $cssom = $p->parse_char_string ($$s); |
| 610 |
|
$cssom->manakai_input_encoding ($charset) if defined $charset; |
| 611 |
|
|
| 612 |
|
print STDOUT qq[</dl></div>]; |
| 613 |
|
|
| 614 |
|
return $cssom; |
| 615 |
|
} # print_syntax_error_css_section |
| 616 |
|
|
| 617 |
sub print_syntax_error_manifest_section ($$) { |
sub print_syntax_error_manifest_section ($$) { |
| 618 |
my ($input, $result) = @_; |
my ($input, $result) = @_; |
| 619 |
|
|
| 650 |
return $manifest; |
return $manifest; |
| 651 |
} # print_syntax_error_manifest_section |
} # print_syntax_error_manifest_section |
| 652 |
|
|
| 653 |
sub print_source_string_section ($$) { |
sub print_source_string_section ($$$) { |
| 654 |
require Encode; |
my $input = shift; |
| 655 |
my $enc = Encode::find_encoding ($_[1]); ## TODO: charset name -> Perl name |
my $s; |
| 656 |
return unless $enc; |
unless ($input->{is_char_string}) { |
| 657 |
|
require Encode; |
| 658 |
|
my $enc = Encode::find_encoding ($_[1]); ## TODO: charset name -> Perl name |
| 659 |
|
return unless $enc; |
| 660 |
|
|
| 661 |
|
$s = \($enc->decode (${$_[0]})); |
| 662 |
|
} else { |
| 663 |
|
$s = $_[0]; |
| 664 |
|
} |
| 665 |
|
|
|
my $s = \($enc->decode (${$_[0]})); |
|
| 666 |
my $i = 1; |
my $i = 1; |
| 667 |
push @nav, ['#source-string' => 'Source'] unless $input->{nested}; |
push @nav, ['#source-string' => 'Source'] unless $input->{nested}; |
| 668 |
print STDOUT qq[<div id="$input->{id_prefix}source-string" class="section"> |
print STDOUT qq[<div id="$input->{id_prefix}source-string" class="section"> |
| 684 |
print STDOUT "</ol></div>"; |
print STDOUT "</ol></div>"; |
| 685 |
} # print_input_string_section |
} # print_input_string_section |
| 686 |
|
|
| 687 |
sub print_document_tree ($) { |
sub print_document_tree ($$) { |
| 688 |
my $node = shift; |
my ($input, $node) = @_; |
| 689 |
|
|
| 690 |
my $r = '<ol class="xoxo">'; |
my $r = '<ol class="xoxo">'; |
| 691 |
|
|
| 692 |
my @node = ($node); |
my @node = ($node); |
| 784 |
<div id="$input->{id_prefix}document-tree" class="section"> |
<div id="$input->{id_prefix}document-tree" class="section"> |
| 785 |
<h2>Document Tree</h2> |
<h2>Document Tree</h2> |
| 786 |
]; |
]; |
| 787 |
push @nav, ['#document-tree' => 'Tree'] unless $input->{nested}; |
push @nav, [qq[#$input->{id_prefix}document-tree] => 'Tree'] |
| 788 |
|
unless $input->{nested}; |
| 789 |
|
|
| 790 |
print_document_tree ($el || $doc); |
print_document_tree ($input, $el || $doc); |
| 791 |
|
|
| 792 |
print STDOUT qq[</div>]; |
print STDOUT qq[</div>]; |
| 793 |
} # print_structure_dump_dom_section |
} # print_structure_dump_dom_section |
| 794 |
|
|
| 795 |
|
sub print_structure_dump_cssom_section ($$) { |
| 796 |
|
my ($input, $cssom) = @_; |
| 797 |
|
|
| 798 |
|
print STDOUT qq[ |
| 799 |
|
<div id="$input->{id_prefix}document-tree" class="section"> |
| 800 |
|
<h2>Document Tree</h2> |
| 801 |
|
]; |
| 802 |
|
push @nav, [qq[#$input->{id_prefix}document-tree] => 'Tree'] |
| 803 |
|
unless $input->{nested}; |
| 804 |
|
|
| 805 |
|
## TODO: |
| 806 |
|
print STDOUT "<pre>".htescape ($cssom->css_text)."</pre>"; |
| 807 |
|
|
| 808 |
|
print STDOUT qq[</div>]; |
| 809 |
|
} # print_structure_dump_cssom_section |
| 810 |
|
|
| 811 |
sub print_structure_dump_manifest_section ($$) { |
sub print_structure_dump_manifest_section ($$) { |
| 812 |
my ($input, $manifest) = @_; |
my ($input, $manifest) = @_; |
| 813 |
|
|
| 815 |
<div id="$input->{id_prefix}dump-manifest" class="section"> |
<div id="$input->{id_prefix}dump-manifest" class="section"> |
| 816 |
<h2>Cache Manifest</h2> |
<h2>Cache Manifest</h2> |
| 817 |
]; |
]; |
| 818 |
push @nav, ['#dump-manifest' => 'Caceh Manifest'] unless $input->{nested}; |
push @nav, [qq[#$input->{id_prefix}dump-manifest] => 'Cache Manifest'] |
| 819 |
|
unless $input->{nested}; |
| 820 |
|
|
| 821 |
print STDOUT qq[<dl><dt>Explicit entries</dt>]; |
print STDOUT qq[<dl><dt>Explicit entries</dt>]; |
| 822 |
|
my $i = 0; |
| 823 |
for my $uri (@{$manifest->[0]}) { |
for my $uri (@{$manifest->[0]}) { |
| 824 |
my $euri = htescape ($uri); |
my $euri = htescape ($uri); |
| 825 |
print STDOUT qq[<dd><code class=uri><<a href="$euri">$euri</a>></code></dd>]; |
print STDOUT qq[<dd id="$input->{id_prefix}index-@{[$i++]}"><code class=uri><<a href="$euri">$euri</a>></code></dd>]; |
| 826 |
} |
} |
| 827 |
|
|
| 828 |
print STDOUT qq[<dt>Fallback entries</dt><dd> |
print STDOUT qq[<dt>Fallback entries</dt><dd> |
| 831 |
for my $uri (sort {$a cmp $b} keys %{$manifest->[1]}) { |
for my $uri (sort {$a cmp $b} keys %{$manifest->[1]}) { |
| 832 |
my $euri = htescape ($uri); |
my $euri = htescape ($uri); |
| 833 |
my $euri2 = htescape ($manifest->[1]->{$uri}); |
my $euri2 = htescape ($manifest->[1]->{$uri}); |
| 834 |
print STDOUT qq[<tr><td><code class=uri><<a href="$euri">$euri</a>></code></td> |
print STDOUT qq[<tr><td id="$input->{id_prefix}index-@{[$i++]}"><code class=uri><<a href="$euri">$euri</a>></code></td> |
| 835 |
<td><code class=uri><<a href="$euri2">$euri2</a>></code></td>]; |
<td id="$input->{id_prefix}index-@{[$i++]}"><code class=uri><<a href="$euri2">$euri2</a>></code></td>]; |
| 836 |
} |
} |
| 837 |
|
|
| 838 |
print STDOUT qq[</table><dt>Online whitelist</dt>]; |
print STDOUT qq[</table><dt>Online whitelist</dt>]; |
| 839 |
for my $uri (@{$manifest->[2]}) { |
for my $uri (@{$manifest->[2]}) { |
| 840 |
my $euri = htescape ($uri); |
my $euri = htescape ($uri); |
| 841 |
print STDOUT qq[<dd><code class=uri><<a href="$euri">$euri</a>></code></dd>]; |
print STDOUT qq[<dd id="$input->{id_prefix}index-@{[$i++]}"><code class=uri><<a href="$euri">$euri</a>></code></dd>]; |
| 842 |
} |
} |
| 843 |
|
|
| 844 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl></div>]; |
| 845 |
} # print_structure_dump_manifest_section |
} # print_structure_dump_manifest_section |
| 846 |
|
|
| 847 |
sub print_structure_error_dom_section ($$$$) { |
sub print_structure_error_dom_section ($$$$$) { |
| 848 |
my ($input, $doc, $el, $result) = @_; |
my ($input, $doc, $el, $result, $onsubdoc) = @_; |
| 849 |
|
|
| 850 |
print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section"> |
print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section"> |
| 851 |
<h2>Document Errors</h2> |
<h2>Document Errors</h2> |
| 852 |
|
|
| 853 |
<dl>]; |
<dl>]; |
| 854 |
push @nav, ['#document-errors' => 'Document Error'] unless $input->{nested}; |
push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error'] |
| 855 |
|
unless $input->{nested}; |
| 856 |
|
|
| 857 |
require Whatpm::ContentChecker; |
require Whatpm::ContentChecker; |
| 858 |
my $onerror = sub { |
my $onerror = sub { |
| 870 |
my $elements; |
my $elements; |
| 871 |
my $time1 = time; |
my $time1 = time; |
| 872 |
if ($el) { |
if ($el) { |
| 873 |
$elements = Whatpm::ContentChecker->check_element ($el, $onerror); |
$elements = Whatpm::ContentChecker->check_element |
| 874 |
|
($el, $onerror, $onsubdoc); |
| 875 |
} else { |
} else { |
| 876 |
$elements = Whatpm::ContentChecker->check_document ($doc, $onerror); |
$elements = Whatpm::ContentChecker->check_document |
| 877 |
|
($doc, $onerror, $onsubdoc); |
| 878 |
} |
} |
| 879 |
$time{check} = time - $time1; |
$time{check} = time - $time1; |
| 880 |
|
|
| 890 |
<h2>Document Errors</h2> |
<h2>Document Errors</h2> |
| 891 |
|
|
| 892 |
<dl>]; |
<dl>]; |
| 893 |
push @nav, ['#document-errors' => 'Document Error'] unless $input->{nested}; |
push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error'] |
| 894 |
|
unless $input->{nested}; |
| 895 |
|
|
| 896 |
require Whatpm::CacheManifest; |
require Whatpm::CacheManifest; |
| 897 |
Whatpm::CacheManifest->check_manifest ($manifest, sub { |
Whatpm::CacheManifest->check_manifest ($manifest, sub { |
| 911 |
sub print_table_section ($$) { |
sub print_table_section ($$) { |
| 912 |
my ($input, $tables) = @_; |
my ($input, $tables) = @_; |
| 913 |
|
|
| 914 |
push @nav, ['#tables' => 'Tables'] unless $input->{nested}; |
push @nav, [qq[#$input->{id_prefix}tables] => 'Tables'] |
| 915 |
|
unless $input->{nested}; |
| 916 |
print STDOUT qq[ |
print STDOUT qq[ |
| 917 |
<div id="$input->{id_prefix}tables" class="section"> |
<div id="$input->{id_prefix}tables" class="section"> |
| 918 |
<h2>Tables</h2> |
<h2>Tables</h2> |
| 969 |
print STDOUT qq[</div>]; |
print STDOUT qq[</div>]; |
| 970 |
} # print_table_section |
} # print_table_section |
| 971 |
|
|
| 972 |
sub print_id_section ($$) { |
sub print_listing_section ($$$) { |
| 973 |
my ($input, $ids) = @_; |
my ($opt, $input, $ids) = @_; |
| 974 |
|
|
| 975 |
push @nav, ['#identifiers' => 'IDs'] unless $input->{nested}; |
push @nav, ['#' . $input->{id_prefix} . $opt->{id} => $opt->{label}] |
| 976 |
|
unless $input->{nested}; |
| 977 |
print STDOUT qq[ |
print STDOUT qq[ |
| 978 |
<div id="$input->{id_prefix}identifiers" class="section"> |
<div id="$input->{id_prefix}$opt->{id}" class="section"> |
| 979 |
<h2>Identifiers</h2> |
<h2>$opt->{heading}</h2> |
| 980 |
|
|
| 981 |
<dl> |
<dl> |
| 982 |
]; |
]; |
| 987 |
} |
} |
| 988 |
} |
} |
| 989 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl></div>]; |
| 990 |
} # print_id_section |
} # print_listing_section |
|
|
|
|
sub print_term_section ($$) { |
|
|
my ($input, $terms) = @_; |
|
|
|
|
|
push @nav, ['#terms' => 'Terms'] unless $input->{nested}; |
|
|
print STDOUT qq[ |
|
|
<div id="$input->{id_prefix}terms" class="section"> |
|
|
<h2>Terms</h2> |
|
|
|
|
|
<dl> |
|
|
]; |
|
|
for my $term (sort {$a cmp $b} keys %$terms) { |
|
|
print STDOUT qq[<dt>@{[htescape $term]}</dt>]; |
|
|
for (@{$terms->{$term}}) { |
|
|
print STDOUT qq[<dd>].get_node_link ($input, $_).qq[</dd>]; |
|
|
} |
|
|
} |
|
|
print STDOUT qq[</dl></div>]; |
|
|
} # print_term_section |
|
|
|
|
|
sub print_class_section ($$) { |
|
|
my ($input, $classes) = @_; |
|
|
|
|
|
push @nav, ['#classes' => 'Classes'] unless $input->{nested}; |
|
|
print STDOUT qq[ |
|
|
<div id="$input->{id_prefix}classes" class="section"> |
|
|
<h2>Classes</h2> |
|
|
|
|
|
<dl> |
|
|
]; |
|
|
for my $class (sort {$a cmp $b} keys %$classes) { |
|
|
print STDOUT qq[<dt><code>@{[htescape $class]}</code></dt>]; |
|
|
for (@{$classes->{$class}}) { |
|
|
print STDOUT qq[<dd>].get_node_link ($input, $_).qq[</dd>]; |
|
|
} |
|
|
} |
|
|
print STDOUT qq[</dl></div>]; |
|
|
} # print_class_section |
|
| 991 |
|
|
| 992 |
sub print_result_section ($) { |
sub print_result_section ($) { |
| 993 |
my $result = shift; |
my $result = shift; |
| 1085 |
|
|
| 1086 |
my $euri = htescape ($input->{uri}); |
my $euri = htescape ($input->{uri}); |
| 1087 |
print STDOUT qq[ |
print STDOUT qq[ |
| 1088 |
<div id="parse-errors" class="section"> |
<div id="$input->{id_prefix}parse-errors" class="section"> |
| 1089 |
<h2>Errors</h2> |
<h2>Errors</h2> |
| 1090 |
|
|
| 1091 |
<dl> |
<dl> |
| 1098 |
</dl> |
</dl> |
| 1099 |
</div> |
</div> |
| 1100 |
]; |
]; |
| 1101 |
push @nav, ['#parse-errors' => 'Errors']; |
push @nav, [qq[#$input->{id_prefix}parse-errors] => 'Errors'] |
| 1102 |
|
unless $input->{nested}; |
| 1103 |
add_error (char => {level => 'u'} => $result); |
add_error (char => {level => 'u'} => $result); |
| 1104 |
add_error (syntax => {level => 'u'} => $result); |
add_error (syntax => {level => 'u'} => $result); |
| 1105 |
add_error (structure => {level => 'u'} => $result); |
add_error (structure => {level => 'u'} => $result); |
| 1120 |
|
|
| 1121 |
if (defined $err->{line}) { |
if (defined $err->{line}) { |
| 1122 |
if ($err->{column} > 0) { |
if ($err->{column} > 0) { |
| 1123 |
$r = qq[<a href="#line-$err->{line}">Line $err->{line}</a> column $err->{column}]; |
$r = qq[<a href="#$input->{id_prefix}line-$err->{line}">Line $err->{line}</a> column $err->{column}]; |
| 1124 |
} else { |
} else { |
| 1125 |
$err->{line} = $err->{line} - 1 || 1; |
$err->{line} = $err->{line} - 1 || 1; |
| 1126 |
$r = qq[<a href="#line-$err->{line}">Line $err->{line}</a>]; |
$r = qq[<a href="#$input->{id_prefix}line-$err->{line}">Line $err->{line}</a>]; |
| 1127 |
} |
} |
| 1128 |
} |
} |
| 1129 |
|
|
| 1133 |
} |
} |
| 1134 |
|
|
| 1135 |
if (defined $err->{index}) { |
if (defined $err->{index}) { |
| 1136 |
$r .= ' ' if length $r; |
if (length $r) { |
| 1137 |
$r .= 'Index ' . (0+$err->{index}); |
$r .= ', Index ' . (0+$err->{index}); |
| 1138 |
|
} else { |
| 1139 |
|
$r .= "<a href='#$input->{id_prefix}index-@{[0+$err->{index}]}'>Index " |
| 1140 |
|
. (0+$err->{index}) . '</a>'; |
| 1141 |
|
} |
| 1142 |
} |
} |
| 1143 |
|
|
| 1144 |
if (defined $err->{value}) { |
if (defined $err->{value}) { |
| 1166 |
} elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { |
} elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { |
| 1167 |
$r = qq[<strong><a href="../error-description#level-u">Not |
$r = qq[<strong><a href="../error-description#level-u">Not |
| 1168 |
supported</a></strong>: ]; |
supported</a></strong>: ]; |
| 1169 |
|
} elsif ($err->{level} eq 'i') { |
| 1170 |
|
$r = qq[<strong><a href="../error-description#level-i">Information</a></strong>: ]; |
| 1171 |
} else { |
} else { |
| 1172 |
my $elevel = htescape ($err->{level}); |
my $elevel = htescape ($err->{level}); |
| 1173 |
$r = qq[<strong><a href="../error-description#level-$elevel">$elevel</a></strong>: |
$r = qq[<strong><a href="../error-description#level-$elevel">$elevel</a></strong>: |
| 1412 |
return $r; |
return $r; |
| 1413 |
} |
} |
| 1414 |
|
|
| 1415 |
|
$r->{inner_html_element} = $http->get_parameter ('e'); |
| 1416 |
|
|
| 1417 |
return $r; |
return $r; |
| 1418 |
} # get_input_document |
} # get_input_document |
| 1419 |
|
|
| 1446 |
|
|
| 1447 |
=head1 LICENSE |
=head1 LICENSE |
| 1448 |
|
|
| 1449 |
Copyright 2007 Wakaba <w@suika.fam.cx> |
Copyright 2007-2008 Wakaba <w@suika.fam.cx> |
| 1450 |
|
|
| 1451 |
This library is free software; you can redistribute it |
This library is free software; you can redistribute it |
| 1452 |
and/or modify it under the same terms as Perl itself. |
and/or modify it under the same terms as Perl itself. |