Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / mantools / postconf2man
blob29afb04a8aacc9680aef739cf147e799a6694018
1 #!/usr/bin/perl
3 # postconf2man - convert postconf2html to nroff
5 # Basic operation:
7 # - Process input as blocks of text separated by one or more empty
8 # (or all whitespace) lines.
10 # Caution: this depends heavily on the postconf2html output format.
12 #use Getopt::Std;
14 #$opt_h = undef;
15 #$opt_v = undef;
16 #getopts("hv");
18 #die "Usage: $0 [-hv]\n" if ($opt_h);
20 #push @ARGV, "/dev/null"; # XXX
22 while(<>) {
24 # Skip blank lines before text block.
25 next unless (/\S/);
27 # Gobble up the next text block.
28 $block = "";
29 do {
30 $_ =~ s/\s+\n$/\n/;
31 $block .= $_;
32 } while(($_ = <>) && /\S/);
34 # How the %!#$^@ do I get a backslash substituted into a string?
35 # Even \134 comes out as \e. What brain damage is this?
36 #$block =~ s/\n\./\n\\\&./g;
37 $block =~ s/\n\./\n\134\&./g;
38 if ($block =~ /<H2>/) {
39 $block =~ s/<H2><a[^>]+>([^<]+)<\/a><\/H2>/\n.SH \1\n/g;
40 $block =~ tr/a-z/A-Z/;
42 $block =~ s/<DT><b><a[^>]+>([^<]+)<\/a>\n(.*)<\/b><\/DT><DD>/\n.SH \1 \2\n/g;
43 $block =~ s/<[Aa] [Hh][Rr][Ee][Ff]="[^"]+">//g;
44 $block =~ s/<[Aa] [Nn][Aa][Mm][Ee]="[^"]+">//g;
45 $block =~ s/<\/[Aa]>//g;
46 $block =~ s/<\/DD>/\n/g;
47 $block =~ s/<DL>/\n/g;
48 $block =~ s/<\/DL>/\n/g;
49 $block =~ s/\\/\\e/g;
50 $block =~ s/<b>/\\fB/g;
51 $block =~ s/<i>/\\fI/g;
52 $block =~ s/<\/b>/\\fR/g;
53 $block =~ s/<\/i>/\\fR/g;
54 $block =~ s/^(<p(re)?>)/.PP\n\1/ if ($wantpp);
55 $block =~ s/<p> */\n/g;
56 $block =~ s/ *<\/p>/\n/g;
57 $block =~ s/<pre>/\n.nf\n.na\n.ft C\n/g;
58 $block =~ s/<\/pre>/\n.fi\n.ad\n.ft R\n/g;
59 $block =~ s/<dl[^>]*>/\n/g;
60 $block =~ s/<ul>/\n/g;
61 #$block =~ s/<\/dl>/\n.PP\n/g;
62 #$block =~ s/<\/ul>/\n.PP\n/g;
63 $block =~ s/<\/dl>/\n/g;
64 $block =~ s/<\/ul>/\n/g;
65 $block =~ s/<dd>\s*/\n/g;
66 $block =~ s/<\/dd>/\n/g;
67 $block =~ s/<li>\s*/\n.IP \\(bu\n/g;
68 $block =~ s/<dt>\s*/\n.IP "/g;
69 $block =~ s/\s*<\/dt>/"/g;
70 $block =~ s/<tt>\s*//g;
71 $block =~ s/\s*<\/tt>//g;
72 $block =~ s/<blockquote>/\n.sp\n.in +4\n/g;
73 $block =~ s/<\/blockquote>/\n.in -4\n/g;
74 $block =~ s/\n<br>\s*/\n.br\n/g;
75 $block =~ s/<br>\s*/\n.br\n/g;
76 $block =~ s/&le;/<=/g;
77 $block =~ s/&lt;/</g;
78 $block =~ s/&ge;/>=/g;
79 $block =~ s/&gt;/>/g;
80 $block =~ s/&amp;/\&/g;
81 $block =~ s/\s+\n/\n/g;
82 $block =~ s/^\n//g;
83 $block =~ s/([a-z][_a-zA-Z0-9-]*)(\([0-9]\))/\\fB\1\\fR\2/g;
84 print $block;
85 $wantpp = !($block =~ /^\.(SH|IP)/);