X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/edb313a940627abab92ecc67a953502043346b94..6b44545759289f85e96c8c6b41501484374afa61:/browser.plp diff --git a/browser.plp b/browser.plp index 9adf10e..13e6b5e 100644 --- a/browser.plp +++ b/browser.plp @@ -39,7 +39,6 @@ given ($get{usage} // 'wm') { :>.

-
<: my $caniuse = do 'browser-support.inc.pl' or die $! || $@; $_->{verrelease} = { @@ -131,11 +130,12 @@ for my $browser (@browsers) { ) for @{ $versions{$browser} }; } print '' x 1; -print "\n"; +say ''; +say '', $header, ''; sub featurescore { # relative amount of support for given feature - state $statspts = { y=>10, 'y x'=>10, a=>5, 'a x'=>5, j=>2, 'p j'=>2, p=>1 }; + state $statspts = { y=>10, 'y x'=>10, a=>5, 'a x'=>5, j=>2, 'p j'=>2, 'p p'=>2, p=>1 }; my $rank = 0; if (my $row = shift) { if ($canihas) { @@ -172,7 +172,7 @@ sub saytitlecol { for ($row->{categories}) { my $cell = $_ ? lc $_->[0] : '-'; - print '', $cell; + printf '%s', join(' + ', @$_), $cell; } print '', map { @@ -181,15 +181,15 @@ sub saytitlecol { sprintf("try { %s; return false } catch(err) { return true }", "document.getElementById('$id').classList.toggle('target')", ), - $_, + Entity($_), ); } $row->{title}; print '
'; s/\.?$/./, print "

$_

" for map { ref $_ ? @$_ : $_ || () } - $row->{description}, $row->{notes}; - printf 'Resources: %s.', join(', ', - map { qq($_->{title}) } @$_ - ) for grep { @$_ } $row->{links} // (); + Entity($row->{description}), formathtml($row->{notes}); # sic + printf 'Resources: %s.', join(', ', map { + sprintf '%s', EscapeHTML($_->{url}), $_->{title} + } @$_) for grep { @$_ } $row->{links} // (); print '
'; } @@ -242,6 +242,7 @@ sub sayusagecol { print '', int featurescore($caniuse->{data}->{$id}->{stats}) / $maxscore * 100; } +say ''; for my $id (sort { featurescore($caniuse->{data}->{$b}->{stats}) <=> featurescore($caniuse->{data}->{$a}->{stats}) @@ -254,8 +255,18 @@ for my $id (sort { sayusagecol($id); say ''; } -print '', $header; -print ''; +say ''; +say ''; + +sub formathtml { + my $ref = defined wantarray ? [@_] : \@_; + for (@$ref) { + s/& (?!\w)/&/gx; + s/< \s/</gx; + s/\n\K\n/
/g; + } + return @$ref; +} sub paddedver { # normalised version number comparable as string (cmp) @@ -272,8 +283,7 @@ sub showversions { return join('‒', @span); } -:>
- +:>
@@ -313,6 +323,6 @@ sub showversions {
- - + +