From 3fb6960fdf61aeabfbc8a879593074a0bf37fbb3 Mon Sep 17 00:00:00 2001 From: Brad House Date: Tue, 28 Nov 2023 10:54:41 -0500 Subject: [PATCH] add recursion support for links --- roffit | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/roffit b/roffit index f74834a..56c1fda 100755 --- a/roffit +++ b/roffit @@ -26,6 +26,7 @@ my $version = "0.15"; use strict; #use warnings; use HTML::Entities qw(encode_entities); +use File::Basename; sub do_encode($) { return encode_entities(shift, q{<>&"'#}); } @@ -522,7 +523,22 @@ sub parsefile { elsif($keyword =~ /^so$/i) { # This keyword refers to a different man page, named in the # $rest. - # We don't support this + # Recurse and read that instead if possible, otherwise output + # generic message saying where to find the information. + if ($mandir) { + for my $d (@mandirs) { + my $sofilename = $d . "/" . basename($rest); + if (-r $sofilename) { + # Recurse! + close($InFH); + open($InFH, "<".$sofilename); + parsefile($sofilename); + return; + } + } + } + + # If we're here, we didn't recurse. push @out, "See the $rest man page.\n"; } elsif($keyword eq "br") {