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 "$outname$mudcount.tex";
43 return "$outdir/" . gen_texbase;
50 print MUDELA "}\n \\paper { linewidth = -1.0\\cm; castingalgorithm = \\Wordwrap; } }\n";
54 print BOOK "\\end{verbatim}\n\\interexample";
59 if ( -f gen_mufile ) {
60 $status = system "diff -q $outdir/book-mudela.ly " . gen_mufile;
65 rename "$outdir/book-mudela.ly", gen_mufile;
69 if ( ! -f gen_texfile) {
70 my_system "lilypond ". gen_mufile;
71 rename gen_texbase, gen_texfile;
73 print BOOK "\\preexample\\input " . gen_texfile . "\n\\postexample\n";
81 open MUDELA, ">$outdir/book-mudela.ly";
83 print BOOK "\\begin{verbatim}\n";
86 print MUDELA "\\score { \\melodic {";
94 return (/^\\begin{$s}/) ;
100 return (/^\\end{$s}/) ;
102 sub parse_mudela_opts
107 $verbatim_b =1 if ($s =~ /verbatim/ );
108 $fragment_b = 1 if ($s =~ /fragment/ );
113 print "usage: convert-mudela [options] [file]
116 --outdir=DIRECTORY write all files in directory DIRECTORY
117 --outname=NAME use NAME as base for the output
124 GetOptions( 'outdir=s', 'outname=s', 'help');
125 help if ( $opt_help ) ;
127 if (defined ($opt_outdir)) {
128 $outdir = $opt_outdir . "/";
133 if (defined ($ARGV[0])) {
138 if (defined ($opt_outname)) {
139 $outname = $opt_outname ;
141 die "Need to have an output name, use --outname" if ( $infile eq "-");
142 $outname = "$infile.tex";
145 my $openout ="$outdir$outname";
146 if ( $infile eq $openout ) {
147 die "The input can't be the output\n";
150 open INFILE, "<$infile";
151 open BOOK, ">$openout";
154 if (end_b "mudela") {
161 $s =~ s/\t/ /g; #shit
166 if (/^\\begin(\[.*\])?{mudela}/ ) {
168 $opts = $1 if ( defined ($1));
170 parse_mudela_opts($opts);