sample: html preface and additional (sub)title markup
[sheet.git] / sample.plp
index 7f8b636c83f7d8e5a694ff16ae045632f562b9fe..b4d2c44c963b7534351d500b0a54d43f9b8e52e2 100644 (file)
@@ -1,20 +1,32 @@
 <(common.inc.plp)><:
 
+my $textinc = 'data/unicode-sampler/unicode.txt';
+
 Html({
        title => "unicode sampler",
        version => '2.0',
        stylesheet => [qw'light dark mono red'],
+       data => [$textinc],
 });
 
-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 $title = readline $source;
-my $hr = readline $source;
+my $top = readline $source;
+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) {
-       print EscapeHTML($p);
+       EscapeHTML($p);
+       $p =~ s{ \A ((\pL+) \N*:) \n }{<h2 id="\L$2\E">$1</h2>}x;
+       $p =~ s{(?<=^  )([\p{Latin} ]+:)}{<em>$1</em>}gm;
+       print $p;
 }
+
 say "</pre>\n";