sample: html preface and additional (sub)title markup
[sheet.git] / sample.plp
index 33d06e909d878f45197a09bd8b139e6d5c5e64f3..b4d2c44c963b7534351d500b0a54d43f9b8e52e2 100644 (file)
@@ -10,19 +10,22 @@ Html({
 });
 
 open my $source, '<', $textinc
-       or die "Could not open text at $textinc: $!\n";
+       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;
 }