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 ($%) { |
271 |
} # add_source_to_parse_error_list |
} # add_source_to_parse_error_list |
272 |
|
|
273 |
sub start_code_block ($) { |
sub start_code_block ($) { |
274 |
shift->html ('<pre><code>'); |
$_[0]->{handle}->print ('<pre><code>'); |
275 |
} # start_code_block |
} # start_code_block |
276 |
|
|
277 |
sub end_code_block ($) { |
sub end_code_block ($) { |
278 |
shift->html ('</code></pre>'); |
$_[0]->{handle}->print ('</code></pre>'); |
279 |
} # end_code_block |
} # end_code_block |
280 |
|
|
281 |
sub code ($$;%) { |
sub code ($$;%) { |
282 |
my ($self, $content, %opt) = @_; |
my ($self, $content, %opt) = @_; |
283 |
$self->start_tag ('code', %opt); |
$self->start_tag ('code', %opt); |
284 |
$self->text ($content); |
$self->text ($content); |
285 |
$self->html ('</code>'); |
$self->{handle}->print ('</code>'); |
286 |
} # code |
} # code |
287 |
|
|
288 |
sub script ($$;%) { |
sub script ($$;%) { |
289 |
my ($self, $content, %opt) = @_; |
my ($self, $content, %opt) = @_; |
290 |
$self->start_tag ('script', %opt); |
$self->start_tag ('script', %opt); |
291 |
$self->html ($content); |
$self->{handle}->print ($content . '</script>'); |
|
$self->html ('</script>'); |
|
292 |
} # script |
} # script |
293 |
|
|
294 |
sub dt ($$;%) { |
sub dt ($$;%) { |
309 |
while (@options) { |
while (@options) { |
310 |
my $opt = shift @options; |
my $opt = shift @options; |
311 |
if ($opt->{options}) { |
if ($opt->{options}) { |
312 |
$self->html ('<optgroup label="'); |
$self->{handle}->print ('<optgroup label="'); |
313 |
$self->nl_text ($opt->{label}); |
$self->nl_text ($opt->{label}); |
314 |
$self->html ('">'); |
$self->{handle}->print ('">'); |
315 |
unshift @options, @{$opt->{options}}, {end_options => 1}; |
unshift @options, @{$opt->{options}}, {end_options => 1}; |
316 |
} elsif ($opt->{end_options}) { |
} elsif ($opt->{end_options}) { |
317 |
$self->end_tag ('optgroup'); |
$self->end_tag ('optgroup'); |
329 |
sub link ($$%) { |
sub link ($$%) { |
330 |
my ($self, $content, %opt) = @_; |
my ($self, $content, %opt) = @_; |
331 |
$self->start_tag ('a', %opt, href => $opt{url}); |
$self->start_tag ('a', %opt, href => $opt{url}); |
332 |
$self->text ($content); |
$self->{handle}->print ($htescape->($content) . '</a>'); |
|
$self->html ('</a>'); |
|
333 |
} # link |
} # link |
334 |
|
|
335 |
sub xref ($$%) { |
sub xref ($$%) { |
336 |
my ($self, $content, %opt) = @_; |
my ($self, $content, %opt) = @_; |
337 |
$self->html ('<a href="#' . $htescape->($self->input->id_prefix . $opt{target}) . '">'); |
$self->{handle}->print |
338 |
|
('<a href="#' . $htescape->($self->input->id_prefix . $opt{target}) . '">'); |
339 |
$self->nl_text ($content, text => $opt{text}); |
$self->nl_text ($content, text => $opt{text}); |
340 |
$self->html ('</a>'); |
$self->{handle}->print ('</a>'); |
341 |
} # xref |
} # xref |
342 |
|
|
343 |
sub xref_text ($$%) { |
sub xref_text ($$%) { |
344 |
my ($self, $content, %opt) = @_; |
my ($self, $content, %opt) = @_; |
345 |
$self->html ('<a href="#' . $htescape->($self->input->id_prefix . $opt{target}) . '">'); |
$self->html ('<a href="#' . $htescape->($self->input->id_prefix . $opt{target}) . '">'); |
346 |
$self->text ($content); |
$self->{handle}->print ($htescape->($content) . '</a>'); |
|
$self->html ('</a>'); |
|
347 |
} # xref |
} # xref |
348 |
|
|
349 |
sub link_to_webhacc ($$%) { |
sub link_to_webhacc ($$%) { |
402 |
$self->xref_text ($get_node_path->($node), |
$self->xref_text ($get_node_path->($node), |
403 |
target => 'node-' . refaddr $node); |
target => 'node-' . refaddr $node); |
404 |
} else { |
} else { |
405 |
$self->html ($get_object_path->($node)); |
$self->{handle}->print ($get_object_path->($node)); |
406 |
} |
} |
407 |
} # node_link |
} # node_link |
408 |
|
|
473 |
? $htescape->($node->owner_element->manakai_local_name) : '' |
? $htescape->($node->owner_element->manakai_local_name) : '' |
474 |
}ge; |
}ge; |
475 |
} |
} |
476 |
$self->html ($msg); |
$self->{handle}->print ($msg); |
477 |
} else { |
} else { |
478 |
$self->text ($type); |
$self->{handle}->print ($htescape->($type)); |
479 |
} |
} |
480 |
} # nl_text |
} # nl_text |
481 |
|
|
482 |
} |
} |
483 |
|
|
484 |
sub nav_list ($) { |
sub nav_list ($) { |
485 |
my $self = shift; |
# my $self = shift; |
486 |
$self->html (q[<ul class="navigation" id="nav-items">]); |
# $self->html (q[<ul class="navigation" id="nav-items">]); |
487 |
for (@{$self->{nav}}) { |
# for (@{$self->{nav}}) { |
488 |
$self->html (qq[<li><a href="#@{[$htescape->($_->[0])]}">]); |
# $self->html (qq[<li><a href="#@{[$htescape->($_->[0])]}">]); |
489 |
$self->nl_text ($_->[1], text => $_->[2]); |
# $self->nl_text ($_->[1], text => $_->[2]); |
490 |
$self->html ('</a>'); |
# $self->html ('</a>'); |
491 |
} |
# } |
492 |
$self->html ('</ul>'); |
# $self->html ('</ul>'); |
493 |
} # nav_list |
} # nav_list |
494 |
|
|
495 |
sub http_header ($) { |
sub http_header ($) { |
496 |
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]); |
497 |
} # http_header |
} # http_header |
498 |
|
|
499 |
sub http_error ($$) { |
sub http_error ($$) { |
502 |
my $text = { |
my $text = { |
503 |
404 => 'Not Found', |
404 => 'Not Found', |
504 |
}->{$code}; |
}->{$code}; |
505 |
$self->html (qq[Status: $code $text\nContent-Type: text/html ; charset=us-ascii\n\n$code $text]); |
$self->{handle}->print |
506 |
|
(qq[Status: $code $text\nContent-Type: text/html ; charset=us-ascii\n\n$code $text]); |
507 |
} # http_error |
} # http_error |
508 |
|
|
509 |
sub html_header ($) { |
sub html_header ($) { |
510 |
my $self = shift; |
my $self = shift; |
511 |
$self->html (q[<!DOCTYPE html>]); |
$self->{handle}->print (q[<!DOCTYPE html>]); |
512 |
$self->start_tag ('html', lang => $self->{primary_language}); |
$self->start_tag ('html', lang => $self->{primary_language}); |
513 |
$self->html (q[<head><title>]); |
$self->{handle}->print (q[<head><title>]); |
514 |
$self->nl_text (q[WebHACC:Title]); |
$self->nl_text (q[WebHACC:Title]); |
515 |
$self->html (q[</title> |
$self->{handle}->print (q[</title> |
516 |
<link rel="stylesheet" href="../cc-style.css" type="text/css"> |
<link rel="stylesheet" href="../cc-style.css" type="text/css"> |
517 |
<script src="../cc-script.js"></script> |
<script src="../cc-script.js"></script> |
518 |
</head> |
</head> |
519 |
<body onclick=" return onbodyclick (event) " onload=" onbodyload () "> |
<body onclick=" return onbodyclick (event) " onload=" onbodyload () "> |
520 |
<h1>]); |
<h1>]); |
521 |
$self->nl_text (q[WebHACC:Heading]); |
$self->nl_text (q[WebHACC:Heading]); |
522 |
$self->html (q[</h1><script> insertNavSections () </script>]); |
$self->{handle}->print (q[</h1><script> insertNavSections () </script>]); |
523 |
} # html_header |
} # html_header |
524 |
|
|
525 |
sub generate_input_section ($$) { |
sub generate_input_section ($$) { |
537 |
my $options = sub ($) { |
my $options = sub ($) { |
538 |
my $context = shift; |
my $context = shift; |
539 |
|
|
540 |
$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'" tabindex=0>]); |
$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>]); |
541 |
$out->nl_text (q[Options]); |
$out->nl_text (q[Options]); |
542 |
$out->start_tag ('div'); |
$out->start_tag ('div'); |
543 |
|
|
664 |
$out->end_tag ('label'); |
$out->end_tag ('label'); |
665 |
} |
} |
666 |
|
|
667 |
$out->html (q[</div></div>]); |
$out->{handle}->print (q[</div></div>]); |
668 |
}; # $options |
}; # $options |
669 |
|
|
670 |
$out->start_section (id => 'input', title => 'Input'); |
$out->start_section (id => 'input', title => 'Input'); |