Skip to content

Commit 5b5b044

Browse files
committed
roffit: show SH names with upercase first + lowercase
--preserve-case is introduced to be used to preserve the case from the source Closes #25
1 parent 10b524e commit 5b5b044

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

roffit

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Author: Daniel Stenberg <daniel@haxx.se>
1111
# Web: https://daniel.haxx.se/projects/roffit
1212

13-
my $version = "0.12";
13+
my $version = "0.13";
1414

1515
use strict;
1616
#use warnings;
@@ -37,6 +37,7 @@ my @mandirs;
3737
my $mandir;
3838
my $hrefdir=".";
3939
my $filename;
40+
my $leavecase;
4041

4142
while($ARGV[0]) {
4243
if($ARGV[0] eq "--bare") {
@@ -48,6 +49,10 @@ while($ARGV[0]) {
4849
print "roffit $version (https://daniel.haxx.se/projects/roffit/)\n";
4950
exit;
5051
}
52+
elsif($ARGV[0] eq "--preserve-case") {
53+
$leavecase = 1;
54+
exit;
55+
}
5156
elsif($ARGV[0] =~ /^--mandir=(.*)/) {
5257
# check for other HTMLized man pages in these given dirs
5358
# can be specified multiple times
@@ -63,12 +68,14 @@ while($ARGV[0]) {
6368
}
6469
elsif($ARGV[0] =~ /^(--help|-h)/) {
6570
print $debugFH "Usage: roffit [options] [infile] < infile > outfile\n",
66-
"Options:\n",
67-
" --version display roffit version and exit\n",
68-
" --bare do not put in HTML, HEAD, BODY tags\n",
69-
" --mandir=<dir> check for other HTMLized man pages in these dirs\n",
70-
" --hrefdir=<dir> if a manpage is found in the --mandir, this is the\n",
71-
" dir we prefix the HTML file name with in the output\n";
71+
"Options:\n",
72+
" --bare do not put in HTML, HEAD, BODY tags\n",
73+
" --hrefdir=<dir> if a manpage is found in the --mandir, this is the\n",
74+
" dir we prefix the HTML file name with in the output\n",
75+
" --mandir=<dir> check for other HTMLized man pages in these dirs\n",
76+
" --preserve-case leave case of section headers untouched\n",
77+
" --version display roffit version and exit\n";
78+
7279
exit;
7380
}
7481
else {
@@ -384,6 +391,7 @@ sub parsefile {
384391

385392
$rest =~ s/\"//g; # cut off quotes
386393
$rest = do_encode($rest);
394+
$rest = ucfirst(lc($rest)) if(!$leavecase);
387395
$out = "<a name=\"$name\"></a><h2 class=\"nroffsh\">$rest</h2>";
388396
$indentlevel=0;
389397
$within_tp=0;

roffit.1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.\" nroff -man roffit.1
33
.\" Written by Daniel Stenberg
44
.\"
5-
.TH roffit 1 "27 Feb 2004" "roffit 0.6" "roffit Manual"
5+
.TH roffit 1 "October 5 2021" "roffit 0.13" "roffit Manual"
66
.SH NAME
77
roffit \- convert nroff to HTML
88
.SH SYNOPSIS
@@ -32,6 +32,10 @@ section).
3232
.IP \-\-hrefdir=<dir>
3333
Specify a directory to prefix generated href links created with the \-\-mandir
3434
option. This defaults to ".".
35+
.IP \-\-preserve-case
36+
When used, this makes roffit preserve the case in SH (section header) in the
37+
output instead of uppercasing the first letter and doing the rest lowercase.
38+
The case changing was introduced in roffit 0.13.
3539
.SH "CSS CLASSES"
3640
.IP h2.nroffsh
3741
The nroff ".SH" section. These are normally the "headlines" before each sub

0 commit comments

Comments
 (0)