diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 12:06:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 12:06:34 +0000 |
commit | 5e61585d76ae77fd5e9e96ebabb57afa4d74880d (patch) | |
tree | 2b467823aaeebc7ef8bc9e3cabe8074eaef1666d /mantools/postconf2html | |
parent | Initial commit. (diff) | |
download | postfix-5e61585d76ae77fd5e9e96ebabb57afa4d74880d.tar.xz postfix-5e61585d76ae77fd5e9e96ebabb57afa4d74880d.zip |
Adding upstream version 3.5.24.upstream/3.5.24upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mantools/postconf2html')
-rwxr-xr-x | mantools/postconf2html | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/mantools/postconf2html b/mantools/postconf2html new file mode 100755 index 0000000..5ad038f --- /dev/null +++ b/mantools/postconf2html @@ -0,0 +1,99 @@ +#!/usr/bin/perl + +# postconf2html - add HTML paragraphs + +# Basic operation: +# +# - Process input as text blocks separated by one or more empty +# (or all whitespace) lines. +# +# - Remove text between <!-- and -->; each may be on a different line. +# +# - Optionally remove <nroffescape> pass-through requests (unless +# the -n option is specified). +# +# - Don't touch blocks that start with `<' in column zero. +# +# The only changes made are: +# +# - Emit "<DT><a name="parametername">parametername</a>...</DT><DD>" at +# the top of each parameter description. +# +# All other non-comment input is flagged as an error. + +use Getopt::Std; + +$opt_h = undef; +$opt_v = undef; +$opt_n = undef; +getopts("hnv"); + +die "Usage: $0 [-nv]\n" if ($opt_h); + +#push @ARGV, "/dev/null"; # XXX + +while(<>) { + + # Skip comments. + next if /^#/; + + # Skip blank lines before text block. + next unless (/\S/); + + # Gobble up the next text block. + $block = ""; + $comment = 0; + do { + $_ =~ s/\s+\n$/\n/; + $block .= $_; + if ($_ =~ /<!--/) + { $comment = 1; } + if ($comment && $_ =~ /-->/) + { $comment = 0; $block =~ s/<!--.*-->//sg; } + } while((($_ = <>) && /\S/) || $comment); + + # Strip nroff escapes. + $block =~ s/<\s*nroffescape[^>]+>//g unless $opt_n; + + # Skip blanks after comment elimination. + if ($block =~ /^\s/) { + $block =~ s/^\s+//s; + next if ($block eq ""); + } + + # Don't touch a text block starting with < in column zero. + if ($block =~ /^</) { + print "$block\n"; + } + + # Meta block. Emit upper case tags for html2man. + elsif ($block =~ /^%PARAM/) { + print "\n</DD>\n\n" if ($param); + print "\n<DL>\n\n" if ($need_dl); + $need_dl = 0; + ($junk, $param, $defval) = split(/\s+/, $block, 3); + $defval =~ s/\s+$//s; + $defval = "empty" if ($defval eq ""); + $defval = "default: $defval" unless ($defval eq "read-only"); + print "<DT><b><a name=\"$param\">$param</a>\n($defval)</b></DT><DD>\n\n"; + } + + # Meta block. Emit upper case tags for html2man. + elsif ($block =~ /^%CLASS/) { + print "\n</DD>\n\n" if ($param); + print "\n</DL>\n\n" if ($class); + $param =""; + ($junk, $class, $text) = split(/\s+/, $block, 3); + $text =~ s/\s+$//s; + print "<H2><a name=\"$class\">$text</a></H2>\n\n"; + $need_dl = 1; + } + + # Can't happen. + else { + die "Unrecognized text block:\n$block"; + } +} + +print "\n</DD>\n\n" if ($param); +print "\n</DL>\n\n" if ($class); |