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/postconffix | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100755 mantools/postconffix (limited to 'mantools/postconffix') diff --git a/mantools/postconffix b/mantools/postconffix new file mode 100755 index 0000000..1c70f36 --- /dev/null +++ b/mantools/postconffix @@ -0,0 +1,72 @@ +#!/usr/bin/perl + +# postconffix - 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: +# +# - Put

..

around text blocks that start in column zero. +# +# - Put
..
around text blocks that start elsewhere. + +#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(<>) { + + # Pass through comments and blank linkes before a text block. + if (/^(#|\s*$)/) { + print; + next; + } + + # 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 =~ /^\n$block\n\n"; + } + + # Pre-formatted block. + elsif ($block =~ /^\s/) { + print "
\n$block
\n\n"; + } + + # Paragraph block. + elsif ($block =~ /^\S/) { + print "

\n$block

\n\n"; + } + + # Can't happen. + else { + die "Unrecognized text block:\n$block"; + } +} -- cgit v1.2.3