scripts/managen: fix parsing of markdown code sections
- Terminate a code section before parsing a heading line.
Prior to this change when a code line (eg " code") was followed
by a heading line (eg "## heading") the code section in the output
was terminated after converting the header instead of before. That led
to some weird formatting outputs depending on the nroff or roffit etc.
With this change:
.nf
curl \--expand\-url https.//example.com/{{url:trim}}
.fi
.IP json
Without this change:
.nf
curl \--expand\-url https.//example.com/{{url:trim}}
.IP json
.fi
Closes https://github.com/curl/curl/pull/16345
This commit is contained in:
parent
760bbb2110
commit
28d3c5dced
@ -302,7 +302,30 @@ sub render {
|
||||
# skip leading blank lines
|
||||
next;
|
||||
}
|
||||
|
||||
$start = 1;
|
||||
|
||||
if(/^[ \t]*\n/) {
|
||||
# count and ignore blank lines
|
||||
$blankline++;
|
||||
next;
|
||||
}
|
||||
elsif($d =~ /^ (.*)/) {
|
||||
my $word = $1;
|
||||
if(!$quote && $manpage) {
|
||||
push @desc, "\n" if($blankline);
|
||||
push @desc, ".nf\n";
|
||||
$blankline = 0;
|
||||
}
|
||||
$quote = 1;
|
||||
$d = "$word\n";
|
||||
}
|
||||
elsif($quote) {
|
||||
# end of quote
|
||||
push @desc, ".fi\n" if($manpage);
|
||||
$quote = 0;
|
||||
}
|
||||
|
||||
if(/^# (.*)/) {
|
||||
$header = 1;
|
||||
if($top != 1) {
|
||||
@ -366,26 +389,6 @@ sub render {
|
||||
print STDERR "$f:$line:1:ERROR: $cmd detected, use ##-style\n";
|
||||
return 3;
|
||||
}
|
||||
elsif(/^[ \t]*\n/) {
|
||||
# count and ignore blank lines
|
||||
$blankline++;
|
||||
next;
|
||||
}
|
||||
elsif($d =~ /^ (.*)/) {
|
||||
my $word = $1;
|
||||
if(!$quote && $manpage) {
|
||||
push @desc, "\n" if($blankline);
|
||||
push @desc, ".nf\n";
|
||||
$blankline = 0;
|
||||
}
|
||||
$quote = 1;
|
||||
$d = "$word\n";
|
||||
}
|
||||
elsif($quote && ($d !~ /^ (.*)/)) {
|
||||
# end of quote
|
||||
push @desc, ".fi\n" if($manpage);
|
||||
$quote = 0;
|
||||
}
|
||||
|
||||
$d =~ s/`%DATE`/$date/g;
|
||||
$d =~ s/`%VERSION`/$version/g;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user