browser: flesh out page description
[sheet.git] / browser.plp
index 02e7e0b7a2481d72d08333392883e5e7481177c6..fbbddde372511b65a08f7053fd65e95dedcc4fc1 100644 (file)
@@ -6,8 +6,10 @@ use List::Util qw(sum max first);
 Html({
        title => 'browser compatibility cheat sheet',
        version => 'v1.0',
-       description =>
-               "caniuse.",
+       description => [
+               "Compatibility table of new web features (HTML5, CSS3, SVG, Javascript)",
+               "comparing support and usage share for all popular browser versions.",
+       ],
        keywords => [qw'
                web browser support compatibility usage available feature
                html html5 css css3 svg javascript js dom mobile
@@ -164,16 +166,19 @@ print '<thead>', $header;
 print "\n<tr>";
 print '<td>' x 3;
 for my $browser (@browsers) {
-       printf('<td title="%s"%s>%s',
-               join(' ',
-                       sprintf('%.1f%%', $canihas->{$browser}->{$_} * $usagepct),
-                       "version $_",
-               ),
-               (map {
-                       defined $_ && !$_ && ' class="ex"'
-               } $caniuse->{agents}->{$browser}->{verrelease}->{$_}),
-               showversions($_),
-       ) for @{ $versions{$browser} };
+       for my $_ (@{ $versions{$browser} }) {
+               my $release = $caniuse->{agents}->{$browser}->{verrelease}->{$_};
+               my $future = defined $release;
+               printf('<td title="%s"%s>%s',
+                       join(' ',
+                               sprintf('%.1f%%', $canihas->{$browser}->{$_} * $usagepct),
+                               $future ? 'development' : (),
+                               "version $_",
+                       ),
+                       $future && ' class="ex"',
+                       showversions($_),
+               );
+       }
 }
 print '<td>' x 1;
 say '</thead>';
@@ -233,10 +238,14 @@ sub saytitlecol {
        } $row->{title};
        print '<div class=aside>';
        s/\.?$/./, print "<p>$_</p>" for map { ref $_ ? @$_ : $_ || () }
-               Entity($row->{description}), formathtml($row->{notes});  # sic
+               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>';
 }
 
@@ -307,16 +316,6 @@ for my $id (sort {
 say '</tbody>';
 say '</table>';
 
-sub formathtml {
-       my $ref = defined wantarray ? [@_] : \@_;
-       for (@$ref) {
-               s/& (?!\w)/&amp;/gx;
-               s/< \s/&lt;/gx;
-               s/\n\K\n/<br>/g;
-       }
-       return @$ref;
-}
-
 sub paddedver {
        # normalised version number comparable as string (cmp)
        shift =~ /(?:.*-|^)(\d*)(.*)/;
@@ -326,10 +325,11 @@ sub paddedver {
 
 sub showversions {
        my @span = ($_[0], @_>1 ? $_[-1] : ());
+       s/-.*// for $span[0];
        for (@span) {
                s/^\./0./;
                s/x$/.*/;
-               s/-.*//;
+               s/.*-//;
        }
        return join('‒', @span);
 }