style: reuse key command styles for continents
[sheet.git] / unicode.plp
index 25f89de638afb27cdbe212c52b7cea65eb9e5d63..349ec78d9bb89a667826c48d39d2ab2ef0a78c62 100644 (file)
@@ -1,34 +1,22 @@
-<:
-use utf8;
-use strict;
-use warnings;
-no  warnings 'qw';  # that's not a comment, it's a NUMBER SIGN
-use open IO => ':utf8';
-
-our $VERSION = '1.0';
-
-$header{content_type} = 'text/html; charset=utf-8';
+<(common.inc.plp)><:
+
+Html({
+       title => 'unicode glyph cheat sheet',
+       version => 'v1.0',
+       description => [
+               "Common Unicode characters with digraph or code point, layed out for quick location.",
+               "Includes general signs, arrows, drawing characters, and IPA letters.",
+       ],
+       keywords => [qw'
+               unicode glyph char character reference common ipa sign mark table digraph
+       '],
+       stylesheet => [qw'light dark red'],
+});
 
-:><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<html>
-
-<head>
-<title>digraph cheat sheet</title>
-<meta http-equiv="content-type" content="utf-8">
-<link rel="stylesheet" type="text/css" media="all" href="/base.css"><:
-       my %styles = map {$_ => $_} qw(dark circus mono red terse);
-       our $style = exists $get{style} && $styles{$get{style}} || 'light';
-       printf(qq{\n<link rel="%s" type="text/css" media="all" href="%s" title="%s">},
-               $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_
-       ) for keys %styles;
 :>
-</head>
-
-<body id="unicode">
-<h1>Common uncommon Unicode</h1>
+<h1>Common Unicode</h1>
 
-<p>i^k in <a href="/">Vim</a>.
+<p>i^k in <a href="/vi">Vim</a>.
 Also see the <a href="/digraphs">complete digraphs table</a>.</p>
 
 <div class="diinfo">
@@ -36,15 +24,7 @@ Also see the <a href="/digraphs">complete digraphs table</a>.</p>
 <:
 my $diinfo = do 'digraphs.inc.pl';
 my %di = map { $diinfo->{$_}->[0] => $_ } grep { ref $diinfo->{$_} }
-       keys %$diinfo;
-
-sub quote {
-       local $_ = shift;
-       s/"/&quot;/g;
-       s/</&lt;/g;
-       s/>/&gt;/g;
-       return $_;
-}
+       sort { length $a <=> length $b } keys %$diinfo;
 
 sub glyph_table {
        my ($digraphs) = @_;
@@ -81,8 +61,7 @@ sub glyph_table {
                        next;
                }
 
-               my $code = join '', map { $di{ord $_} || '' } split //, $cell;
-               my $name = $diinfo->{$code}->[1];
+               my ($code, $name);
 
                # determine display class
                my @class;
@@ -94,11 +73,17 @@ sub glyph_table {
                        $cell = '';
                }
                else {
+                       push @class, 'X';
+
                        if ($cell =~ s/^-//) {
                                push @class, 'di-rare'; # discouraged
                        }
 
-                       if ($code) {
+                       $code = join '', map { $di{ord $_} || '' } split //, $cell;
+                       $name = $diinfo->{$code}->[1];
+                       length $code == 2 or undef $code;
+
+                       if (defined $code) {
                                push @class, 'di-d'; # digraph
                                push @class, 'di-prop' # unofficial
                                        if $diinfo->{$code}->[2] =~ /\bXz\b/;
@@ -117,8 +102,8 @@ sub glyph_table {
                        defined $name  ? qq{ title="$name"}  : '',
                        @class ? sprintf(' class="%s"', join ' ', @class) : '',
                        $colspan > 1 && qq{ colspan="$colspan"},
-                       $cell eq '' ? '&nbsp;' : quote($cell),
-                       $code ne '' ? sprintf(' <small class="digraph">%s</small>', quote($code))
+                       $cell eq '' ? '&nbsp;' : EscapeHTML($cell),
+                       defined $code ? sprintf(' <small class="digraph">%s</small>', EscapeHTML($code))
                                : length($cell) == 1 && $cell !~ /[a-z]/
                                        ? sprintf(' <small class="%s">%04X</small>', 'value', ord $cell)
                                        : '',
@@ -133,7 +118,7 @@ sub glyph_table {
 
 sub print_glyph_tables {
        while (@_) {
-               printf "<div><h2>%s</h2>\n\n", shift;
+               printf '<div class="section"><h2>%s</h2>'."\n\n", shift;
                while (ref $_[0] and $_ = shift) {
                        print glyph_table($_);
                }
@@ -141,20 +126,40 @@ sub print_glyph_tables {
        }
 }
 
+our $verbose = exists $get{v};
+
 print_glyph_tables(
        'Popular',
        [qw{. « » . ‹ › . ‘ ’ . “ ” . „ ‚ . ‟ ‛}],
        [qw{. † ‡ • . § ¶ # . © ® ™ . ° ′ ″ . − × ÷ . ± ² √}],
-       [qw{. å ä ö ü ß . Å æ ø ű ſ}],
+       [qw{. ⚋ ⚊ . ⚐ ⚑ . ☺ ☹ . ✓ ✗ . ✔ ✘ . ◄ ► }],
+       [qw{. å ä ö ü ß . ā æ ø ű ſ}],
        [qw{. ¿ ç ñ é ê è}],
+       [qw{. α β}], [qw{. א}],
+
+       'Signs',
+       [qw{. ¤ ¢ ₥ € £ ₨ $ ¥ . ₫ ₭ ₦ ₱ ₧ ₮ ₩ ₪}],
+       [qw{. ♠ ♡ ♢ ♣ . ♤ ♥ ♦ ♧}],
+       [qw{. ☉ ☿ ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇}],  # solar
+       [qw{. ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓}],  # zodiac
 
        'Arrows',
        [qw{. ↖ ↑ ↗ ↔ . ← - → ↕ . ↙ ↓ ↘ -}],
        [qw{. ⇖ ⇑ ⇗ ⇔ . ⇐ - ⇒ ⇕ . ⇙ ⇓ ⇘ -}],
+       [qw{. ⬁ ⇧ ⬀ ⬄ . ⇦ - ⇨ ⇳ . ⬃ ⇩ ⬂ -}],
+       [qw{. ⬉ ⬆ ⬈ ⬌ . ⬅ - ➡ ⬍ . ⬋ ⬇ ⬊ -}],
+       [qw{. ◩ ⬒ ⬔   . ◧ □ ◨   . ⬕ ⬓ ◪  }],
        [qw{. ◤ ▲ ◥   . ◀ ◆ ▶   . ◣ ▼ ◢  }],
        [qw{. ◸ △ ◹   . ◁ ◇ ▷   . ◺ ▽ ◿  }],
+$verbose ? (
+       [qw{.    .  -  .    }],
+       [qw{.    .  -  .    }],
+) : (),
 
        'Line drawing',
+       [qw{. ╔ ╦ ╗ ═ . ╠ ╬ ╣ ║ . ╚ ╩ ╝ - }],
+       [qw{. ╒ ╤ ╕ . ╞ ╪ ╡ . ╘ ╧ ╛ }],
+       [qw{. ╓ ╥ ╖ . ╟ ╫ ╢ . ╙ ╨ ╜ }],
        [qw{. ┌ ┬ ┐ . ├ ┼ ┤ . └ ┴ ┘}],
        [qw{. ┏ ┳ ┓ . ┣ ╋ ┫ . ┗ ┻ ┛}],
        [qw{. ┍ ┯ ┑ . ┝ ┿ ┥ . ┕ ┷ ┙}],
@@ -166,22 +171,13 @@ print_glyph_tables(
                . ╹ ┃ ╏ ┇ ┋ ╻ ╽
        }],
        [qw{. ╱ ╳ ╲ }],
-       [qw{. ╔ ╦ ╗ ═ . ╠ ╬ ╣ ║ . ╚ ╩ ╝ - }],
-       [qw{. ╒ ╤ ╕ . ╞ ╪ ╡ . ╘ ╧ ╛ }],
-       [qw{. ╓ ╥ ╖ . ╟ ╫ ╢ . ╙ ╨ ╜ }],
 
        'Blocks',
-       [qw{. �� ▀ ▝ . ▌ █ ▐ . ▖ ▄ ▗ }],
+       [qw{. �� ▣ ■ . ▤ ▦ ▥ . ▧ ▩ ▨}],
        [qw{. ░ . ▒ . ▓ }],
+       [qw{. ▘ ▀ ▝ . ▌ █ ▐ . ▖ ▄ ▗ }],
        [qw{. ▛ ▚ ▟ . ▙ ▞ ▜ }],
        [qw{. ▁ ▂ ▃ ▄ ▅ ▆ ▇ ▔ . ▏ ▎ ▍ ▌ ▋ ▊ ▉ ▕ }],
-       [qw{. □ ▣ ■ . ▤ ▦ ▥ . ▧ ▩ ▨}],
-
-       'Signs',
-       [qw{. ¤ ¢ ₥ € £ ₨ $ ¥ . ₫ ₭ ₦ ₱ ₧ ₮ ₩ ₪}],
-       [qw{. ♠ ♡ ♢ ♣ . ♤ ♥ ♦ ♧}],
-       [qw{. ☉ ☿ ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇}],  # solar
-       [qw{. ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓}],  # zodiac
 
        'IPA',
        [qw{
@@ -219,14 +215,7 @@ print_glyph_tables(
                .>Open       a ɶ  - -  ɑ ɒ
        }],
 
-       'Alphabetics',
-       [qw{
-               .>Latin    a ī ı ę ô ɳ ŋ ṡ š đ ð Ʒ
-               .>Cyrillic а і й э ё н њ ш щ ч ь Я
-               .>Greek    α ί ϊ η ϋ π ψ σ ς θ ξ Ω
-               .>Hebrew   א ײ י ע ו נ ן ס ש ט צ ץ
-       }],
-
+$verbose ? (
        'Japanese',
        [qw{
                  - A  I  U  E  O  _
@@ -271,6 +260,7 @@ print_glyph_tables(
                .>P パ ピ プ ペ ポ
                .>V ヷ ヸ ヴ ヹ ヺ
        }],
+) : (),
 );
 
 :></div>
@@ -285,16 +275,3 @@ print_glyph_tables(
        </table>
 </div>
 
-<p class="footer">
-       <a href="http://sheet.shiar.nl/" rel="home">sheet.shiar.nl</a>/unicode
-       <a href="git://dev.shiar.nl/sheet" rel="vcs-git" title="Git repository"><:= "v$VERSION" :></a>
-       created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
-       <a title="Licensed under the GNU Affero General Public License, version 3" rel="copyright"
-          href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a> •
-       last update <:
-               use Time::Format qw(time_format);
-               print time_format('yyyy-mm-dd', (stat $ENV{SCRIPT_FILENAME})[9]);
-       :>
-</p>
-
-</html>