--- test/html-webhacc/WebHACC/Output.pm 2008/08/17 05:06:21 1.22 +++ test/html-webhacc/WebHACC/Output.pm 2008/09/17 03:56:43 1.26 @@ -8,11 +8,11 @@ my $s = $_[0]; $s =~ s/&/&/g; $s =~ s//>/g; +# $s =~ s/>/>/g; $s =~ s/"/"/g; - $s =~ s{([\x00-\x09\x0B-\x1F\x7F-\xA0\x{FEFF}\x{FFFC}-\x{FFFF}])}{ - 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; }; @@ -20,7 +20,7 @@ my $s = $_[0]; $s =~ s/&/&/g; $s =~ s//>/g; +# $s =~ s/>/>/g; $s =~ s/"/"/g; return $s; }; @@ -68,49 +68,49 @@ } # has_error sub set_utf8 ($) { - binmode shift->{handle}, ':utf8'; + binmode $_[0]->{handle}, ':utf8'; } # set_utf8 sub set_flush ($) { - shift->{handle}->autoflush (1); + $_[0]->{handle}->autoflush (1); } # set_flush sub unset_flush ($) { - shift->{handle}->autoflush (0); + $_[0]->{handle}->autoflush (0); } # unset_flush sub html ($$) { - shift->{handle}->print (shift); + $_[0]->{handle}->print ($_[1]); } # html sub text ($$) { - shift->html ($htescape->(shift)); + $_[0]->{handle}->print ($htescape->($_[1])); } # text sub url ($$%) { my ($self, $url, %opt) = @_; - $self->html (q[<]); + $self->{handle}->print (q[<]); $self->link ($url, %opt, url => $url); - $self->html (q[>]); + $self->{handle}->print (q[>]); } # url sub start_tag ($$%) { my ($self, $tag_name, %opt) = @_; - $self->html ('<' . $htescape_value->($tag_name)); # escape for safety + $self->{handle}->print ('<' . $tag_name); if (exists $opt{id}) { my $id = $self->input->id_prefix . $opt{id}; - $self->html (' id="' . $htescape_value->($id) . '"'); + $self->{handle}->print (' id="' . $htescape_value->($id) . '"'); delete $opt{id}; } - for (keys %opt) { # for safety - $self->html (' ' . $htescape_value->($_) . '="' . - $htescape_value->($opt{$_}) . '"'); + for (keys %opt) { + $self->{handle}->print + (' ' . $_ . '="' . $htescape_value->($opt{$_}) . '"'); } - $self->html ('>'); + $self->{handle}->print ('>'); } # start_tag sub end_tag ($$) { - shift->html ('(shift) . '>'); + $_[0]->{handle}->print (''); } # end_tag sub start_section ($%) { @@ -271,25 +271,24 @@ } # add_source_to_parse_error_list sub start_code_block ($) { - shift->html ('
');
+  $_[0]->{handle}->print ('
');
 } # start_code_block
 
 sub end_code_block ($) {
-  shift->html ('
'); + $_[0]->{handle}->print ('
'); } # end_code_block sub code ($$;%) { my ($self, $content, %opt) = @_; $self->start_tag ('code', %opt); $self->text ($content); - $self->html (''); + $self->{handle}->print (''); } # code sub script ($$;%) { my ($self, $content, %opt) = @_; $self->start_tag ('script', %opt); - $self->html ($content); - $self->html (''); + $self->{handle}->print ($content . ''); } # script sub dt ($$;%) { @@ -310,9 +309,9 @@ while (@options) { my $opt = shift @options; if ($opt->{options}) { - $self->html ('nl_text ($opt->{label}); - $self->html ('">'); + $self->{handle}->print ('">'); unshift @options, @{$opt->{options}}, {end_options => 1}; } elsif ($opt->{end_options}) { $self->end_tag ('optgroup'); @@ -330,22 +329,21 @@ sub link ($$%) { my ($self, $content, %opt) = @_; $self->start_tag ('a', %opt, href => $opt{url}); - $self->text ($content); - $self->html (''); + $self->{handle}->print ($htescape->($content) . ''); } # link sub xref ($$%) { my ($self, $content, %opt) = @_; - $self->html (''); + $self->{handle}->print + (''); $self->nl_text ($content, text => $opt{text}); - $self->html (''); + $self->{handle}->print (''); } # xref sub xref_text ($$%) { my ($self, $content, %opt) = @_; $self->html (''); - $self->text ($content); - $self->html (''); + $self->{handle}->print ($htescape->($content) . ''); } # xref sub link_to_webhacc ($$%) { @@ -404,7 +402,7 @@ $self->xref_text ($get_node_path->($node), target => 'node-' . refaddr $node); } else { - $self->html ($get_object_path->($node)); + $self->{handle}->print ($get_object_path->($node)); } } # node_link @@ -449,6 +447,23 @@ $msg =~ s{{value}}{ defined $opt{value} ? $htescape->($opt{value}) : '' }ge; + $msg =~ s{{octets}}{ + if (defined $opt{octets}) { + join ', ', map {sprintf '0x%02X', ord $_} split //, ${$opt{octets}}; + } else { + ''; + } + }ge; + $msg =~ s{{char}}{ + defined $opt{char} ? $htescape->(${$opt{char}}) : '' + }ge; + $msg =~ s{{char:hexref}}{ + if (defined $opt{char}) { + join '', map {sprintf '&#x%02X;', ord $_} split //, ${$opt{char}}; + } else { + ''; + } + }ge; $msg =~ s{{local-name}}{ UNIVERSAL::can ($node, 'manakai_local_name') ? $htescape->($node->manakai_local_name) : '' @@ -458,27 +473,27 @@ ? $htescape->($node->owner_element->manakai_local_name) : '' }ge; } - $self->html ($msg); + $self->{handle}->print ($msg); } else { - $self->text ($type); + $self->{handle}->print ($htescape->($type)); } } # nl_text } sub nav_list ($) { - my $self = shift; - $self->html (q['); +# my $self = shift; +# $self->html (q['); } # nav_list sub http_header ($) { - 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]); } # http_header sub http_error ($$) { @@ -487,23 +502,24 @@ my $text = { 404 => 'Not Found', }->{$code}; - $self->html (qq[Status: $code $text\nContent-Type: text/html ; charset=us-ascii\n\n$code $text]); + $self->{handle}->print + (qq[Status: $code $text\nContent-Type: text/html ; charset=us-ascii\n\n$code $text]); } # http_error sub html_header ($) { my $self = shift; - $self->html (q[]); + $self->{handle}->print (q[]); $self->start_tag ('html', lang => $self->{primary_language}); - $self->html (q[]); + $self->{handle}->print (q[<head><title>]); $self->nl_text (q[WebHACC:Title]); - $self->html (q[ + $self->{handle}->print (q[

]); $self->nl_text (q[WebHACC:Heading]); - $self->html (q[

]); + $self->{handle}->print (q[]); } # html_header sub generate_input_section ($$) { @@ -521,7 +537,7 @@ my $options = sub ($) { my $context = shift; - $out->html (q[

]); + $out->{handle}->print (q[

]); $out->nl_text (q[Options]); $out->start_tag ('div'); @@ -545,6 +561,7 @@ {value => 'application/atom+xml'}, {value => 'text/cache-manifest'}, {value => 'text/css'}, + {value => 'text/x-css-inline'}, {value => 'text/x-h2h'}, {value => 'text/html'}, {value => 'text/x-webidl'}, @@ -564,23 +581,75 @@ {label => 'Japanese charsets', options => [ {value => 'Windows-31J'}, {value => 'Shift_JIS'}, + {value => 'x-sjis'}, {value => 'EUC-JP'}, + {value => 'x-euc-jp'}, {value => 'ISO-2022-JP'}, + {value => 'ISO-2022-JP-1'}, + {value => 'ISO-2022-JP-2'}, ]}, - {label => 'European charsets', options => [ + {label => 'Latin charsets', options => [ + {value => 'Windows-1250'}, {value => 'Windows-1252'}, + {value => 'Windows-1254'}, + {value => 'Windows-1257'}, + {value => 'Windows-1258'}, {value => 'ISO-8859-1'}, + {value => 'ISO-8859-2'}, + {value => 'ISO-8859-3'}, + {value => 'ISO-8859-4'}, + {value => 'ISO-8859-9'}, + {value => 'ISO-8859-10'}, + {value => 'ISO-8859-13'}, + {value => 'ISO-8859-14'}, + {value => 'ISO-8859-15'}, + {value => 'ISO-8859-16'}, {value => 'US-ASCII'}, ]}, - {label => 'Asian charsets', options => [ + {label => 'Greek charsets', options => [ + {value => 'Windows-1253'}, + {value => 'ISO-8859-7'}, + ]}, + {label => 'Cyrillic charsets', options => [ + {value => 'Windows-1251'}, + {value => 'ISO-8859-5'}, + ]}, + {label => 'Arabic charsets', options => [ + {value => 'Windows-1256'}, + {value => 'ISO-8859-6'}, + ]}, + {label => 'Hebrew charsets', options => [ + {value => 'Windows-1255'}, + {value => 'ISO-8859-8'}, + ]}, + {label => 'Thai charsets', options => [ {value => 'Windows-874'}, {value => 'ISO-8859-11'}, {value => 'TIS-620'}, ]}, + {label => 'Chinese charsets', options => [ + {value => 'Big5'}, + {value => 'x-x-big5'}, + {value => 'Big5-HKSCS'}, + {value => 'GBK'}, + {value => 'GB2312'}, + {value => 'GB_2312-80'}, + {value => 'ISO-2022-CN'}, + {value => 'ISO-2022-CN-EXT'}, + ]}, + {label => 'Korean charsets', options => [ + {value => 'Windows-949'}, + {value => 'EUC-KR'}, + {value => 'KS_C_5601-1987'}, + {value => 'ISO-2022-KR'}, + ]}, {label => 'Unicode charsets', options => [ {value => 'UTF-8'}, {value => 'UTF-8n'}, - ]}, + {value => 'UTF-16'}, + {value => 'UTF-16BE'}, + {value => 'UTF-16LE'}, + ]}, ], name => 'charset', selected => scalar $cgi->get_parameter ('charset')); $out->end_tag ('label'); @@ -596,7 +665,7 @@ $out->end_tag ('label'); } - $out->html (q[

]); + $out->{handle}->print (q[]); }; # $options $out->start_section (id => 'input', title => 'Input');