common: drop leading 'v' in version numbers
[sheet.git] / browser.plp
index ad8690f2781e0d4902aae5ac8723befc5e4ae733..782bea8628ddf3128fd58d2927f5fba28856db5b 100644 (file)
@@ -6,7 +6,7 @@ no if $] >= 5.018, warnings => 'experimental::smartmatch';
 
 Html({
        title => 'browser compatibility cheat sheet',
-       version => 'v1.2',
+       version => '1.3',
        description => [
                "Compatibility table of new web features (HTML5, CSS3, SVG, Javascript)",
                "comparing support and usage share for all popular browser versions.",
@@ -22,7 +22,7 @@ Html({
 
 say "<h1>Browser compatibility</h1>\n";
 
-my $caniuse = do 'data/browser/support.inc.pl' or die $! || $@;
+my $caniuse = do 'data/browser/support.inc.pl' or die $@ || $!;
 $_->{verrelease} = {
        # mark last three (future) versions as unreleased, ensure current isn't
        map {
@@ -58,7 +58,9 @@ my %DSTATS = (
        x => sub {
                join(' ',
                        'requires prefix',
-                       (map "-$_-", $caniuse->{agents}->{$_[0]}->{prefix} // ()),
+                       map {"-$_-"}
+                       ($caniuse->{agents}->{$_[0]}->{prefix_exceptions} // {})->{$_[1]}
+                       // $caniuse->{agents}->{$_[0]}->{prefix} // (),
                );
        },
 );
@@ -99,7 +101,7 @@ given ($get{usage} // 'wm') {
                        'identifier must be alphanumeric name or <q>0</q>';
        }
        $canihas = do "data/browser/usage-$_.inc.pl" or do {
-               printf "<p>Browser usage data not found: <em>%s</em>", $! || $@;
+               printf "<p>Browser usage data not found: <em>%s</em>", $@ || $!;
                break;
        };
        $usage = $_;
@@ -270,6 +272,7 @@ sub featurescore {
                        while (my ($browser, $versions) = each %$row) {
                                ref $versions eq 'HASH' or next;
                                while (my ($version, $status) = each %$versions) {
+                                       $status =~ s/\h\#\d+//;
                                        $rank += ($canihas->{$browser}->{$version} || .001) * $PSTATS{$status};
                                }
                        }
@@ -297,6 +300,7 @@ sub featurescore {
 sub formatnotes {
        my @html = @_;
        for (@html) {
+               s/\r\n?/\n/g;  # windows returns
                s/\h* $//gmx;  # trailing whitespace
                s/(?<= [^.\n]) $/./gmx;  # consistently end each line by a period
                Entity($_);
@@ -386,7 +390,7 @@ sub saybrowsercols {
 
                        # prepare version hover details
                        my $title = sprintf('%.1f%% %s', $usage * $usagepct, join(', ',
-                               map { ref $_ eq 'CODE' ? $_->($browser) : $_ }
+                               map { ref $_ eq 'CODE' ? $_->($browser, $span[0]->[0]) : $_ }
                                map { $DSTATS{$_} // () }
                                map { split / /, $_ }
                                $prev