--- test/html-webhacc/WebHACC/Output.pm 2008/07/21 05:24:32 1.3
+++ test/html-webhacc/WebHACC/Output.pm 2008/07/27 10:33:46 1.9
@@ -17,7 +17,9 @@
};
sub new ($) {
- return bless {nav => []}, shift;
+ require WebHACC::Input;
+ return bless {nav => [], section_rank => 1,
+ input => WebHACC::Input->new}, shift;
} # new
sub input ($;$) {
@@ -25,7 +27,7 @@
if (defined $_[1]) {
$_[0]->{input} = $_[1];
} else {
- delete $_[0]->{input};
+ $_[0]->{input} = WebHACC::Input->new;
}
}
@@ -91,22 +93,105 @@
sub start_section ($%) {
my ($self, %opt) = @_;
+
+ if (defined $opt{role}) {
+ if ($opt{role} eq 'parse-errors') {
+ $opt{id} ||= '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';
+ $opt{title} ||= 'Structural Errors';
+ $opt{short_title} ||= 'Struct. Errors';
+ delete $opt{role};
+ } elsif ($opt{role} eq 'reformatted') {
+ $opt{id} ||= 'document-tree';
+ $opt{title} ||= 'Reformatted Document Source';
+ $opt{short_title} ||= 'Reformatted';
+ delete $opt{role}
+ } elsif ($opt{role} eq 'tree') {
+ $opt{id} ||= 'document-tree';
+ $opt{title} ||= 'Document Tree';
+ $opt{short_title} ||= 'Tree';
+ delete $opt{role};
+ } elsif ($opt{role} eq 'structure') {
+ $opt{id} ||= 'document-structure';
+ $opt{title} ||= 'Document Structure';
+ $opt{short_title} ||= 'Structure';
+ delete $opt{role};
+ }
+ }
+
+ $self->{section_rank}++;
$self->html ('
input->id_prefix . $opt{id};
$self->html (' id="' . $htescape->($id) . '"');
- push @{$self->{nav}}, [$id => $opt{short_title} || $opt{title}]
- unless $self->input->nested;
+ push @{$self->{nav}},
+ [$id => $opt{short_title} || $opt{title} => $opt{text}]
+ if $self->{section_rank} == 2;
}
- $self->html ('>
' . $htescape->($opt{title}) . '
');
+ my $section_rank = $self->{section_rank};
+ $section_rank = 6 if $section_rank > 6;
+ $self->html ('>');
+ $self->nl_text ($opt{title}, text => $opt{text});
+ $self->html ('');
} # start_section
sub end_section ($) {
my $self = shift;
$self->html ('');
$self->{handle}->flush;
+ $self->{section_rank}--;
} # end_section
+sub start_error_list ($%) {
+ my ($self, %opt) = @_;
+
+ if (defined $opt{role}) {
+ if ($opt{role} eq 'parse-errors') {
+ $opt{id} ||= 'parse-errors-list';
+ delete $opt{role};
+ } elsif ($opt{role} eq 'structure-errors') {
+ $opt{id} ||= 'document-errors-list';
+ delete $opt{role};
+ }
+ }
+
+ $self->start_tag ('dl', %opt);
+} # start_error_list
+
+sub end_error_list ($%) {
+ my ($self, %opt) = @_;
+
+ if (defined $opt{role}) {
+ if ($opt{role} eq 'parse-errors') {
+ delete $opt{role};
+ $self->end_tag ('dl');
+ ## NOTE: For parse error list, the |add_source_to_parse_error_list|
+ ## method is invoked at the end of |generate_source_string_section|,
+ ## since that generation method is invoked after the error list
+ ## is generated.
+ } elsif ($opt{role} eq 'structure-errors') {
+ delete $opt{role};
+ $self->end_tag ('dl');
+ $self->add_source_to_parse_error_list ('document-errors-list');
+ } else {
+ $self->end_tag ('dl');
+ }
+ } else {
+ $self->end_tag ('dl');
+ }
+} # end_error_list
+
+sub add_source_to_parse_error_list ($$) {
+ my $self = shift;
+
+ $self->script (q[addSourceToParseErrorList ('] . $self->input->id_prefix .
+ q[', '] . shift () . q[')]);
+} # add_source_to_parse_error_list
+
sub start_code_block ($) {
shift->html ('');
} # start_code_block
@@ -132,9 +217,38 @@
sub dt ($$;%) {
my ($self, $content, %opt) = @_;
$self->start_tag ('dt', %opt);
- $self->text ($content);
+ $self->nl_text ($content, text => $opt{text});
} # dt
+sub select ($$%) {
+ my ($self, $options, %opt) = @_;
+
+ my $selected = $opt{selected};
+ delete $opt{selected};
+
+ $self->start_tag ('select', %opt);
+
+ my @options = @$options;
+ while (@options) {
+ my $opt = shift @options;
+ if ($opt->{options}) {
+ $self->html ('