]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/mudela-book.py
release: 1.1.55
[lilypond.git] / scripts / mudela-book.py
index fd535434c8420386560231d05651a0215cd6efa1..eafc978c0e0eee1a1d639555414d39a7adf6659d 100644 (file)
@@ -7,10 +7,6 @@
 #  help-gnu-music@gnu.org
 #
 #  TODO:
-# * Spacing before and after mudela blocks should be fixed. No empy lines
-#   before and after the mudela block should make just little space between
-#   music and text, one or more empy lines should make bigger space, like
-#   between paragraphs.
 # * center option (??)
 # * make mudela-book understand usepackage{geometry}
 # * check that linewidth set in \paper is not wider than actual linewidth?
@@ -67,7 +63,7 @@
 #   - bf: Default fragments have linewidth=-1.0
 #   - Added 'singleline' and 'multiline' options.
 # 0.5.6:
-#   - \mudelafile{} set linewith correct, -1 for .sly and texlinewidth for .fly
+#   - \mudelafile{} set linewidth correct, -1 for .sly and texlinewidth for .fly
 #   - changes to Mudela_output
 #   - changed RE to search for pre/postMudelaExample to make it possible to
 #     comment out a definition.
@@ -89,6 +85,8 @@ fontsize_i2a = {11:'eleven', 13:'thirteen', 16:'sixteen',
                 20:'twenty', 26:'twentysix'}
 fontsize_pt2i = {'11pt':11, '13pt':13, '16pt':16, '20pt':20, '26pt':26}
 
+# perhaps we can do without this?
+
 begin_mudela_re = re.compile ('^ *\\\\begin{mudela}')
 begin_verbatim_re = re.compile ('^ *\\\\begin{verbatim}')
 end_verbatim_re = re.compile ('^ *\\\\end{verbatim}')
@@ -396,21 +394,24 @@ class Tex_output:
     def write_outfile(self):
         file = open(self.output_fn+'.latex', 'w')
         file.write('% Created by mudela-book\n')
+        last_line = None
         for line in self.__lines:
             if type(line)==type([]):
-                if line[0] == 'tex':
-                    #\\def\\interscoreline{}
+                if last_line == '\n':
+                    file.write(r'\vspace{0.5cm}')
+                if line[0] == 'tex':                    
                     file.write('\\preMudelaExample \\input %s \\postMudelaExample\n'\
-                              # TeX applies the prefix of the main source automatically.
                                % (line[1]+'.tex'))
-#                               % (outdir+line[1]+'.tex'))
                 if line[0] == 'eps':
                     ps_dim = ps_dimention(outdir+line[1]+'.eps')
                     file.write('\\noindent\\parbox{%ipt}{\includegraphics{%s}}\n' \
                                % (ps_dim[0], line[1]+'.eps'))
-#                               % (ps_dim[0], outdir+line[1]+'.eps'))
             else:
                 file.write(line)
+            if type(last_line)==type([]):
+                if line=='\n':
+                    file.write(r'\vspace{0.5cm}')
+            last_line = line
         file.close()
 
 # given parameter s="\mudela[some options]{CODE} some text and commands"
@@ -601,6 +602,7 @@ class Main_tex_input(Tex_input):
 
                f = open (full_path, 'r')
                lines =f.readlines ()
+               self.mudela.write ('%% This is a copy of file %s\n' % full_path)
                for x in lines:
                    self.mudela.write (x)
                r = file_ext_re.search(fn)