From: Jay Satiro Date: Sun, 16 Feb 2025 07:49:43 +0000 (-0500) Subject: scripts/managen: fix parsing of markdown code sections X-Git-Tag: curl-8_13_0~455 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=28d3c5dced240a541917b3d8a7bef2ee9cd6a48c;p=thirdparty%2Fcurl.git 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 --- diff --git a/scripts/managen b/scripts/managen index 170d1f8bd3..6621b1684c 100755 --- a/scripts/managen +++ b/scripts/managen @@ -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;