10 # do something, check return status
14 foreach $cmd (@cmds) {
18 $cmd = substr ($cmd, 1);
21 my $ret = ( system ($cmd));
24 print STDERR
"ignoring failed command \`$cmd\' (status $ret)\n";
26 print STDERR
"\nmudela-book: failed on command \`$cmd\' (status $ret)\n";
34 return "$outdir/$outname$mudcount.ly";
39 return "$outdir/$outname$mudcount.tex";
46 print MUDELA
"}\n \\paper { linewidth = -1.0\\cm; castingalgorithm = \\Wordwrap; } }\n";
50 print BOOK
"\\end{verbatim}\n\\interexample";
55 if ( -f gen_mufile
) {
56 $status = system "diff -q $outdir/book-mudela.ly " . gen_mufile
;
61 rename "$outdir/book-mudela.ly", gen_mufile
;
65 if ( ! -f gen_texfile
) {
66 my_system
"lilypond ". gen_mufile
;
67 rename "lelie.tex", gen_texfile
;
69 print BOOK
"\\preexample\\input " . gen_texfile
. "\n\\postexample\n";
77 open MUDELA
, ">$outdir/book-mudela.ly";
79 print BOOK
"\\begin{verbatim}\n";
82 print MUDELA
"\\score { \\melodic {";
90 return (/^\\begin{$s}/) ;
96 return (/^\\end{$s}/) ;
103 $verbatim_b =1 if ($s =~ /verbatim/ );
104 $fragment_b = 1 if ($s =~ /fragment/ );
109 print "usage: convert-mudela [options] [file]
112 --outdir=DIRECTORY write all files in directory DIRECTORY
113 --outname=NAME use NAME as base for the output
120 GetOptions
( 'outdir=s', 'outname=s', 'help');
121 help
if ( $opt_help ) ;
123 if (defined ($opt_outdir)) {
124 $outdir = $opt_outdir . "/";
129 if (defined ($ARGV[0])) {
134 if (defined ($opt_outname)) {
135 $outname = $opt_outname ;
137 die "Need to have an output name, use --outname" if ( $infile eq "-");
138 $outname = "$infile.tex";
141 my $openout ="$outdir$outname";
142 if ( $infile eq $openout ) {
143 die "The input can't be the output\n";
146 open INFILE
, "<$infile";
147 open BOOK
, ">$openout";
150 if (end_b
"mudela") {
157 $s =~ s/\t/ /g; #shit
162 if (/^\\begin(\[.*\])?{mudela}/ ) {
164 $opts = $1 if ( defined ($1));
166 parse_mudela_opts
($opts);