Skip to content

Commit b5a92a9

Browse files
committed
roffit: add --man option for better external linking
This new option accepts two directories. The first is where (prefix) to look for an existing man page soruce file. If that exists, it uses the second prefix to prepend to the genrated HTML file name when creating a link to it. Closes #51
1 parent a565a8f commit b5a92a9

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

roffit

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#
2222
# Web: https://daniel.haxx.se/projects/roffit
2323

24-
my $version = "0.17";
24+
my $version = "0.18";
2525

2626
use strict;
2727
#use warnings;
@@ -50,6 +50,7 @@ my $mandir;
5050
my $hrefdir=".";
5151
my $filename;
5252
my $leavecase;
53+
my %manhref;
5354

5455
while($ARGV[0]) {
5556
if($ARGV[0] eq "--bare") {
@@ -65,6 +66,14 @@ while($ARGV[0]) {
6566
$leavecase = 1;
6667
exit;
6768
}
69+
elsif($ARGV[0] =~ /^--man=([^=]*)=(.*)/) {
70+
# check for other man pages in the given dir, and if so, link to it
71+
# using the second string. can be specified multiple times
72+
push @mandirs, $1;
73+
$manhref{$1} = $2;
74+
$mandir = 1; # option used
75+
shift @ARGV;
76+
}
6877
elsif($ARGV[0] =~ /^--mandir=(.*)/) {
6978
# check for other HTMLized man pages in these given dirs
7079
# can be specified multiple times
@@ -84,6 +93,8 @@ while($ARGV[0]) {
8493
" --bare do not put in HTML, HEAD, BODY tags\n",
8594
" --hrefdir=<dir> if a manpage is found in the --mandir, this is the\n",
8695
" dir we prefix the HTML file name with in the output\n",
96+
" --man=<dir>=<href> if a manpage is found in DIR then link to it using\n",
97+
" HREF\n",
8798
" --mandir=<dir> check for other HTMLized man pages in these dirs\n",
8899
" --preserve-case leave case of section headers untouched\n",
89100
" --version display roffit version and exit\n";
@@ -238,7 +249,11 @@ sub linkfile {
238249
my $file = "$d/$symbol.$section";
239250

240251
if(-r $file) {
241-
my $html = "$hrefdir/$symbol.html";
252+
my $href = $hrefdir;
253+
if($manhref{$d}) {
254+
$href = $manhref{$d};
255+
}
256+
my $html = "$href/$symbol.html";
242257
# there is such a HTML file present, produce a
243258
# link to it!
244259
$link = "<a Class=\"$style\" href=\"$html\">$symbol</a>";

0 commit comments

Comments
 (0)