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;";
51 print MUDELA "castingalgorithm = \\Wordwrap; } }\n";
55 print BOOK "\\end{verbatim}";
58 print BOOK "\\end{minipage}";
61 print BOOK "\\interexample";
66 if ( -f gen_mufile ) {
67 $status = system "diff -q $outdir/book-mudela.ly " . gen_mufile;
72 rename "$outdir/book-mudela.ly", gen_mufile;
76 if ( ! -f gen_texfile) {
77 my_system "lilypond ". gen_mufile;
78 rename gen_texbase, gen_texfile;
82 print BOOK "\\begin{minipage}[c]{.5\\textwidth}\n";
84 print BOOK "\\input " . gen_texfile . "\n";
86 print BOOK "\\end{minipage}";
89 print BOOK "\\postexample%\n";
96 open MUDELA, ">$outdir/book-mudela.ly";
97 print BOOK "\\preexample%\n";
99 print BOOK "\\begin{minipage}[c]{.5\\textwidth}\n";
100 print MUDELA "default_paper = \\paper { \\paper_sixteen ";
101 print MUDELA "linewidth = 7.\\cm;}";
104 print BOOK "\\begin{verbatim}\n";
107 print MUDELA "\\score { \\melodic { ";
109 print MUDELA "default_paper = \\paper { \\paper_sixteen ";
110 print MUDELA "linewidth = 15.\\cm;}";
119 return (/^\\begin{$s}/) ;
125 return (/^\\end{$s}/) ;
127 sub parse_mudela_opts
132 $verbatim_b =1 if ($s =~ /verbatim/ );
133 $fragment_b = 1 if ($s =~ /fragment/ );
134 $center_b = 1 if ($s =~ /center/ );
139 print "usage: convert-mudela [options] [file]
142 --outdir=DIRECTORY write all files in directory DIRECTORY
143 --outname=NAME use NAME as base for the output
150 GetOptions( 'outdir=s', 'outname=s', 'help');
153 $opt_help = 0; # to extinguish typo check. brr, what a language
156 if (defined ($opt_outdir)) {
157 $outdir = $opt_outdir . "/";
162 if (defined ($ARGV[0])) {
167 if (defined ($opt_outname)) {
168 $outname = $opt_outname ;
170 die "Need to have an output name, use --outname" if ( $infile eq "-");
171 $outname = "$infile.tex";
174 my $openout ="$outdir$outname";
175 if ( $infile eq $openout ) {
176 die "The input can't be the output\n";
179 open INFILE, "<$infile";
180 open BOOK, ">$openout";
183 if (end_b "mudela") {
190 $s =~ s/\t/ /g; #shit
195 if (/^\\begin(\[.*\])?{mudela}/ ) {
197 $opts = $1 if ( defined ($1));
199 parse_mudela_opts($opts);