X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/bfdd522492dbe05861569104e131fd8c1d3cad61..918a888d397a962465dfa834dbd0907ef4b63d4b:/browser.plp diff --git a/browser.plp b/browser.plp index 02e7e0b..6c06a2e 100644 --- a/browser.plp +++ b/browser.plp @@ -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 @@ -86,8 +88,9 @@ given ($get{usage} // 'wm') { break; }; $usage = $_; - my $ref = $canihas->{-source} || 'unknown'; - $ref = sprintf '%s', $_, $ref for $canihas->{-url} || (); + my $ref = $canihas->{-title} || 'unknown'; + $ref = sprintf '%s', $_, $ref + for $canihas->{-site} || $canihas->{-source} || (); $ref .= " $_" for $canihas->{-date} || (); print "\nwith $ref browser usage statistics"; } @@ -164,16 +167,19 @@ print '', $header; print "\n"; print '' x 3; for my $browser (@browsers) { - printf('%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('%s', + join(' ', + sprintf('%.1f%%', $canihas->{$browser}->{$_} * $usagepct), + $future ? 'development' : (), + "version $_", + ), + $future && ' class="ex"', + showversions($_), + ); + } } print '' x 1; say ''; @@ -233,10 +239,14 @@ sub saytitlecol { } $row->{title}; print '
'; s/\.?$/./, print "

$_

" for map { ref $_ ? @$_ : $_ || () } - Entity($row->{description}), formathtml($row->{notes}); # sic + Entity($row->{description}), + map { s/\s*\n/\n
/g; $_ } $row->{notes}; printf 'Resources: %s.', join(', ', map { sprintf '%s', EscapeHTML($_->{url}), $_->{title} } @$_) for grep { @$_ } $row->{links} // (); + printf '
Parent feature: %s.', join(', ', map { + sprintf '%s', EscapeHTML("#$_"), $caniuse->{data}->{$_}->{title} + } $_) for $row->{parent} || (); print '
'; } @@ -307,16 +317,6 @@ for my $id (sort { 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) shift =~ /(?:.*-|^)(\d*)(.*)/; @@ -326,10 +326,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); }