From b5896ba9f6047e7031e2bdee0622d543e11a6734 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 6 May 2024 03:46:30 +0200 Subject: Adding upstream version 3.4.23. Signed-off-by: Daniel Baumann --- mantools/postconf2man | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 mantools/postconf2man (limited to 'mantools/postconf2man') diff --git a/mantools/postconf2man b/mantools/postconf2man new file mode 100755 index 0000000..c9aff6d --- /dev/null +++ b/mantools/postconf2man @@ -0,0 +1,94 @@ +#!/usr/bin/perl + +# postconf2man - convert postconf2html to nroff + +# Basic operation: +# +# - Process input as blocks of text separated by one or more empty +# (or all whitespace) lines. +# +# - Process pass-through requests for things that this +# script cannot do automatically. +# +# Caution: this depends heavily on the postconf2html output format. + +#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 blank lines before text block. + next unless (/\S/); + + # Gobble up the next text block. + $block = ""; + do { + $_ =~ s/\s+\n$/\n/; + $block .= $_; + } while(($_ = <>) && /\S/); + + # How the %!#$^@ do I get a backslash substituted into a string? + # Even \134 comes out as \e. What brain damage is this? + #$block =~ s/\n\./\n\\\&./g; + $block =~ s/\n\./\n\134\&./g; + if ($block =~ /

/) { + $block =~ s/

]+>([^<]+)<\/a><\/H2>/\n.SH \1\n/g; + $block =~ tr/a-z/A-Z/; + } + $block =~ s/
]+>([^<]+)<\/a>\n(.*)<\/b><\/DT>
/\n.SH \1 \2\n/g; + $block =~ s/<[Aa][ \n]+[Hh][Rr][Ee][Ff]="[^"]+">//g; + $block =~ s/<[Aa][ \n]+[Nn][Aa][Mm][Ee]="[^"]+">//g; + $block =~ s/<\/[Aa]>//g; + $block =~ s/<\/DD>/\n/g; + $block =~ s/
/\n/g; + $block =~ s/<\/DL>/\n/g; + $block =~ s/\\/\\e/g; + $block =~ s//\\fB/g; + $block =~ s//\\fI/g; + $block =~ s/<\/b>/\\fR/g; + $block =~ s/<\/i>/\\fR/g; + $block =~ s/^()/.PP\n\1/ if ($wantpp); + $block =~ s/

*/\n/g; + $block =~ s/ *<\/p>/\n/g; + $block =~ s/

/\n.nf\n.na\n.ft C\n/g;
+    $block =~ s/<\/pre>/\n.fi\n.ad\n.ft R\n/g;
+    $block =~ s/]*>/\n/g;
+    $block =~ s/
    /\n/g; + #$block =~ s/<\/dl>/\n.PP\n/g; + #$block =~ s/<\/ul>/\n.PP\n/g; + $block =~ s/<\/dl>/\n.br\n/g; + $block =~ s/<\/ul>/\n.br\n/g; + $block =~ s/
    \s*/\n/g; + $block =~ s/<\/dd>/\n.br\n/g; + $block =~ s/
  • \s*/\n.IP \\(bu\n/g; + $block =~ s/
    \s*/\n.IP "/g; + $block =~ s/\s*<\/dt>/"/g; + $block =~ s/\s*//g; + $block =~ s/\s*<\/tt>//g; + # Munge "-" here, so that we don't screw up ".in -4". + $block =~ s/-/\\-/g; + $block =~ s/
    /\n.sp\n.in +4\n/g; + $block =~ s/<\/blockquote>/\n.in -4\n/g; + $block =~ s/\n
    \s*/\n.br\n/g; + $block =~ s/
    \s*/\n.br\n/g; + $block =~ s/≤/<=/g; + $block =~ s/</=/g; + $block =~ s/>/>/g; + $block =~ s/&/\&/g; + $block =~ s/–/-/g; + $block =~ s/—/-/g; + $block =~ s/\s+\n/\n/g; + $block =~ s/^\n//g; + $block =~ s/\s*<\s*nroffescape\s+([^ >]+)\s*>\s*/\n\1\n/g; + $block =~ s/([a-z][_a-zA-Z0-9-]*)(\([0-9]\))/\\fB\1\\fR\2/g; + print $block; + $wantpp = !($block =~ /^\.(SH|IP)/); +} -- cgit v1.2.3