mirror of
https://github.com/curl/curl.git
synced 2026-07-28 00:03:09 +03:00
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:
parent
9bcc64c39b
commit
163f0cbc8b
1 changed files with 25 additions and 14 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue