-#!@PERL@ -w
+#!@PERL@ -w
+# -*-Perl-*-
my $mudcount = 0;
my $mudela_b = 0;
-my $outdir = "";
-my $outname = "";
+my $outname = "-";
use Getopt::Long;
sub gen_mufile
{
$mudela_b = 0;
if ($fragment_b) {
- print MUDELA "}\n \\paper { linewidth = -1.0\\cm; } }\n";
+ print MUDELA "}\n \\paper { linewidth = -1.0\\cm; castingalgorithm = \\Wordwrap; } }\n";
$fragment_b =0;
}
if ( $verbatim_b) {
$fragment_b = 1 if ($s =~ /fragment/ );
}
+sub help
+{
+ print "usage: convert-mudela [options] [file]
+options:
+--help
+--outdir=DIRECTORY write all files in directory DIRECTORY
+--outname=NAME use NAME as base for the output
+";
+ exit;
+}
+
sub main
{
- GetOptions( 'outdir=s', 'outname=s');
- $outdir = $opt_outdir;
- $outname = $opt_outname if (defined ($opt_outname) && $opt_outname);
- open INFILE, $ARGV[0];
+ GetOptions( 'outdir=s', 'outname=s', 'help');
+ help if ( $opt_help ) ;
+
+ if (defined ($opt_outdir)) {
+ $outdir = $opt_outdir . "/";
+ } else {
+ $outdir = "";
+ }
+
+ if (defined ($ARGV[0])) {
+ $infile = $ARGV[0] ;
+ } else {
+ $infile = "-";
+ }
+ if (defined ($opt_outname)) {
+ $outname = $opt_outname ;
+ } else {
+ die "Need to have an output name, use --outname" if ( $infile == "-");
+ $outname = "$infile.tex";
+ }
- open BOOK, ">$outdir/$outname";
+ open INFILE, "<$infile";
+ open BOOK, ">$outdir$outname";
while (<INFILE>) {
if ($mudela_b) {
if (end_b "mudela") {
close BOOK;
}
+
main;