8 |
my $s = $_[0]; |
my $s = $_[0]; |
9 |
$s =~ s/&/&/g; |
$s =~ s/&/&/g; |
10 |
$s =~ s/</</g; |
$s =~ s/</</g; |
11 |
$s =~ s/>/>/g; |
# $s =~ s/>/>/g; |
12 |
$s =~ s/"/"/g; |
$s =~ s/"/"/g; |
13 |
$s =~ s{([\x00-\x09\x0B-\x1F\x7F-\xA0\x{FEFF}\x{FFFC}-\x{FFFF}])}{ |
# $s =~ s{([\x00-\x09\x0B-\x1F\x7F-\xA0\x{FEFF}\x{FFFC}-\x{FFFF}])}{ |
14 |
sprintf '<var>U+%04X</var>', ord $1; |
# sprintf '<var>U+%04X</var>', ord $1; |
15 |
}ge; |
# }ge; |
16 |
return $s; |
return $s; |
17 |
}; |
}; |
18 |
|
|
20 |
my $s = $_[0]; |
my $s = $_[0]; |
21 |
$s =~ s/&/&/g; |
$s =~ s/&/&/g; |
22 |
$s =~ s/</</g; |
$s =~ s/</</g; |
23 |
$s =~ s/>/>/g; |
# $s =~ s/>/>/g; |
24 |
$s =~ s/"/"/g; |
$s =~ s/"/"/g; |
25 |
return $s; |
return $s; |
26 |
}; |
}; |
68 |
} # has_error |
} # has_error |
69 |
|
|
70 |
sub set_utf8 ($) { |
sub set_utf8 ($) { |
71 |
binmode shift->{handle}, ':utf8'; |
binmode $_[0]->{handle}, ':utf8'; |
72 |
} # set_utf8 |
} # set_utf8 |
73 |
|
|
74 |
sub set_flush ($) { |
sub set_flush ($) { |
75 |
shift->{handle}->autoflush (1); |
$_[0]->{handle}->autoflush (1); |
76 |
} # set_flush |
} # set_flush |
77 |
|
|
78 |
sub unset_flush ($) { |
sub unset_flush ($) { |
79 |
shift->{handle}->autoflush (0); |
$_[0]->{handle}->autoflush (0); |
80 |
} # unset_flush |
} # unset_flush |
81 |
|
|
82 |
sub html ($$) { |
sub html ($$) { |
83 |
shift->{handle}->print (shift); |
$_[0]->{handle}->print ($_[1]); |
84 |
} # html |
} # html |
85 |
|
|
86 |
sub text ($$) { |
sub text ($$) { |
87 |
shift->html ($htescape->(shift)); |
$_[0]->{handle}->print ($htescape->($_[1])); |
88 |
} # text |
} # text |
89 |
|
|
90 |
sub url ($$%) { |
sub url ($$%) { |
91 |
my ($self, $url, %opt) = @_; |
my ($self, $url, %opt) = @_; |
92 |
$self->html (q[<code class=uri><]); |
$self->{handle}->print (q[<code class=uri><]); |
93 |
$self->link ($url, %opt, url => $url); |
$self->link ($url, %opt, url => $url); |
94 |
$self->html (q[></code>]); |
$self->{handle}->print (q[></code>]); |
95 |
} # url |
} # url |
96 |
|
|
97 |
sub start_tag ($$%) { |
sub start_tag ($$%) { |
98 |
my ($self, $tag_name, %opt) = @_; |
my ($self, $tag_name, %opt) = @_; |
99 |
$self->html ('<' . $htescape_value->($tag_name)); # escape for safety |
$self->{handle}->print ('<' . $tag_name); |
100 |
if (exists $opt{id}) { |
if (exists $opt{id}) { |
101 |
my $id = $self->input->id_prefix . $opt{id}; |
my $id = $self->input->id_prefix . $opt{id}; |
102 |
$self->html (' id="' . $htescape_value->($id) . '"'); |
$self->{handle}->print (' id="' . $htescape_value->($id) . '"'); |
103 |
delete $opt{id}; |
delete $opt{id}; |
104 |
} |
} |
105 |
for (keys %opt) { # for safety |
for (keys %opt) { |
106 |
$self->html (' ' . $htescape_value->($_) . '="' . |
$self->{handle}->print |
107 |
$htescape_value->($opt{$_}) . '"'); |
(' ' . $_ . '="' . $htescape_value->($opt{$_}) . '"'); |
108 |
} |
} |
109 |
$self->html ('>'); |
$self->{handle}->print ('>'); |
110 |
} # start_tag |
} # start_tag |
111 |
|
|
112 |
sub end_tag ($$) { |
sub end_tag ($$) { |
113 |
shift->html ('</' . $htescape_value->(shift) . '>'); |
$_[0]->{handle}->print ('</' . $_[1] . '>'); |
114 |
} # end_tag |
} # end_tag |
115 |
|
|
116 |
sub start_section ($%) { |
sub start_section ($%) { |
182 |
my $st = $opt{short_title} || $opt{title}; |
my $st = $opt{short_title} || $opt{title}; |
183 |
push @{$self->{nav}}, |
push @{$self->{nav}}, |
184 |
[$id => $st => $opt{text}] if $self->{section_rank} == 2; |
[$id => $st => $opt{text}] if $self->{section_rank} == 2; |
185 |
|
|
186 |
$self->start_tag ('script'); |
unless ($opt{notab}) { |
187 |
$self->html (qq[ addSectionLink ('$id', ']); |
$self->start_tag ('script'); |
188 |
$self->nl_text ($st, text => $opt{text}); |
$self->html (qq[ addSectionLink ('$id', ']); |
189 |
if (defined $opt{parent_id}) { |
$self->nl_text ($st, text => $opt{text}); |
190 |
$self->html (q[', '] . $opt{parent_id}); |
if (defined $opt{parent_id}) { |
191 |
|
$self->html (q[', '] . $opt{parent_id}); |
192 |
|
} |
193 |
|
$self->html (q[') ]); |
194 |
|
$self->end_tag ('script'); |
195 |
} |
} |
|
$self->html (q[') ]); |
|
|
$self->end_tag ('script'); |
|
196 |
} |
} |
197 |
} else { |
} else { |
198 |
$self->html ('>'); |
$self->html ('>'); |
273 |
} # add_source_to_parse_error_list |
} # add_source_to_parse_error_list |
274 |
|
|
275 |
sub start_code_block ($) { |
sub start_code_block ($) { |
276 |
shift->html ('<pre><code>'); |
$_[0]->{handle}->print ('<pre><code>'); |
277 |
} # start_code_block |
} # start_code_block |
278 |
|
|
279 |
sub end_code_block ($) { |
sub end_code_block ($) { |
280 |
shift->html ('</code></pre>'); |
$_[0]->{handle}->print ('</code></pre>'); |
281 |
} # end_code_block |
} # end_code_block |
282 |
|
|
283 |
sub code ($$;%) { |
sub code ($$;%) { |
284 |
my ($self, $content, %opt) = @_; |
my ($self, $content, %opt) = @_; |
285 |
$self->start_tag ('code', %opt); |
$self->start_tag ('code', %opt); |
286 |
$self->text ($content); |
$self->text ($content); |
287 |
$self->html ('</code>'); |
$self->{handle}->print ('</code>'); |
288 |
} # code |
} # code |
289 |
|
|
290 |
sub script ($$;%) { |
sub script ($$;%) { |
291 |
my ($self, $content, %opt) = @_; |
my ($self, $content, %opt) = @_; |
292 |
$self->start_tag ('script', %opt); |
$self->start_tag ('script', %opt); |
293 |
$self->html ($content); |
$self->{handle}->print ($content . '</script>'); |
|
$self->html ('</script>'); |
|
294 |
} # script |
} # script |
295 |
|
|
296 |
sub dt ($$;%) { |
sub dt ($$;%) { |
311 |
while (@options) { |
while (@options) { |
312 |
my $opt = shift @options; |
my $opt = shift @options; |
313 |
if ($opt->{options}) { |
if ($opt->{options}) { |
314 |
$self->html ('<optgroup label="'); |
$self->{handle}->print ('<optgroup label="'); |
315 |
$self->nl_text ($opt->{label}); |
$self->nl_text ($opt->{label}); |
316 |
$self->html ('">'); |
$self->{handle}->print ('">'); |
317 |
unshift @options, @{$opt->{options}}, {end_options => 1}; |
unshift @options, @{$opt->{options}}, {end_options => 1}; |
318 |
} elsif ($opt->{end_options}) { |
} elsif ($opt->{end_options}) { |
319 |
$self->end_tag ('optgroup'); |
$self->end_tag ('optgroup'); |
331 |
sub link ($$%) { |
sub link ($$%) { |
332 |
my ($self, $content, %opt) = @_; |
my ($self, $content, %opt) = @_; |
333 |
$self->start_tag ('a', %opt, href => $opt{url}); |
$self->start_tag ('a', %opt, href => $opt{url}); |
334 |
$self->text ($content); |
$self->{handle}->print ($htescape->($content) . '</a>'); |
|
$self->html ('</a>'); |
|
335 |
} # link |
} # link |
336 |
|
|
337 |
sub xref ($$%) { |
sub xref ($$%) { |
338 |
my ($self, $content, %opt) = @_; |
my ($self, $content, %opt) = @_; |
339 |
$self->html ('<a href="#' . $htescape->($self->input->id_prefix . $opt{target}) . '">'); |
$self->{handle}->print |
340 |
|
('<a href="#' . $htescape->($self->input->id_prefix . $opt{target}) . '">'); |
341 |
$self->nl_text ($content, text => $opt{text}); |
$self->nl_text ($content, text => $opt{text}); |
342 |
$self->html ('</a>'); |
$self->{handle}->print ('</a>'); |
343 |
} # xref |
} # xref |
344 |
|
|
345 |
sub xref_text ($$%) { |
sub xref_text ($$%) { |
346 |
my ($self, $content, %opt) = @_; |
my ($self, $content, %opt) = @_; |
347 |
$self->html ('<a href="#' . $htescape->($self->input->id_prefix . $opt{target}) . '">'); |
$self->html ('<a href="#' . $htescape->($self->input->id_prefix . $opt{target}) . '">'); |
348 |
$self->text ($content); |
$self->{handle}->print ($htescape->($content) . '</a>'); |
|
$self->html ('</a>'); |
|
349 |
} # xref |
} # xref |
350 |
|
|
351 |
sub link_to_webhacc ($$%) { |
sub link_to_webhacc ($$%) { |
404 |
$self->xref_text ($get_node_path->($node), |
$self->xref_text ($get_node_path->($node), |
405 |
target => 'node-' . refaddr $node); |
target => 'node-' . refaddr $node); |
406 |
} else { |
} else { |
407 |
$self->html ($get_object_path->($node)); |
$self->{handle}->print ($get_object_path->($node)); |
408 |
} |
} |
409 |
} # node_link |
} # node_link |
410 |
|
|
449 |
$msg =~ s{<var>{value}</var>}{ |
$msg =~ s{<var>{value}</var>}{ |
450 |
defined $opt{value} ? $htescape->($opt{value}) : '' |
defined $opt{value} ? $htescape->($opt{value}) : '' |
451 |
}ge; |
}ge; |
452 |
|
$msg =~ s{<var>{octets}</var>}{ |
453 |
|
if (defined $opt{octets}) { |
454 |
|
join ', ', map {sprintf '0x%02X', ord $_} split //, ${$opt{octets}}; |
455 |
|
} else { |
456 |
|
''; |
457 |
|
} |
458 |
|
}ge; |
459 |
|
$msg =~ s{<var>{char}</var>}{ |
460 |
|
defined $opt{char} ? $htescape->(${$opt{char}}) : '' |
461 |
|
}ge; |
462 |
|
$msg =~ s{<var>{char:hexref}</var>}{ |
463 |
|
if (defined $opt{char}) { |
464 |
|
join '', map {sprintf '&#x%02X;', ord $_} split //, ${$opt{char}}; |
465 |
|
} else { |
466 |
|
''; |
467 |
|
} |
468 |
|
}ge; |
469 |
$msg =~ s{<var>{local-name}</var>}{ |
$msg =~ s{<var>{local-name}</var>}{ |
470 |
UNIVERSAL::can ($node, 'manakai_local_name') |
UNIVERSAL::can ($node, 'manakai_local_name') |
471 |
? $htescape->($node->manakai_local_name) : '' |
? $htescape->($node->manakai_local_name) : '' |
475 |
? $htescape->($node->owner_element->manakai_local_name) : '' |
? $htescape->($node->owner_element->manakai_local_name) : '' |
476 |
}ge; |
}ge; |
477 |
} |
} |
478 |
$self->html ($msg); |
$self->{handle}->print ($msg); |
479 |
} else { |
} else { |
480 |
$self->text ($type); |
$self->{handle}->print ($htescape->($type)); |
481 |
} |
} |
482 |
} # nl_text |
} # nl_text |
483 |
|
|
484 |
} |
} |
485 |
|
|
486 |
sub nav_list ($) { |
sub nav_list ($) { |
487 |
my $self = shift; |
# my $self = shift; |
488 |
$self->html (q[<ul class="navigation" id="nav-items">]); |
# $self->html (q[<ul class="navigation" id="nav-items">]); |
489 |
for (@{$self->{nav}}) { |
# for (@{$self->{nav}}) { |
490 |
$self->html (qq[<li><a href="#@{[$htescape->($_->[0])]}">]); |
# $self->html (qq[<li><a href="#@{[$htescape->($_->[0])]}">]); |
491 |
$self->nl_text ($_->[1], text => $_->[2]); |
# $self->nl_text ($_->[1], text => $_->[2]); |
492 |
$self->html ('</a>'); |
# $self->html ('</a>'); |
493 |
} |
# } |
494 |
$self->html ('</ul>'); |
# $self->html ('</ul>'); |
495 |
} # nav_list |
} # nav_list |
496 |
|
|
497 |
sub http_header ($) { |
sub http_header ($) { |
498 |
shift->html (qq[Content-Type: text/html; charset=utf-8\n\n]); |
$_[0]->{handle}->print (qq[Content-Type: text/html; charset=utf-8\n\n]); |
499 |
} # http_header |
} # http_header |
500 |
|
|
501 |
sub http_error ($$) { |
sub http_error ($$) { |
504 |
my $text = { |
my $text = { |
505 |
404 => 'Not Found', |
404 => 'Not Found', |
506 |
}->{$code}; |
}->{$code}; |
507 |
$self->html (qq[Status: $code $text\nContent-Type: text/html ; charset=us-ascii\n\n$code $text]); |
$self->{handle}->print |
508 |
|
(qq[Status: $code $text\nContent-Type: text/html ; charset=us-ascii\n\n$code $text]); |
509 |
} # http_error |
} # http_error |
510 |
|
|
511 |
sub html_header ($) { |
sub html_header ($) { |
512 |
my $self = shift; |
my $self = shift; |
513 |
$self->html (q[<!DOCTYPE html>]); |
$self->{handle}->print (q[<!DOCTYPE html>]); |
514 |
$self->start_tag ('html', lang => $self->{primary_language}); |
$self->start_tag ('html', lang => $self->{primary_language}); |
515 |
$self->html (q[<head><title>]); |
$self->{handle}->print (q[<head><title>]); |
516 |
$self->nl_text (q[WebHACC:Title]); |
$self->nl_text (q[WebHACC:Title]); |
517 |
$self->html (q[</title> |
$self->{handle}->print (q[</title> |
518 |
<link rel="stylesheet" href="../cc-style.css" type="text/css"> |
<link rel="stylesheet" href="../cc-style.css" type="text/css"> |
519 |
<script src="../cc-script.js"></script> |
<script src="../cc-script.js"></script> |
520 |
</head> |
</head> |
521 |
<body onclick=" return onbodyclick (event) " onload=" onbodyload () "> |
<body onclick=" return onbodyclick (event) " onload=" onbodyload () "> |
522 |
<h1>]); |
<h1>]); |
523 |
$self->nl_text (q[WebHACC:Heading]); |
$self->nl_text (q[WebHACC:Heading]); |
524 |
$self->html (q[</h1><script> insertNavSections () </script>]); |
$self->{handle}->print (q[</h1><script> insertNavSections () </script>]); |
525 |
} # html_header |
} # html_header |
526 |
|
|
527 |
sub generate_input_section ($$) { |
sub generate_input_section ($$) { |
539 |
my $options = sub ($) { |
my $options = sub ($) { |
540 |
my $context = shift; |
my $context = shift; |
541 |
|
|
542 |
$out->html (q[<div class="details default"><p class=legend onclick="nextSibling.style.display = nextSibling.style.display == 'block' ? 'none' : 'block'; parentNode.className = nextSibling.style.display == 'none' ? 'details' : 'details open'">]); |
$out->{handle}->print (q[<div class="details default"><p class=legend onclick="nextSibling.style.display = nextSibling.style.display == 'block' ? 'none' : 'block'; parentNode.className = nextSibling.style.display == 'none' ? 'details' : 'details open'" tabindex=0>]); |
543 |
$out->nl_text (q[Options]); |
$out->nl_text (q[Options]); |
544 |
$out->start_tag ('div'); |
$out->start_tag ('div'); |
545 |
|
|
561 |
$out->select ([ |
$out->select ([ |
562 |
{value => '', label => 'As specified'}, |
{value => '', label => 'As specified'}, |
563 |
{value => 'application/atom+xml'}, |
{value => 'application/atom+xml'}, |
564 |
|
{value => 'text/cache-manifest'}, |
565 |
|
{value => 'text/css'}, |
566 |
|
{value => 'text/x-css-inline'}, |
567 |
|
{value => 'text/x-h2h'}, |
568 |
|
{value => 'text/html'}, |
569 |
|
{value => 'text/x-regexp-js'}, |
570 |
|
{value => 'text/x-webidl'}, |
571 |
{value => 'application/xhtml+xml'}, |
{value => 'application/xhtml+xml'}, |
572 |
{value => 'application/xml'}, |
{value => 'application/xml'}, |
|
{value => 'text/html'}, |
|
573 |
{value => 'text/xml'}, |
{value => 'text/xml'}, |
|
{value => 'text/css'}, |
|
|
{value => 'text/cache-manifest'}, |
|
|
{value => 'text/x-webidl'}, |
|
574 |
], name => 'i', selected => scalar $cgi->get_parameter ('i')); |
], name => 'i', selected => scalar $cgi->get_parameter ('i')); |
575 |
$out->end_tag ('label'); |
$out->end_tag ('label'); |
576 |
|
|
584 |
{label => 'Japanese charsets', options => [ |
{label => 'Japanese charsets', options => [ |
585 |
{value => 'Windows-31J'}, |
{value => 'Windows-31J'}, |
586 |
{value => 'Shift_JIS'}, |
{value => 'Shift_JIS'}, |
587 |
|
{value => 'x-sjis'}, |
588 |
{value => 'EUC-JP'}, |
{value => 'EUC-JP'}, |
589 |
|
{value => 'x-euc-jp'}, |
590 |
{value => 'ISO-2022-JP'}, |
{value => 'ISO-2022-JP'}, |
591 |
|
{value => 'ISO-2022-JP-1'}, |
592 |
|
{value => 'ISO-2022-JP-2'}, |
593 |
]}, |
]}, |
594 |
{label => 'European charsets', options => [ |
{label => 'Latin charsets', options => [ |
595 |
|
{value => 'Windows-1250'}, |
596 |
{value => 'Windows-1252'}, |
{value => 'Windows-1252'}, |
597 |
|
{value => 'Windows-1254'}, |
598 |
|
{value => 'Windows-1257'}, |
599 |
|
{value => 'Windows-1258'}, |
600 |
{value => 'ISO-8859-1'}, |
{value => 'ISO-8859-1'}, |
601 |
|
{value => 'ISO-8859-2'}, |
602 |
|
{value => 'ISO-8859-3'}, |
603 |
|
{value => 'ISO-8859-4'}, |
604 |
|
{value => 'ISO-8859-9'}, |
605 |
|
{value => 'ISO-8859-10'}, |
606 |
|
{value => 'ISO-8859-13'}, |
607 |
|
{value => 'ISO-8859-14'}, |
608 |
|
{value => 'ISO-8859-15'}, |
609 |
|
{value => 'ISO-8859-16'}, |
610 |
{value => 'US-ASCII'}, |
{value => 'US-ASCII'}, |
611 |
]}, |
]}, |
612 |
{label => 'Asian charsets', options => [ |
{label => 'Greek charsets', options => [ |
613 |
|
{value => 'Windows-1253'}, |
614 |
|
{value => 'ISO-8859-7'}, |
615 |
|
]}, |
616 |
|
{label => 'Cyrillic charsets', options => [ |
617 |
|
{value => 'Windows-1251'}, |
618 |
|
{value => 'ISO-8859-5'}, |
619 |
|
]}, |
620 |
|
{label => 'Arabic charsets', options => [ |
621 |
|
{value => 'Windows-1256'}, |
622 |
|
{value => 'ISO-8859-6'}, |
623 |
|
]}, |
624 |
|
{label => 'Hebrew charsets', options => [ |
625 |
|
{value => 'Windows-1255'}, |
626 |
|
{value => 'ISO-8859-8'}, |
627 |
|
]}, |
628 |
|
{label => 'Thai charsets', options => [ |
629 |
{value => 'Windows-874'}, |
{value => 'Windows-874'}, |
630 |
{value => 'ISO-8859-11'}, |
{value => 'ISO-8859-11'}, |
631 |
{value => 'TIS-620'}, |
{value => 'TIS-620'}, |
632 |
]}, |
]}, |
633 |
|
{label => 'Chinese charsets', options => [ |
634 |
|
{value => 'Big5'}, |
635 |
|
{value => 'x-x-big5'}, |
636 |
|
{value => 'Big5-HKSCS'}, |
637 |
|
{value => 'GBK'}, |
638 |
|
{value => 'GB2312'}, |
639 |
|
{value => 'GB_2312-80'}, |
640 |
|
{value => 'ISO-2022-CN'}, |
641 |
|
{value => 'ISO-2022-CN-EXT'}, |
642 |
|
]}, |
643 |
|
{label => 'Korean charsets', options => [ |
644 |
|
{value => 'Windows-949'}, |
645 |
|
{value => 'EUC-KR'}, |
646 |
|
{value => 'KS_C_5601-1987'}, |
647 |
|
{value => 'ISO-2022-KR'}, |
648 |
|
]}, |
649 |
{label => 'Unicode charsets', options => [ |
{label => 'Unicode charsets', options => [ |
650 |
{value => 'UTF-8'}, |
{value => 'UTF-8'}, |
651 |
{value => 'UTF-8n'}, |
{value => 'UTF-8n'}, |
652 |
]}, |
{value => 'UTF-16'}, |
653 |
|
{value => 'UTF-16BE'}, |
654 |
|
{value => 'UTF-16LE'}, |
655 |
|
]}, |
656 |
], name => 'charset', |
], name => 'charset', |
657 |
selected => scalar $cgi->get_parameter ('charset')); |
selected => scalar $cgi->get_parameter ('charset')); |
658 |
$out->end_tag ('label'); |
$out->end_tag ('label'); |
668 |
$out->end_tag ('label'); |
$out->end_tag ('label'); |
669 |
} |
} |
670 |
|
|
671 |
$out->html (q[</div></div>]); |
$out->{handle}->print (q[</div></div>]); |
672 |
}; # $options |
}; # $options |
673 |
|
|
674 |
$out->start_section (id => 'input', title => 'Input'); |
$out->start_section (id => 'input', title => 'Input'); |