sc: lotv patch v5.0.13 (2024-03-26)
[sheet.git] / sample.plp
1 <(common.inc.plp)><:
2
3 my $textinc = 'sample.txt';
4
5 Html({
6         title => "unicode sampler",
7         version => '2.1',
8         data => [$textinc],
9         image => 'sample.png',
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 say <<".";
20 <p>HTML display of <a href="/$textinc">plain text</a>
21 intended for monospaced (terminal) output.
22 Compare an expected rendering of the <a href="/sample.png">overview</a>.
23 </p>
24 .
25
26 say '<pre>';
27 print $intro;
28
29 while (my $p = readline $source) {
30         EscapeHTML($p);
31         $p =~ s{ \A ((\pL+) \N*:) \n }{<h2 id="\L$2\E">$1</h2>}x;
32         if ($2 eq 'Unicode') {
33                 # table without proper direction control
34                 $p =~ s/^(?= )/\x{202d}/gm; # ltr override every line
35         }
36         $p =~ s{(?<=^  )([\p{Latin} ]+:)}{<em>$1</em>}gm;
37         print $p;
38 }
39
40 say "</pre>\n";