cd2nroff: fix backslashes for 4-space indent lines

They were previously only properly escaped for ~~~ quotes. Spotted for
the CURLOPT_HTTPSIG_KEY man page.

Closes #22393
This commit is contained in:
Daniel Stenberg 2026-07-25 22:22:21 +02:00
parent 9bcc64c39b
commit 163f0cbc8b
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -200,6 +200,17 @@ my %knowntls = (
'none' => 1,
);
sub quoted {
my ($d) = @_;
# in verbatim/quoted blocks, make backslashes literal
$d =~ s/\\/\\\\/g;
# lines starting with a period or apostrophe need it escaped
$d =~ s/^([.'])/\\&$1/;
return $d;
}
sub single {
my @seealso;
my @proto;
@ -391,28 +402,27 @@ sub single {
if($quote == 4) {
# remove the indentation
if($d =~ /^ (.*)/) {
push @desc, "$1\n";
$d = quoted($1);
push @desc, "$d\n";
next;
}
else {
# end of quote
$quote = 0;
push @desc, ".fi\n";
# fall-through
}
else {
if(/^~~~/) {
# end of quote
$quote = 0;
push @desc, ".fi\n";
next;
}
}
if(/^~~~/) {
# end of quote
$quote = 0;
push @desc, ".fi\n";
$d = quoted($d);
push @desc, $d;
next;
}
# convert single backslashes to doubles
$d =~ s/\\/\\\\/g;
# lines starting with a period needs it escaped
$d =~ s/^\./\\&./;
push @desc, $d;
next;
}
# remove single line HTML comments
@ -512,7 +522,8 @@ sub single {
$quote = 4;
push @desc, "\n" if($blankline && !$header);
$header = 0;
push @desc, ".nf\n$1\n";
my $d = quoted($1);
push @desc, ".nf\n$d\n";
}
elsif(/^[ \t]*\n/) {
# count and ignore blank lines