-#!@PERL@ -w
+#!@PERL@ -w
+# -*-Perl-*-
my $mudcount = 0;
my $mudela_b = 0;
-my $outdir = "";
-my $outname = "";
+my $outname = "-";
+my $outdir;
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 main
+sub help
{
- GetOptions( 'outdir=s', 'outname=s');
- $outdir = $opt_outdir;
- $outname = $opt_outname if (defined ($opt_outname) && $opt_outname);
- open INFILE, $ARGV[0];
+ 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;
+}
- open BOOK, ">$outdir/$outname";
+sub main
+{
+ 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 eq "-");
+ $outname = "$infile.tex";
+ }
+
+ my $openout ="$outdir$outname";
+ if ( $infile eq $openout ) {
+ die "The input can't be the output\n";
+ }
+
+ open INFILE, "<$infile";
+ open BOOK, ">$openout";
while (<INFILE>) {
if ($mudela_b) {
if (end_b "mudela") {
close BOOK;
}
+
main;