1 |
wakaba |
1.1 |
package WebHACC::Result; |
2 |
|
|
use strict; |
3 |
|
|
|
4 |
|
|
sub new ($) { |
5 |
wakaba |
1.9 |
return bless { |
6 |
|
|
global_status => 'conforming', |
7 |
|
|
# or, 'should-error', 'non-conforming', 'uncertain' |
8 |
|
|
subdoc_results => [], |
9 |
|
|
}, shift; |
10 |
wakaba |
1.1 |
} # new |
11 |
|
|
|
12 |
wakaba |
1.2 |
sub output ($;$) { |
13 |
|
|
if (@_ > 1) { |
14 |
|
|
if (defined $_[1]) { |
15 |
|
|
$_[0]->{output} = $_[1]; |
16 |
|
|
} else { |
17 |
|
|
delete $_[0]->{output}; |
18 |
|
|
} |
19 |
|
|
} |
20 |
|
|
|
21 |
|
|
return $_[0]->{output}; |
22 |
|
|
} # output |
23 |
|
|
|
24 |
wakaba |
1.9 |
sub parent_result ($;$) { |
25 |
|
|
if (@_ > 1) { |
26 |
|
|
if (defined $_[1]) { |
27 |
|
|
$_[0]->{parent_result} = $_[1]; |
28 |
|
|
} else { |
29 |
|
|
delete $_[0]->{parent_result}; |
30 |
|
|
} |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
return $_[0]->{parent_result}; |
34 |
|
|
} # parent_result |
35 |
|
|
|
36 |
|
|
sub layer_applicable ($$) { |
37 |
|
|
my $self = shift; |
38 |
|
|
my $layer = shift; |
39 |
|
|
$self->{layers}->{$layer}->{applicable} = 1; |
40 |
|
|
} # layer_applicable |
41 |
|
|
|
42 |
|
|
sub layer_uncertain ($$) { |
43 |
|
|
my $self = shift; |
44 |
|
|
my $layer = shift; |
45 |
|
|
$self->{layers}->{$layer}->{uncertain} ||= 1; |
46 |
|
|
$self->{layers}->{$layer}->{applicable} = 1; |
47 |
|
|
$self->{global_status} = 'uncertain' |
48 |
|
|
unless $self->{global_status} eq 'non-conforming'; |
49 |
|
|
} # layer_uncertain |
50 |
|
|
|
51 |
wakaba |
1.2 |
sub add_error ($%) { |
52 |
|
|
my ($self, %opt) = @_; |
53 |
|
|
|
54 |
|
|
my $out = $self->output; |
55 |
wakaba |
1.10 |
$out->has_error (1); |
56 |
wakaba |
1.2 |
|
57 |
|
|
my $error_level = $opt{level}; |
58 |
|
|
if (not defined $error_level) { |
59 |
|
|
$error_level = 'm'; ## NOTE: Unknown - an error of the implementation |
60 |
|
|
} elsif ({ |
61 |
|
|
m => 1, s => 1, w => 1, i => 1, u => 1, |
62 |
|
|
}->{$error_level}) { |
63 |
|
|
# |
64 |
|
|
} else { |
65 |
|
|
$error_level = 'm'; ## NOTE: Unknown - an error of the implementation |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
my $error_layer = $opt{layer}; |
69 |
|
|
if (not defined $error_layer) { |
70 |
|
|
$error_layer = 'syntax'; ## NOTE: Unknown - an error of the implementation |
71 |
|
|
} elsif ({ |
72 |
|
|
transfer => 1, |
73 |
|
|
encode => 1, |
74 |
|
|
charset => 1, |
75 |
|
|
syntax => 1, |
76 |
|
|
structure => 1, |
77 |
|
|
semantics => 1, |
78 |
|
|
}->{$error_layer}) { |
79 |
|
|
# |
80 |
|
|
} else { |
81 |
|
|
$error_layer = 'syntax'; ## NOTE: Unknown - an error of the implementation |
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
my $class = qq[level-$error_level layer-$error_layer]; |
85 |
|
|
|
86 |
wakaba |
1.6 |
## Line & column numbers (prepare values) |
87 |
wakaba |
1.1 |
|
88 |
|
|
my $line; |
89 |
|
|
my $column; |
90 |
|
|
|
91 |
wakaba |
1.2 |
if (defined $opt{node}) { |
92 |
|
|
$line = $opt{node}->get_user_data ('manakai_source_line'); |
93 |
wakaba |
1.1 |
if (defined $line) { |
94 |
wakaba |
1.2 |
$column = $opt{node}->get_user_data ('manakai_source_column'); |
95 |
wakaba |
1.7 |
} elsif ($opt{node}->isa ('Message::IF::Node')) { |
96 |
wakaba |
1.2 |
if ($opt{node}->node_type == $opt{node}->ATTRIBUTE_NODE) { |
97 |
|
|
my $owner = $opt{node}->owner_element; |
98 |
|
|
if ($owner) { |
99 |
|
|
$line = $owner->get_user_data ('manakai_source_line'); |
100 |
|
|
$column = $owner->get_user_data ('manakai_source_column'); |
101 |
|
|
} |
102 |
wakaba |
1.1 |
} else { |
103 |
wakaba |
1.2 |
my $parent = $opt{node}->parent_node; |
104 |
wakaba |
1.1 |
if ($parent) { |
105 |
|
|
$line = $parent->get_user_data ('manakai_source_line'); |
106 |
|
|
$column = $parent->get_user_data ('manakai_source_column'); |
107 |
|
|
} |
108 |
|
|
} |
109 |
|
|
} |
110 |
|
|
} |
111 |
|
|
unless (defined $line) { |
112 |
wakaba |
1.2 |
if (defined $opt{token} and defined $opt{token}->{line}) { |
113 |
|
|
$line = $opt{token}->{line}; |
114 |
|
|
$column = $opt{token}->{column}; |
115 |
|
|
} elsif (defined $opt{line}) { |
116 |
|
|
$line = $opt{line}; |
117 |
|
|
$column = $opt{column}; |
118 |
wakaba |
1.1 |
} |
119 |
|
|
} |
120 |
wakaba |
1.20 |
$line += $opt{line_diff} || 0 if defined $line; |
121 |
|
|
$column += $opt{column_diff} || 0 if defined $column; |
122 |
wakaba |
1.6 |
$line = $line - 1 || 1 |
123 |
|
|
if defined $line and not (defined $column and $column > 0); |
124 |
|
|
|
125 |
|
|
$out->start_tag ('dt', class => $class, |
126 |
|
|
'data-type' => $opt{type}, |
127 |
|
|
'data-level' => $error_level, |
128 |
|
|
'data-layer' => $error_layer, |
129 |
|
|
($line ? ('data-line' => $line) : ()), |
130 |
|
|
($column ? ('data-column' => $column) : ())); |
131 |
|
|
my $has_location; |
132 |
|
|
|
133 |
|
|
## URL |
134 |
|
|
|
135 |
|
|
if (defined $opt{url}) { |
136 |
|
|
$out->url ($opt{url}); |
137 |
|
|
$has_location = 1; |
138 |
|
|
} |
139 |
|
|
|
140 |
|
|
## Line & column numbers (real output) |
141 |
wakaba |
1.1 |
|
142 |
|
|
if (defined $line) { |
143 |
|
|
if (defined $column and $column > 0) { |
144 |
wakaba |
1.6 |
$out->xref ('Line #', text => $line, target => 'line-' . $line); |
145 |
|
|
$out->text (' '); |
146 |
|
|
$out->nl_text ('column #', text => $column); |
147 |
wakaba |
1.1 |
} else { |
148 |
wakaba |
1.6 |
$out->xref ('Line #', text => $line, target => 'line-' . $line); |
149 |
wakaba |
1.1 |
} |
150 |
wakaba |
1.3 |
$has_location = 1; |
151 |
wakaba |
1.1 |
} |
152 |
|
|
|
153 |
wakaba |
1.2 |
## Node path |
154 |
|
|
|
155 |
|
|
if (defined $opt{node}) { |
156 |
|
|
$out->html (' '); |
157 |
|
|
$out->node_link ($opt{node}); |
158 |
wakaba |
1.3 |
$has_location = 1; |
159 |
wakaba |
1.1 |
} |
160 |
|
|
|
161 |
wakaba |
1.2 |
if (defined $opt{index}) { |
162 |
|
|
if ($opt{index_has_link}) { |
163 |
|
|
$out->html (' '); |
164 |
wakaba |
1.6 |
$out->xref ('Index #', text => (0+$opt{index}), |
165 |
wakaba |
1.2 |
target => 'index-' . (0+$opt{index})); |
166 |
wakaba |
1.1 |
} else { |
167 |
wakaba |
1.6 |
$out->html (' '); |
168 |
|
|
$out->nl_text ('Index #', text => (0+$opt{index})); |
169 |
wakaba |
1.1 |
} |
170 |
wakaba |
1.3 |
$has_location = 1; |
171 |
wakaba |
1.1 |
} |
172 |
|
|
|
173 |
wakaba |
1.21 |
if (not defined $opt{valueref} and defined $opt{value}) { |
174 |
|
|
$opt{valueref} = \($opt{value}); |
175 |
|
|
} |
176 |
|
|
|
177 |
|
|
if (defined $opt{valueref}) { |
178 |
wakaba |
1.2 |
$out->html (' '); |
179 |
wakaba |
1.16 |
if (defined $opt{pos_start}) { |
180 |
|
|
$out->start_tag ('code'); |
181 |
wakaba |
1.21 |
$out->text (substr ${$opt{valueref}}, 0, $opt{pos_start}); |
182 |
wakaba |
1.16 |
$out->start_tag ('mark'); |
183 |
wakaba |
1.21 |
$out->text (substr ${$opt{valueref}}, $opt{pos_start}, |
184 |
|
|
$opt{pos_end} - $opt{pos_start}); |
185 |
wakaba |
1.16 |
$out->end_tag ('mark'); |
186 |
wakaba |
1.21 |
$out->text (substr ${$opt{valueref}}, $opt{pos_end}) |
187 |
|
|
if $opt{pos_end} < length ${$opt{valueref}}; |
188 |
wakaba |
1.16 |
$out->end_tag ('code'); |
189 |
|
|
} elsif ($opt{value_mark_end}) { |
190 |
|
|
$out->start_tag ('code'); |
191 |
wakaba |
1.21 |
$out->text (${$opt{valueref}}); |
192 |
wakaba |
1.16 |
$out->start_tag ('mark'); |
193 |
|
|
$out->end_tag ('mark'); |
194 |
|
|
$out->end_tag ('code'); |
195 |
|
|
} elsif (defined $opt{value_mark}) { |
196 |
|
|
$out->start_tag ('code'); |
197 |
wakaba |
1.21 |
for (split /($opt{value_mark})/, ${$opt{valueref}}) { |
198 |
wakaba |
1.16 |
if (/$opt{value_mark}/) { |
199 |
|
|
$out->start_tag ('mark'); |
200 |
|
|
$out->text ($_); |
201 |
|
|
$out->end_tag ('mark'); |
202 |
|
|
} else { |
203 |
|
|
$out->text ($_); |
204 |
|
|
} |
205 |
|
|
} |
206 |
|
|
$out->end_tag ('code'); |
207 |
|
|
} else { |
208 |
wakaba |
1.21 |
$out->code (${$opt{valueref}}); |
209 |
wakaba |
1.16 |
} |
210 |
wakaba |
1.3 |
$has_location = 1; |
211 |
|
|
} |
212 |
|
|
|
213 |
|
|
unless ($has_location) { |
214 |
|
|
if (defined $opt{input}) { |
215 |
|
|
if (defined $opt{input}->{container_node}) { |
216 |
|
|
my $original_input = $out->input; |
217 |
|
|
$out->input ($opt{input}->{parent_input}); |
218 |
|
|
$out->node_link ($opt{input}->{container_node}); |
219 |
|
|
$out->input ($original_input); |
220 |
|
|
$has_location = 1; |
221 |
|
|
} elsif (defined $opt{input}->{request_uri}) { |
222 |
|
|
$out->url ($opt{input}->{request_uri}); |
223 |
|
|
$has_location = 1; |
224 |
wakaba |
1.14 |
} elsif (defined $opt{input}->url) { |
225 |
|
|
$out->url ($opt{input}->url); |
226 |
wakaba |
1.3 |
$has_location = 1; |
227 |
|
|
} |
228 |
|
|
} |
229 |
|
|
|
230 |
|
|
unless ($has_location) { |
231 |
wakaba |
1.10 |
$out->nl_text ('Unknown location'); |
232 |
wakaba |
1.3 |
} |
233 |
wakaba |
1.1 |
} |
234 |
wakaba |
1.2 |
|
235 |
|
|
$out->start_tag ('dd', class => $class); |
236 |
wakaba |
1.4 |
|
237 |
|
|
## Error level |
238 |
wakaba |
1.9 |
$out->nl_text ('Error level ' . $error_level); |
239 |
|
|
$out->text (': '); |
240 |
wakaba |
1.4 |
|
241 |
|
|
## Error message |
242 |
wakaba |
1.11 |
my $error_type_text = $opt{type}; |
243 |
wakaba |
1.13 |
$out->nl_text ($error_type_text, node => $opt{node}, text => $opt{text}, |
244 |
wakaba |
1.21 |
value => ${$opt{valueref} or \''}, char => $opt{char}, |
245 |
wakaba |
1.18 |
octets => $opt{octets}); |
246 |
wakaba |
1.4 |
|
247 |
|
|
## Link to a long description |
248 |
wakaba |
1.2 |
|
249 |
|
|
my $fragment = $opt{type}; |
250 |
|
|
$fragment =~ tr/ /-/; |
251 |
|
|
$fragment = $out->encode_url_component ($fragment); |
252 |
|
|
$out->text (' ['); |
253 |
wakaba |
1.15 |
$out->start_tag ('a', href => '../error-description#' . $fragment, |
254 |
|
|
rel => 'help'); |
255 |
|
|
$out->nl_text ('Description'); |
256 |
|
|
$out->end_tag ('a'); |
257 |
wakaba |
1.2 |
$out->text (']'); |
258 |
|
|
|
259 |
wakaba |
1.9 |
if ($error_level eq 'm') { |
260 |
|
|
$self->{layers}->{$error_layer}->{must}++; |
261 |
|
|
$self->{global_status} = 'non-conforming'; |
262 |
|
|
} elsif ($error_level eq 's') { |
263 |
|
|
$self->{layers}->{$error_layer}->{should}++; |
264 |
|
|
$self->{global_status} = 'should-error' |
265 |
|
|
unless {'non-conforming' => 1, |
266 |
|
|
uncertain => 1}->{$self->{global_status}}; |
267 |
wakaba |
1.2 |
} elsif ($error_level eq 'w') { |
268 |
wakaba |
1.9 |
$self->{layers}->{$error_layer}->{warning}++; |
269 |
wakaba |
1.2 |
} elsif ($error_level eq 'u') { |
270 |
wakaba |
1.9 |
$self->{layers}->{$error_layer}->{uncertain}++; |
271 |
|
|
$self->{global_status} = 'uncertain' |
272 |
|
|
unless $self->{global_status} eq 'non-conforming'; |
273 |
wakaba |
1.2 |
} elsif ($error_level eq 'i') { |
274 |
wakaba |
1.9 |
$self->{layers}->{$error_layer}->{info}++; |
275 |
wakaba |
1.2 |
} |
276 |
|
|
} # add_error |
277 |
|
|
|
278 |
|
|
sub generate_result_section ($) { |
279 |
wakaba |
1.9 |
my $self = shift; |
280 |
|
|
|
281 |
|
|
my $result = $self; |
282 |
wakaba |
1.2 |
|
283 |
|
|
my $out = $result->output; |
284 |
|
|
|
285 |
wakaba |
1.9 |
$out->start_section (role => 'result'); |
286 |
wakaba |
1.2 |
|
287 |
wakaba |
1.9 |
my $para_class = { |
288 |
|
|
'conforming' => 'result-para no-error', |
289 |
|
|
'should-error' => 'result-para should-errors', |
290 |
|
|
'non-conforming' => 'result-para must-errors', |
291 |
|
|
'uncertain' => 'result-para uncertain', |
292 |
|
|
}->{$self->{global_status}}; |
293 |
|
|
$out->start_tag ('p', class => $para_class); |
294 |
|
|
$out->nl_text ('Conformance is ' . $self->{global_status}); |
295 |
|
|
$out->end_tag ('p'); |
296 |
|
|
|
297 |
|
|
$out->html (qq[<table> |
298 |
|
|
<colgroup><col><col><colgroup><col><col><col><col><colgroup><col> |
299 |
|
|
<thead> |
300 |
|
|
<tr><th scope=col colspan=2>]); |
301 |
|
|
for ('Error level m', 'Error level s', 'Error level w', |
302 |
|
|
'Error level i', 'Score') { |
303 |
|
|
$out->start_tag ('th'); |
304 |
|
|
$out->nl_text ($_); |
305 |
|
|
} |
306 |
|
|
|
307 |
|
|
my $maindoc_status = {must => 0, should => 0, warning => 0, info => 0, |
308 |
|
|
uncertain => 0, applicable => 1}; |
309 |
|
|
my $subdocs_status = {must => 0, should => 0, warning => 0, info => 0, |
310 |
|
|
uncertain => 0, applicable => 1}; |
311 |
|
|
my $global_status = {must => 0, should => 0, warning => 0, info => 0, |
312 |
|
|
uncertain => 0, applicable => 1}; |
313 |
|
|
|
314 |
|
|
my $score_unit = 2; |
315 |
|
|
|
316 |
|
|
my @row = ( |
317 |
|
|
sub { |
318 |
|
|
$out->start_tag ('tbody'); |
319 |
|
|
$out->start_tag ('tr'); |
320 |
|
|
$out->start_tag ('th', colspan => 7, scope => 'col'); |
321 |
|
|
$out->nl_text ('Main document'); |
322 |
|
|
}, |
323 |
wakaba |
1.10 |
{label => 'Transfer L.', status => $self->{layers}->{transfer}, |
324 |
wakaba |
1.9 |
target => 'transfer-errors', score_base => 20, |
325 |
|
|
parent_status => $maindoc_status}, |
326 |
wakaba |
1.10 |
{label => 'Encode L.', status => $self->{layers}->{encode}, |
327 |
wakaba |
1.11 |
target => 'parse-errors', score_base => 10, |
328 |
wakaba |
1.9 |
parent_status => $maindoc_status}, |
329 |
wakaba |
1.10 |
{label => 'Char L.', status => $self->{layers}->{charset}, |
330 |
wakaba |
1.19 |
target => 'parse-errors', score_base => 10, |
331 |
wakaba |
1.9 |
parent_status => $maindoc_status}, |
332 |
wakaba |
1.19 |
## TODO: char semantics layer |
333 |
wakaba |
1.10 |
{label => 'Syntax L.', status => $self->{layers}->{syntax}, |
334 |
wakaba |
1.9 |
target => 'parse-errors', score_base => 20, |
335 |
|
|
parent_status => $maindoc_status}, |
336 |
wakaba |
1.10 |
{label => 'Structure L.', status => $self->{layers}->{structure}, |
337 |
wakaba |
1.9 |
target => 'document-errors', score_base => 20, |
338 |
|
|
parent_status => $maindoc_status}, |
339 |
wakaba |
1.10 |
{label => 'Semantics L.', status => $self->{layers}->{semantics}, |
340 |
wakaba |
1.9 |
score_base => 20, |
341 |
|
|
parent_status => $maindoc_status}, |
342 |
|
|
); |
343 |
|
|
|
344 |
|
|
if (@{$self->{subdoc_results}}) { |
345 |
|
|
push @row, {label => 'Subtotal', status => $maindoc_status, |
346 |
|
|
score_base => 100, |
347 |
|
|
parent_status => $global_status, is_total => 1}; |
348 |
|
|
push @row, sub { |
349 |
|
|
$out->start_tag ('tbody'); |
350 |
|
|
$out->start_tag ('tr'); |
351 |
|
|
$out->start_tag ('th', colspan => 7, scope => 'col'); |
352 |
|
|
$out->nl_text ('Subdocuments'); |
353 |
|
|
}; |
354 |
|
|
for (@{$self->{subdoc_results}}) { |
355 |
|
|
push @row, {label => '#' . $_->{input}->full_subdocument_index, |
356 |
|
|
status => $_, |
357 |
|
|
target => $_->{input}->id_prefix . 'result-summary', |
358 |
|
|
score_base => 100, parent_status => $subdocs_status}; |
359 |
|
|
} |
360 |
|
|
push @row, {label => 'Subtotal', status => $subdocs_status, |
361 |
|
|
score_base => 100 * @{$self->{subdoc_results}}, |
362 |
|
|
parent_status => $global_status, is_total => 1}; |
363 |
wakaba |
1.2 |
} else { |
364 |
wakaba |
1.9 |
$global_status = $maindoc_status; |
365 |
wakaba |
1.2 |
} |
366 |
|
|
|
367 |
wakaba |
1.9 |
push @row, sub { |
368 |
|
|
$out->start_tag ('tfoot'); |
369 |
|
|
}; |
370 |
|
|
push @row, {label => 'Total', status => $global_status, |
371 |
|
|
score_base => 100 * (@{$self->{subdoc_results}} + 1), |
372 |
|
|
parent_status => {}, is_total => 1}; |
373 |
|
|
|
374 |
|
|
for my $x (@row) { |
375 |
|
|
if (ref $x eq 'CODE') { |
376 |
|
|
$x->(); |
377 |
|
|
next; |
378 |
|
|
} |
379 |
|
|
|
380 |
|
|
$x->{parent_status}->{$_} += $x->{status}->{$_} |
381 |
|
|
for qw/must should warning info uncertain/; |
382 |
|
|
|
383 |
|
|
my $row_class = $x->{status}->{uncertain} ? 'uncertain' : ''; |
384 |
|
|
$row_class .= ' total' if $x->{is_total}; |
385 |
|
|
$out->start_tag ('tr', class => $row_class); |
386 |
|
|
my $uncertain = $x->{status}->{uncertain} ? '?' : ''; |
387 |
|
|
|
388 |
|
|
$out->start_tag ('td', class => 'subrow') unless $x->{is_total}; |
389 |
|
|
|
390 |
|
|
## Layer name |
391 |
|
|
$out->start_tag ('th', colspan => $x->{is_total} ? 2 : 1, |
392 |
|
|
scope => 'row'); |
393 |
|
|
if (defined $x->{target} and |
394 |
|
|
($x->{status}->{must} or $x->{status}->{should} or |
395 |
|
|
$x->{status}->{warning} or $x->{status}->{info} or |
396 |
|
|
$x->{status}->{uncertain})) { |
397 |
|
|
$out->xref ($x->{label}, target => $x->{target}); |
398 |
|
|
} else { |
399 |
|
|
$out->nl_text ($x->{label}); |
400 |
|
|
} |
401 |
|
|
|
402 |
|
|
## MUST-level errors |
403 |
|
|
$out->start_tag ('td', class => $x->{status}->{must} ? 'must-errors' : ''); |
404 |
|
|
if ($x->{status}->{applicable}) { |
405 |
|
|
$out->text (($x->{status}->{must} or 0) . $uncertain); |
406 |
|
|
} else { |
407 |
|
|
$out->nl_text ('N/A'); |
408 |
|
|
} |
409 |
|
|
|
410 |
|
|
## SHOULD-level errors |
411 |
|
|
$out->start_tag ('td', |
412 |
|
|
class => $x->{status}->{should} ? 'should-errors' : ''); |
413 |
|
|
if ($x->{status}->{applicable}) { |
414 |
|
|
$out->text (($x->{status}->{should} or 0) . $uncertain); |
415 |
|
|
} else { |
416 |
|
|
$out->nl_text ('N/A'); |
417 |
|
|
} |
418 |
|
|
|
419 |
|
|
## Warnings |
420 |
|
|
$out->start_tag ('td', class => $x->{status}->{warning} ? 'warnings' : ''); |
421 |
|
|
if ($x->{status}->{applicable}) { |
422 |
|
|
$out->text (($x->{status}->{warning} or 0) . $uncertain); |
423 |
|
|
} else { |
424 |
|
|
$out->nl_text ('N/A'); |
425 |
|
|
} |
426 |
|
|
|
427 |
|
|
## Informations |
428 |
|
|
$out->start_tag ('td', class => $x->{status}->{info} ? 'infos' : ''); |
429 |
|
|
if ($x->{status}->{applicable}) { |
430 |
|
|
$out->text (($x->{status}->{info} or 0) . $uncertain); |
431 |
|
|
} else { |
432 |
|
|
$out->nl_text ('N/A'); |
433 |
|
|
} |
434 |
|
|
|
435 |
|
|
## Score |
436 |
|
|
$out->start_tag ('td', |
437 |
|
|
class => $x->{status}->{must} ? 'score must-errors' : |
438 |
|
|
$x->{status}->{should} ? 'score should-errors' : |
439 |
|
|
'score'); |
440 |
|
|
|
441 |
|
|
my $max_score = $x->{score_base}; |
442 |
|
|
$max_score -= $x->{status}->{must} * $score_unit; |
443 |
|
|
my $min_score = $max_score; |
444 |
|
|
$min_score -= $x->{status}->{should} * $score_unit; |
445 |
|
|
|
446 |
|
|
$out->start_tag ('strong'); |
447 |
|
|
if ($x->{status}->{uncertain}) { |
448 |
|
|
$out->html ('−∞ '); # negative inifinity |
449 |
|
|
$out->nl_text ('...'); |
450 |
|
|
$out->html ($max_score < 0 ? |
451 |
|
|
' −' . substr ($max_score, 1) : ' ' . $max_score); |
452 |
|
|
} elsif ($min_score != $max_score) { |
453 |
|
|
$out->html ($min_score < 0 ? |
454 |
|
|
'−' . substr ($min_score, 1) . ' ': $min_score . ' '); |
455 |
|
|
$out->nl_text ('...'); |
456 |
|
|
$out->html ($max_score < 0 ? |
457 |
|
|
' −' . substr ($max_score, 1) : ' ' . $max_score); |
458 |
wakaba |
1.2 |
} else { |
459 |
wakaba |
1.9 |
$out->html ($max_score < 0 ? |
460 |
|
|
'−' . substr ($max_score, 1) : $max_score); |
461 |
wakaba |
1.2 |
} |
462 |
wakaba |
1.9 |
$out->end_tag ('strong'); |
463 |
|
|
|
464 |
|
|
$out->text (' / ' . $x->{score_base}); |
465 |
wakaba |
1.2 |
} |
466 |
wakaba |
1.9 |
|
467 |
|
|
$out->end_tag ('table'); |
468 |
wakaba |
1.2 |
|
469 |
wakaba |
1.9 |
my $parent = $self->parent_result; |
470 |
|
|
if ($parent) { |
471 |
|
|
$global_status->{input} = $out->input; |
472 |
|
|
push @{$parent->{subdoc_results}}, $global_status; |
473 |
|
|
} |
474 |
wakaba |
1.2 |
|
475 |
wakaba |
1.9 |
$out->nl_text ('This checker is work in progress.'); |
476 |
wakaba |
1.2 |
$out->end_section; |
477 |
|
|
} # generate_result_section |
478 |
wakaba |
1.1 |
|
479 |
|
|
1; |