3 # postconf2man - convert postconf2html to nroff
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.
18 #die "Usage: $0 [-hv]\n" if ($opt_h);
20 #push @ARGV, "/dev/null"; # XXX
24 # Skip blank lines before text block.
27 # Gobble up the next text 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
;
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/≤/<=/g;
78 $block =~ s/≥/>=/g;
80 $block =~ s/&/\&/g;
81 $block =~ s/\s+\n/\n/g;
83 $block =~ s/([a-z][_a-zA-Z0-9-]*)(\([0-9]\))/\\fB\1\\fR\2/g;
85 $wantpp = !($block =~ /^\.(SH|IP)/);