termcol: rename scumm preset to dosbox
[sheet.git] / sample.plp
index 15323a34db2023c3fdf9e32cdd05346d749687a8..adae7bd4c8b6bf505607b33ceefa449297aae3eb 100644 (file)
@@ -1,25 +1,34 @@
 <(common.inc.plp)><:
 
+my $textinc = 'data/unicode-sampler/unicode.txt';
+my $proto = sprintf('http%s://', !!$ENV{HTTPS} && 's');
+my $preview = "$proto$ENV{HTTP_HOST}/sample.png";
+
 Html({
        title => "unicode sampler",
        version => '2.0',
        stylesheet => [qw'light dark mono red'],
+       data => [$textinc],
+       raw => qq(<meta property="og:image" content="$preview" />),
 });
 
-open my $source, '<', 'data/unicode-sampler/unicode.txt'
-       or die "Could not open text: $!\n";
+open my $source, '<', $textinc
+       or Abort("Could not open text at $textinc", 501, $!);
 local $/ = "\n\n";
 
 my $top = readline $source;
-my ($title, $hr, $intro) = split /\n(\H)$1+\n/, $top, 2;
+my ($title, $hr, $intro) = split /\n(\pP)\1+\n/, $top, 2;
 say "<h1>$title</h1>";
+printf '<p>HTML display of <a href="%s">plain text</a>', $textinc;
+say ' intended for monospaced (terminal) output.</p>';
 
 say '<pre>';
 print $intro;
 
 while (my $p = readline $source) {
        EscapeHTML($p);
-       $p =~ s{ \A (\N+:) \n\Z }{<h2>$1</h2>}x;
+       $p =~ s{ \A ((\pL+) \N*:) \n }{<h2 id="\L$2\E">$1</h2>}x;
+       $p =~ s{(?<=^  )([\p{Latin} ]+:)}{<em>$1</em>}gm;
        print $p;
 }