keyboard/altgr: fix missing char info from array definitions
[sheet.git] / browser.plp
index e6491cba039951ae034ade42a20dbad82d045e3b..fe96312f6d74afcab57c1598be1e6177a8006689 100644 (file)
@@ -1,10 +1,9 @@
 <(common.inc.plp)><:
 use List::Util qw(sum max first);
 <(common.inc.plp)><:
 use List::Util qw(sum max first);
-no if $] >= 5.018, warnings => 'experimental::smartmatch';
 
 Html({
        title => 'browser compatibility cheat sheet',
 
 Html({
        title => 'browser compatibility cheat sheet',
-       version => '1.5',
+       version => '1.6',
        description => [
                "Compatibility table of new web features (HTML5, CSS3, SVG, Javascript)",
                "comparing support and usage share for all popular browser versions.",
        description => [
                "Compatibility table of new web features (HTML5, CSS3, SVG, Javascript)",
                "comparing support and usage share for all popular browser versions.",
@@ -14,13 +13,12 @@ Html({
                html html5 css css3 svg javascript js dom mobile
                ie internet explorer firefox chrome safari webkit opera
        '],
                html html5 css css3 svg javascript js dom mobile
                ie internet explorer firefox chrome safari webkit opera
        '],
-       stylesheet => [qw'circus dark mono red light'],
        data => ['data/browser/support.inc.pl'],
 });
 
 say "<h1>Browser compatibility</h1>\n";
 
        data => ['data/browser/support.inc.pl'],
 });
 
 say "<h1>Browser compatibility</h1>\n";
 
-my $caniuse = do 'data/browser/support.inc.pl' or die $@ || $!;
+my $caniuse = Data('data/browser/support');
 
 my %CSTATS = (
        'n'   => 'l1',
 
 my %CSTATS = (
        'n'   => 'l1',
@@ -73,10 +71,7 @@ my %CSTATUS = (
 );
 my %versions;
 while (my ($browser, $row) = each %{ $caniuse->{agents} }) {
 );
 my %versions;
 while (my ($browser, $row) = each %{ $caniuse->{agents} }) {
-       $versions{$browser} = [
-               sort { paddedver($a) cmp paddedver($b) } grep { defined }
-               @{ $row->{versions} }
-       ];
+       $versions{$browser} = [@{ $row->{versions} }];
 }
 
 my $ref = showlink('Can I use', 'https://caniuse.com/');
 }
 
 my $ref = showlink('Can I use', 'https://caniuse.com/');
@@ -87,19 +82,19 @@ say '<p id="intro">Alternate rendition of '.$ref;
 
 my ($canihas, $usage);
 my $minusage = $get{threshold} // 1;
 
 my ($canihas, $usage);
 my $minusage = $get{threshold} // 1;
-given ($get{usage} // 'wm') {
-       when (!$_) {
-               # none
-       }
-       when (!m{ \A [a-z]\w+ (?:/\d[\d-]*\d)? \z }x) {
+for ($get{usage} // 'wm') {
+       $_ or next;  # none
+       unless (m{ \A [a-z]\w+ (?:/\d[\d-]*\d)? \z }x) {
                Alert([
                        'Invalid browser usage data request',
                        'Identifier must be alphanumeric name or <q>0</q>.',
                ]);
                Alert([
                        'Invalid browser usage data request',
                        'Identifier must be alphanumeric name or <q>0</q>.',
                ]);
+               next;
        }
        }
-       $canihas = do "data/browser/usage-$_.inc.pl" or do {
-               Alert('Browser usage data not found', $@ || $!);
-               break;
+
+       $canihas = eval { Data("data/browser/usage-$_") } or do {
+               Alert('Browser usage data not found', ref $@ ? @{$@} : $@);
+               next;
        };
        $usage = $_;
        my $ref = $canihas->{-title} || 'unknown';
        };
        $usage = $_;
        my $ref = $canihas->{-title} || 'unknown';
@@ -311,6 +306,7 @@ sub formatnotes {
                s/(?<= [^.\n]) $/./gmx;  # consistently end each line by a period
                Entity($_);
                s{  ` ([^`]*)  ` }{<code>$1</code>}gx;
                s/(?<= [^.\n]) $/./gmx;  # consistently end each line by a period
                Entity($_);
                s{  ` ([^`]*)  ` }{<code>$1</code>}gx;
+               s{ \(\K (?: \Qhttps://caniuse.com\E )? (?: /? \#feat= | / ) }{#}gx;
                s{ \[ ([^]]*) \] \( ([^)]*) \) }{<a href="$2">$1</a>}gx;
        }
        return @html;
                s{ \[ ([^]]*) \] \( ([^)]*) \) }{<a href="$2">$1</a>}gx;
        }
        return @html;
@@ -469,7 +465,7 @@ sub paddedver {
        # normalised version number comparable as string (cmp)
        $_[0] =~ m/(?:.*-|^)(\d*)(.*)/;
        # matched (major)(.minor) of last value in range (a-B)
        # normalised version number comparable as string (cmp)
        $_[0] =~ m/(?:.*-|^)(\d*)(.*)/;
        # matched (major)(.minor) of last value in range (a-B)
-       return sprintf('%02d', length $1 ? $1 : 99) . $2;
+       return sprintf('%03d', length $1 ? $1 : 999) . $2;
 }
 
 sub showversions {
 }
 
 sub showversions {