tools: preserve make errors, ignore empty output
[sheet.git] / emoji.plp
index 73271d5892b77084508551966557a008e2d09102..2a546b406efe045351345a9e558852ba7735861a 100644 (file)
--- a/emoji.plp
+++ b/emoji.plp
@@ -2,7 +2,7 @@
 
 Html({
        title => 'emoji cheat sheet',
-       version => 'v1.0',
+       version => '1.0',
        description => [
                "Emoticons overview and Unicode equivalents"
                . " of MSN, Y!M, and Gmail icons.",
@@ -18,33 +18,34 @@ Html({
 <h1>IM emoticons</h1>
 
 <:
-my %ICONURL = (
-       msn   => 'http://messenger.msn.com/Resource/emoticons/%s.gif',
-#      yahoo => 'http://l.yimg.com/us.yimg.com/i/mesg/emoticons6/%s.gif',
-       yahoo => 'http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/%s.gif',
-#      yahoo-web => 'http://l.yimg.com/a/i/us/msg/emoticons/%s.gif',
-       gmail => 'http://mail.google.com/mail/help/images/screenshots/chat/%s.gif',
-);
-
-print "<ul>\n";
+say '<div class="section">';
 
 for my $system (qw'gmail msn yahoo') {
        my @info = do "emoji-$system.inc.pl";
-       printf '<div class="section"><h3>%s</h3>'."\n\n", $system;
-       print '<table><tbody>'."\n";
+       my $meta = shift @info or die $@;
+       ref $meta eq 'HASH' or die "invalid $system definitions";
+       my $title = $meta->{name} // $system;
+       $title = showlink($title, $_) for $meta->{source} || ();
+
+       say sprintf '<div class="section"><h2>%s</h2>', $meta->{name} // $system;
+       say '<table><tbody>';
        for (my $i = 0; $i <= $#info; $i++) {
                my $name = $info[$i];
                unless (ref $info[$i+1] eq 'ARRAY') {
-                       printf '</table><table><tbody>'."\n", $name;
+                       say sprintf '</table><table><tbody>', $name;
                        next;
                }
-               my ($input, $attr, $char, $desc) = @{ $info[++$i] };
-               printf('<tr><th><img src="'.$ICONURL{$system}.'"><td><kbd>%s</kbd><td>%s%s'."\n",
-                       $name, EscapeHTML($input), $desc // $name, $char ? '<td>'.chr($char) : '',
+               my ($input, $flags, $char, $desc) = @{ $info[++$i] };
+               say sprintf('<tr><th><img src="%s" alt="%s"><td><kbd>%s</kbd><td>%s%s',
+                       sprintf($meta->{ $flags =~ /\bext\b/ ? 'iconext' : 'icon' } // '%s', $name),
+                       EscapeHTML($name),
+                       EscapeHTML($input),
+                       $desc // $name,
+                       $char ? '<td>'.chr($char) : '',
                );
        }
-       print "</table></div>\n\n";
+       say "</table></div>\n";
 }
 
-print "</ul><hr>\n\n";
+say "</div><hr>\n";