summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeri <deri@chuzzlewit.myzen.co.uk>2024-03-12 14:46:24 +0100
committerAlejandro Colomar <alx@kernel.org>2024-03-12 18:23:31 +0100
commit347f1ebaaf2495196bbb2efe8a74e87cc797d944 (patch)
tree10e023d21197adfe9b33af04bb37d9c5a006e7a2
parent14cad7b461b594e0439b8c02b5004e341c193c53 (diff)
scripts/LinuxManBook/prepare.pl: Support some autogenerated pages from other projects
And remove a warning about an experimental perl feature, by using a while instead of a for loop. Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rwxr-xr-xscripts/LinuxManBook/prepare.pl26
1 files changed, 14 insertions, 12 deletions
diff --git a/scripts/LinuxManBook/prepare.pl b/scripts/LinuxManBook/prepare.pl
index d42941856..735cfcf09 100755
--- a/scripts/LinuxManBook/prepare.pl
+++ b/scripts/LinuxManBook/prepare.pl
@@ -59,7 +59,7 @@ foreach my $al (`grep -E '^\\.so' $dir/man*/*`)
$aliases{$1}=$2;
}
-foreach my ($k,$v) (%aliases)
+while (my ($k,$v)=each %aliases)
{
while (exists($aliases{$v})) {
$v=$aliases{$v};
@@ -98,6 +98,15 @@ sub BuildPage
# If this is an alias, just add it to the outline panel.
+ # if new section add top level bookmark
+
+ if ($sec ne $Section) {
+ print ".nr PDFOUTLINE.FOLDLEVEL 1\n";
+ print ".pdfbookmark 1 $Sections{$sec}\n";
+ print ".nr PDFOUTLINE.FOLDLEVEL 2\n";
+ $Section=$sec;
+ }
+
if (exists($aliases{$bkmark})) {
print ".eo\n.device ps:exec [/Dest /$aliases{$bkmark} /Title ($title) /Level 2 /OUT pdfmark\n.ec\n.fl\n";
return;
@@ -123,7 +132,7 @@ sub BuildPage
s/\\-/-/g if /^\.[BM]R\s+/;
- if (m/^\.BR\s+([-\w\\.]+)\s+\((.+?)\)(.*)/ or m/^\.MR\s+([-\w\\.]+)\s+(\w+)\s+(.*)/) {
+ if (m/^\.BR\s+([-\w\\.]+)\s+\((.+?)\)(.*)/ or m/^\.MR\s+([-\w\\.]+)\s+(\w+)\s+(.*)/ or m/^\\fB([-\w\\.]+)\\fR\((.+?)\)(.*)$/) {
my $bkmark="$1";
my $sec=$2;
my $after=$3;
@@ -135,7 +144,7 @@ sub BuildPage
my $dest=$files{"${bkmark}.$sec"}->[1];
$_=".pdfhref L -D \"$dest\" -A \"$after\" -- \\fI$bkmark\\fP($sec)";
} else {
- $_=".IR ".substr($_,4);
+ $_=".IR $bkmark ($sec)\\c\n$after";
}
}
@@ -161,16 +170,9 @@ sub BuildPage
s/\n\n/\n/g;
}
- if (m/^\.TH\s+([-\w\\.]+)\s+(\w+)/) {
+ s/\\&\././ if m/^.TH /;
- # if new section add top level bookmark
-
- if ($sec ne $Section) {
- print ".nr PDFOUTLINE.FOLDLEVEL 1\n";
- print ".pdfbookmark 1 $Sections{$sec}\n";
- print ".nr PDFOUTLINE.FOLDLEVEL 2\n";
- $Section=$sec;
- }
+ if (m/^\.TH\s+"?([-\w\\.]+)"?\s+"?(\w+)"?/) {
print "$_\n";