sample: html preface and additional (sub)title markup
[sheet.git] / sample.plp
1 <(common.inc.plp)><:
2
3 my $textinc = 'data/unicode-sampler/unicode.txt';
4
5 Html({
6         title => "unicode sampler",
7         version => '2.0',
8         stylesheet => [qw'light dark mono red'],
9         data => [$textinc],
10 });
11
12 open my $source, '<', $textinc
13         or Abort("Could not open text at $textinc", 501, $!);
14 local $/ = "\n\n";
15
16 my $top = readline $source;
17 my ($title, $hr, $intro) = split /\n(\pP)\1+\n/, $top, 2;
18 say "<h1>$title</h1>";
19 printf '<p>HTML display of <a href="%s">plain text</a>', $textinc;
20 say ' intended for monospaced (terminal) output.</p>';
21
22 say '<pre>';
23 print $intro;
24
25 while (my $p = readline $source) {
26         EscapeHTML($p);
27         $p =~ s{ \A ((\pL+) \N*:) \n }{<h2 id="\L$2\E">$1</h2>}x;
28         $p =~ s{(?<=^  )([\p{Latin} ]+:)}{<em>$1</em>}gm;
29         print $p;
30 }
31
32 say "</pre>\n";