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";
102 print BOOK
"\\begin{verbatim}\n";
105 print MUDELA
"\\score { \\melodic {\\octave c';";
107 print MUDELA
"default_paper = \\paper { \\paper_sixteen ";
108 print MUDELA
"linewidth = 7.\\cm;}";
116 return (/^\\begin{$s}/) ;
122 return (/^\\end{$s}/) ;
124 sub parse_mudela_opts
129 $verbatim_b =1 if ($s =~ /verbatim/ );
130 $fragment_b = 1 if ($s =~ /fragment/ );
131 $center_b = 1 if ($s =~ /center/ );
136 print "usage: convert-mudela [options] [file]
139 --outdir=DIRECTORY write all files in directory DIRECTORY
140 --outname=NAME use NAME as base for the output
147 GetOptions
( 'outdir=s', 'outname=s', 'help');
150 $opt_help = 0; # to extinguish typo check. brr, what a language
153 if (defined ($opt_outdir)) {
154 $outdir = $opt_outdir . "/";
159 if (defined ($ARGV[0])) {
164 if (defined ($opt_outname)) {
165 $outname = $opt_outname ;
167 die "Need to have an output name, use --outname" if ( $infile eq "-");
168 $outname = "$infile.tex";
171 my $openout ="$outdir$outname";
172 if ( $infile eq $openout ) {
173 die "The input can't be the output\n";
176 open INFILE
, "<$infile";
177 open BOOK
, ">$openout";
180 if (end_b
"mudela") {
187 $s =~ s/\t/ /g; #shit
192 if (/^\\begin(\[.*\])?{mudela}/ ) {
194 $opts = $1 if ( defined ($1));
196 parse_mudela_opts
($opts);