--- test/html-webhacc/WebHACC/Output.pm 2008/07/21 09:40:59 1.5 +++ test/html-webhacc/WebHACC/Output.pm 2008/08/14 09:16:52 1.13 @@ -16,8 +16,19 @@ return $s; }; +my $htescape_value = sub ($) { + my $s = $_[0]; + $s =~ s/&/&/g; + $s =~ s/</g; + $s =~ s/>/>/g; + $s =~ s/"/"/g; + return $s; +}; + sub new ($) { - return bless {nav => [], section_rank => 1}, shift; + require WebHACC::Input; + return bless {nav => [], section_rank => 1, + input => WebHACC::Input->new}, shift; } # new sub input ($;$) { @@ -25,7 +36,7 @@ if (defined $_[1]) { $_[0]->{input} = $_[1]; } else { - delete $_[0]->{input}; + $_[0]->{input} = WebHACC::Input->new; } } @@ -73,29 +84,32 @@ sub start_tag ($$%) { my ($self, $tag_name, %opt) = @_; - $self->html ('<' . $htescape->($tag_name)); # escape for safety + $self->html ('<' . $htescape_value->($tag_name)); # escape for safety if (exists $opt{id}) { my $id = $self->input->id_prefix . $opt{id}; - $self->html (' id="' . $htescape->($id) . '"'); + $self->html (' id="' . $htescape_value->($id) . '"'); delete $opt{id}; } for (keys %opt) { # for safety - $self->html (' ' . $htescape->($_) . '="' . $htescape->($opt{$_}) . '"'); + $self->html (' ' . $htescape_value->($_) . '="' . + $htescape_value->($opt{$_}) . '"'); } $self->html ('>'); } # start_tag sub end_tag ($$) { - shift->html ('' . $htescape->(shift) . '>'); + shift->html ('' . $htescape_value->(shift) . '>'); } # end_tag sub start_section ($%) { my ($self, %opt) = @_; + my $class = 'section'; if (defined $opt{role}) { if ($opt{role} eq 'parse-errors') { $opt{id} ||= 'parse-errors'; - $opt{title} ||= 'Parse Errors'; + $opt{title} ||= 'Parse Errors Section'; + $opt{short_title} ||= 'Parse Errors'; delete $opt{role}; } elsif ($opt{role} eq 'structure-errors') { $opt{id} ||= 'document-errors'; @@ -117,22 +131,41 @@ $opt{title} ||= 'Document Structure'; $opt{short_title} ||= 'Structure'; delete $opt{role}; + } elsif ($opt{role} eq 'subdoc') { + $class .= ' subdoc'; + delete $opt{role}; } } $self->{section_rank}++; - $self->html ('