+
+sub saytitlecol {
+ my ($id) = @_;
+ my $row = $caniuse->{data}->{$id};
+
+ for ($row->{categories}) {
+ my $cell = $_ ? lc $_->[0] : '-';
+ $cell =~ s/ api$//; # trim unessential fluff in 'js api'
+ printf '<th title="%s">%s', join(' + ', @$_), $cell;
+ }
+
+ print '<td>', map {
+ sprintf('<a href="%s" onclick="%s">%s</a>',
+ "#$id",
+ sprintf("try { %s; return false } catch(err) { return true }",
+ "document.getElementById('$id').classList.toggle('target')",
+ ),
+ Entity($_),
+ );
+ } $row->{title};
+ print '<div class=aside>';
+ s/\.?$/./, print "<p>$_</p>" for map { ref $_ ? @$_ : $_ || () }
+ Entity($row->{description}),
+ map { s/\s*\n/\n<br>/g; $_ } $row->{notes};
+ printf 'Resources: %s.', join(', ', map {
+ sprintf '<a href="%s">%s</a>', EscapeHTML($_->{url}), $_->{title}
+ } @$_) for grep { @$_ } $row->{links} // ();
+ printf '<br>Parent feature: %s.', join(', ', map {
+ sprintf '<a href="%s">%s</a>', EscapeHTML("#$_"), $caniuse->{data}->{$_}->{title}
+ } $_) for $row->{parent} || ();
+ print '</div>';
+}
+
+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};
+
+ my ($prev, @span);
+ for my $ver (@{ $versions{$browser} }, undef) {
+ unless (!defined $prev
+ or ref $data eq 'HASH' && $data->{$prev} ~~ $data->{$ver}) {
+ my $usage = sum(map { $canihas->{$browser}->{$_} } @span);
+ printf '<td class="%s" colspan="%d" title="%s">%s',
+ join(' ',
+ X => $CSTATS{ ref $data eq 'HASH' && $data->{$prev} || 'u' },
+ !$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 / /, $_ }
+ ref $data eq 'HASH' && $data->{$prev} || 'u'
+ )),
+ showversions(@span),
+ undef $prev;
+ @span = ();
+ }
+ push @span, $ver;
+ $prev = $ver;
+ }
+}
+
+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>';