| 17 |
}; |
}; |
| 18 |
|
|
| 19 |
sub new ($) { |
sub new ($) { |
| 20 |
return bless {nav => []}, shift; |
return bless {nav => [], section_rank => 1}, shift; |
| 21 |
} # new |
} # new |
| 22 |
|
|
| 23 |
sub input ($;$) { |
sub input ($;$) { |
| 91 |
|
|
| 92 |
sub start_section ($%) { |
sub start_section ($%) { |
| 93 |
my ($self, %opt) = @_; |
my ($self, %opt) = @_; |
| 94 |
|
|
| 95 |
|
if (defined $opt{role}) { |
| 96 |
|
if ($opt{role} eq 'parse-errors') { |
| 97 |
|
$opt{id} ||= 'parse-errors'; |
| 98 |
|
$opt{title} ||= 'Parse Errors'; |
| 99 |
|
delete $opt{role}; |
| 100 |
|
} elsif ($opt{role} eq 'structure-errors') { |
| 101 |
|
$opt{id} ||= 'document-errors'; |
| 102 |
|
$opt{title} ||= 'Structural Errors'; |
| 103 |
|
$opt{short_title} ||= 'Struct. Errors'; |
| 104 |
|
delete $opt{role}; |
| 105 |
|
} elsif ($opt{role} eq 'reformatted') { |
| 106 |
|
$opt{id} ||= 'document-tree'; |
| 107 |
|
$opt{title} ||= 'Reformatted Document Source'; |
| 108 |
|
$opt{short_title} ||= 'Reformatted'; |
| 109 |
|
delete $opt{role} |
| 110 |
|
} elsif ($opt{role} eq 'tree') { |
| 111 |
|
$opt{id} ||= 'document-tree'; |
| 112 |
|
$opt{title} ||= 'Document Tree'; |
| 113 |
|
$opt{short_title} ||= 'Tree'; |
| 114 |
|
delete $opt{role}; |
| 115 |
|
} elsif ($opt{role} eq 'structure') { |
| 116 |
|
$opt{id} ||= 'document-structure'; |
| 117 |
|
$opt{title} ||= 'Document Structure'; |
| 118 |
|
$opt{short_title} ||= 'Structure'; |
| 119 |
|
delete $opt{role}; |
| 120 |
|
} |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
$self->{section_rank}++; |
| 124 |
$self->html ('<div class=section'); |
$self->html ('<div class=section'); |
| 125 |
if (defined $opt{id}) { |
if (defined $opt{id}) { |
| 126 |
my $id = $self->input->id_prefix . $opt{id}; |
my $id = $self->input->id_prefix . $opt{id}; |
| 127 |
$self->html (' id="' . $htescape->($id) . '"'); |
$self->html (' id="' . $htescape->($id) . '"'); |
| 128 |
push @{$self->{nav}}, [$id => $opt{short_title} || $opt{title}] |
push @{$self->{nav}}, [$id => $opt{short_title} || $opt{title}] |
| 129 |
unless $self->input->nested; |
if $self->{section_rank} == 2; |
| 130 |
} |
} |
| 131 |
$self->html ('><h2>' . $htescape->($opt{title}) . '</h2>'); |
my $section_rank = $self->{section_rank}; |
| 132 |
|
$section_rank = 6 if $section_rank > 6; |
| 133 |
|
$self->html ('><h' . $section_rank . '>' . |
| 134 |
|
$htescape->($opt{title}) . |
| 135 |
|
'</h' . $section_rank . '>'); |
| 136 |
} # start_section |
} # start_section |
| 137 |
|
|
| 138 |
sub end_section ($) { |
sub end_section ($) { |
| 139 |
my $self = shift; |
my $self = shift; |
| 140 |
$self->html ('</div>'); |
$self->html ('</div>'); |
| 141 |
$self->{handle}->flush; |
$self->{handle}->flush; |
| 142 |
|
$self->{section_rank}--; |
| 143 |
} # end_section |
} # end_section |
| 144 |
|
|
| 145 |
|
sub start_error_list ($%) { |
| 146 |
|
my ($self, %opt) = @_; |
| 147 |
|
|
| 148 |
|
if (defined $opt{role}) { |
| 149 |
|
if ($opt{role} eq 'parse-errors') { |
| 150 |
|
$opt{id} ||= 'parse-errors-list'; |
| 151 |
|
delete $opt{role}; |
| 152 |
|
} elsif ($opt{role} eq 'structure-errors') { |
| 153 |
|
$opt{id} ||= 'document-errors-list'; |
| 154 |
|
delete $opt{role}; |
| 155 |
|
} |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
$self->start_tag ('dl', %opt); |
| 159 |
|
} # start_error_list |
| 160 |
|
|
| 161 |
|
sub end_error_list ($%) { |
| 162 |
|
my ($self, %opt) = @_; |
| 163 |
|
|
| 164 |
|
if (defined $opt{role}) { |
| 165 |
|
if ($opt{role} eq 'parse-errors') { |
| 166 |
|
delete $opt{role}; |
| 167 |
|
$self->end_tag ('dl'); |
| 168 |
|
## NOTE: For parse error list, the |add_source_to_parse_error_list| |
| 169 |
|
## method is invoked at the end of |generate_source_string_section|, |
| 170 |
|
## since that generation method is invoked after the error list |
| 171 |
|
## is generated. |
| 172 |
|
} elsif ($opt{role} eq 'structure-errors') { |
| 173 |
|
delete $opt{role}; |
| 174 |
|
$self->end_tag ('dl'); |
| 175 |
|
$self->add_source_to_parse_error_list ('document-errors-list'); |
| 176 |
|
} else { |
| 177 |
|
$self->end_tag ('dl'); |
| 178 |
|
} |
| 179 |
|
} else { |
| 180 |
|
$self->end_tag ('dl'); |
| 181 |
|
} |
| 182 |
|
} # end_error_list |
| 183 |
|
|
| 184 |
|
sub add_source_to_parse_error_list ($$) { |
| 185 |
|
my $self = shift; |
| 186 |
|
|
| 187 |
|
$self->script (q[addSourceToParseErrorList ('] . $self->input->id_prefix . |
| 188 |
|
q[', '] . shift . q[')]); |
| 189 |
|
} # add_source_to_parse_error_list |
| 190 |
|
|
| 191 |
sub start_code_block ($) { |
sub start_code_block ($) { |
| 192 |
shift->html ('<pre><code>'); |
shift->html ('<pre><code>'); |
| 193 |
} # start_code_block |
} # start_code_block |