gen.pl: improve example output format

Treat consecutive lines that start with a space to be "examples". They
are output enclosed by .nf and .fi

Updated form.d to use this new fanciness

Closes #8016
This commit is contained in:
Daniel Stenberg 2021-11-15 14:47:46 +01:00
parent 3bf54f90f3
commit d1828b470f
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 16 additions and 10 deletions

View File

@ -40,6 +40,9 @@ correct markup that shows both short and long version.
Text written within `*asterisks*` will get shown using italics. Text within Text written within `*asterisks*` will get shown using italics. Text within
two `**asterisks**` will get shown using bold. two `**asterisks**` will get shown using bold.
Text that is prefixed with a space will be treated like an "example" and will
be output in monospace.
## Header and footer ## Header and footer
`page-header` is the file that will be output before the generated options `page-header` is the file that will be output before the generated options

View File

@ -91,16 +91,12 @@ carriage-returns and trailing spaces are stripped.
Here is an example of a header file contents: Here is an example of a header file contents:
# This file contain two headers. # This file contain two headers.
.br
X-header-1: this is a header X-header-1: this is a header
# The following header is folded. # The following header is folded.
.br
X-header-2: this is X-header-2: this is
.br
another header another header
To support sending multipart mail messages, the syntax is extended as follows: To support sending multipart mail messages, the syntax is extended as follows:
.br .br
- name can be omitted: the equal sign is the first character of the argument, - name can be omitted: the equal sign is the first character of the argument,
@ -115,11 +111,8 @@ inline part in two alternative formats: plain text and HTML. It attaches a
text file: text file:
curl -F '=(;type=multipart/alternative' \\ curl -F '=(;type=multipart/alternative' \\
.br -F '=plain text message' \\
-F '=plain text message' \\ -F '= <body>HTML message</body>;type=text/html' \\
.br
-F '= <body>HTML message</body>;type=text/html' \\
.br
-F '=)' -F '=@textfile.txt' ... smtp://example.com -F '=)' -F '=@textfile.txt' ... smtp://example.com
Data can be encoded for transfer using encoder=. Available encodings are Data can be encoded for transfer using encoder=. Available encodings are
@ -133,7 +126,6 @@ Example: send multipart mail with a quoted-printable text message and a
base64 attached file: base64 attached file:
curl -F '=text message;encoder=quoted-printable' \\ curl -F '=text message;encoder=quoted-printable' \\
.br
-F '=@localfile;encoder=base64' ... smtp://example.com -F '=@localfile;encoder=base64' ... smtp://example.com
See further examples and details in the MANUAL. See further examples and details in the MANUAL.

View File

@ -76,6 +76,7 @@ sub manpageify {
sub printdesc { sub printdesc {
my @desc = @_; my @desc = @_;
my $exam = 0;
for my $d (@desc) { for my $d (@desc) {
if($d =~ /\(Added in ([0-9.]+)\)/i) { if($d =~ /\(Added in ([0-9.]+)\)/i) {
my $ver = $1; my $ver = $1;
@ -89,6 +90,16 @@ sub printdesc {
# *italics* # *italics*
$d =~ s/\*([^ ]*)\*/\\fI$1\\fP/g; $d =~ s/\*([^ ]*)\*/\\fI$1\\fP/g;
} }
if(!$exam && ($d =~ /^ /)) {
# start of example
$exam = 1;
print ".nf\n"; # no-fill
}
elsif($exam && ($d !~ /^ /)) {
# end of example
$exam = 0;
print ".fi\n"; # fill-in
}
# skip lines starting with space (examples) # skip lines starting with space (examples)
if($d =~ /^[^ ]/) { if($d =~ /^[^ ]/) {
for my $k (keys %optlong) { for my $k (keys %optlong) {