#!/usr/bin/perl
# postconf2html - add HTML paragraphs
# Basic operation:
#
# - Process input as text blocks separated by one or more empty
# (or all whitespace) lines.
#
# - Don't touch blocks that start with `<' in column zero.
#
# The only changes made are:
#
# - Emit "
parametername..." 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;
#getopts("hv");
#die "Usage: $0 [-hv]\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 = "";
do {
$_ =~ s/\s+\n$/\n/;
$block .= $_;
} while(($_ = <>) && /\S/);
# 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\n\n" if ($param);
print "\n\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 "- $param\n($defval)
- \n\n";
}
# Meta block. Emit upper case tags for html2man.
elsif ($block =~ /^%CLASS/) {
print "\n
\n\n" if ($param);
print "\n
\n\n" if ($class);
$param ="";
($junk, $class, $text) = split(/\s+/, $block, 3);
$text =~ s/\s+$//s;
print "\n\n";
$need_dl = 1;
}
# Can't happen.
else {
die "Unrecognized text block:\n$block";
}
}
print "\n\n\n" if ($param);
print "\n\n\n" if ($class);