From 347f1ebaaf2495196bbb2efe8a74e87cc797d944 Mon Sep 17 00:00:00 2001 From: Deri Date: Tue, 12 Mar 2024 14:46:24 +0100 Subject: 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 --- scripts/LinuxManBook/prepare.pl | 26 ++++++++++++++------------ 1 file 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"; -- cgit v1.2.3