sample: reference chapter titles by first word
[sheet.git] / sample.plp
index 33d06e909d878f45197a09bd8b139e6d5c5e64f3..be68403b48ce1e3bbfdccc96488d60434c3f1bf5 100644 (file)
@@ -10,7 +10,7 @@ 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;
@@ -22,7 +22,7 @@ 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\Z }{<h2 id="\L$2\E">$1</h2>}x;
        print $p;
 }