+
+sub saystatuscol {
+ my ($id) = @_;
+ my $row = $caniuse->{data}->{$id};
+
+ for ($row->{status}) {
+ my $cell = $_ // '-';
+ $cell = sprintf '<a href="%s">%s</a>', $_, $cell for $row->{spec} // ();
+ printf '<td title="%s" class="l %s">%s',
+ $caniuse->{statuses}->{$_}, $CSTATUS{$_} // '', $cell;
+ }
+}
+
+sub saybrowsercols {
+ my ($id, $browser) = @_;
+ my $data = $caniuse->{data}->{$id}->{stats}->{$browser};
+ if (ref $data eq 'ARRAY') {
+ # special case for unsupported
+ my $release = $caniuse->{agents}->{$browser}->{verrelease};
+ $data = {
+ map { $_ => defined $release->{$_} ? 'u' : 'n' } keys %$release
+ };
+ }
+
+ my ($prev, @span);
+ for my $ver (@{ $versions{$browser} }, undef) {
+ my $compare = (
+ !defined $ver ? undef : # last column if nameless
+ ref $data ne 'HASH' ? '' : # unclassified if no support hash
+ $data->{$ver} // $prev # known or inherit from predecessor
+ // (grep { defined } @{$data}{ @{ $versions{$browser} } })[0]
+ ~~ 'n' && 'n' # first known version is unsupported
+ || 'u' # unsure
+ );
+ unless (!defined $prev or $prev ~~ $compare) {
+ my $usage = sum(map { $canihas->{$browser}->{$_} } @span);
+ printf '<td class="%s" colspan="%d" title="%s">%s',
+ join(' ',
+ X => $CSTATS{$prev},
+ !$usage ? ('p0') : ('p',
+ sprintf('p%01d', $usage * ($usagepct - .0001) / 10),
+ sprintf('p%02d', $usage * ($usagepct - .0001)),
+ ),
+ sprintf('pp%02d', $usage / $usagemax),
+ ),
+ scalar @span,
+ sprintf('%.1f%% %s', $usage * $usagepct, join(', ',
+ map { ref $_ eq 'CODE' ? $_->($browser) : $_ }
+ map { $DSTATS{$_} // () }
+ map { split / /, $_ }
+ $prev
+ )),
+ showversions(@span),
+ undef $prev;
+ @span = ();
+ }
+ push @span, $ver;
+ $prev = $compare;
+ }
+}
+
+sub sayusagecol {
+ my ($id) = @_;
+ print '<td>', int featurescore($caniuse->{data}->{$id}->{stats}) * $usagepct;
+}
+
+say '<tbody>';
+for my $id (sort {
+ featurescore($caniuse->{data}->{$b}->{stats})
+ <=> featurescore($caniuse->{data}->{$a}->{stats})
+} keys %{ $caniuse->{data} }) {
+ $caniuse->{data}->{$id}->{stats} or next; # skip metadata [summary]
+ printf '<tr id="%s">', $id;
+ saytitlecol($id);
+ saystatuscol($id);
+ saybrowsercols($id, $_) for @browsers;
+ sayusagecol($id);
+ say '</tr>';
+}
+say '</tbody>';
+say '</table>';