#!/usr/local/bin/perl # # $Id: text2mush,v 1.4 1999/07/11 17:13:05 joi Exp $ # $Log: text2mush,v $ # Revision 1.4 1999/07/11 17:13:05 joi # Added -i, -o, -O parameters. # # Revision 1.3 1997/12/14 17:39:04 joi # Moved guts to a subroutine so that unprettify can call it, too. # # Revision 1.2 1997/12/13 17:09:42 joi # Fixed space globbing. Added break option on %r. # # Revision 1.1 1997/04/26 15:29:20 joi # Initial revision # # # this script converts an arbitrary sequence of text info a # single mush character string. # # usage: text2mush [-m | -M ] [-b] [-i input] [-o output|-O output] # # -p : puts out a nearly-prettify format, with a line break # inserted before each new attribute encountered. Useful # for when you're feeding a collection of help attributes # in a single text file. (Otherwise they'd all run together.) # # -P : does the above but also separates the lines with a single -, # compatible with the unprettify command. # # -b : break lines on %r outputs, good for sucking into pretty # source files while still preserving the formatting. # # -i : input filename. Defaults to stdin. # -o : output filename. Defaults to stdout. # -O : append to filename. require "getopt.pl"; require "./text2mush.pl"; &Getopt("ioO"); if ($opt_o eq "-") { $opt_o = ""; } elsif ($opt_O eq "-") { $opt_o = ""; $opt_O = ""; } if ($opt_i eq "-") { $opt_i = ""; } if ($opt_i) { open(STDIN,"<$opt_i") || die "Unable to open $opt_i for input.\n"; } if ($opt_o) { open(STDOUT,">$opt_o") || die "Unable to open $opt_o for output.\n"; } elsif ($opt_O) { open(STDOUT,">>$opt_O") || die "Unable to open $opt_O for append.\n"; } while () { chop; print "\n" if ($opt_p && /^[&@]/); print "\n-\n" if ($opt_P && /^[&@]/); $line .= &text2mush($_); if ($opt_b) { print $line,"\n"; $line = ""; } } print STDOUT $line,"\n";