]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/mudela-book.py
release: 1.2.5
[lilypond.git] / scripts / mudela-book.py
index 8021e5181800d88377bbddee58db4a980e64d417..e679cae1d839fc059ae71f51a0bb02a4ab90f90e 100644 (file)
@@ -69,7 +69,7 @@ output_dict= {
     }
   >
 \end{mudela}""", 
-               'output-mudela':r"""\begin%s{mudela}
+               'output-mudela':r"""\begin[%s]{mudela}
 %s
 \end{mudela}""",
                'output-verbatim': r"""\begin{verbatim}%s\end{verbatim}""",
@@ -135,7 +135,7 @@ re_dict = {
                 'mudela-file': '@mudelafile(\[[^\\]]+\])?{([^}]+)}',
                 'mudela' : '@mudela(\[.*?\])?{(.*?)}',
                 'mudela-block': r"""(?s)@mudela(\[.*?\])?(.*?)@end mudela""",
-                'interesting-cs': r"""[\\@](node|mudelagraphic)""",
+                'interesting-cs': r"""[\\@](chapter|section)""",
                  'comma-sep' : ', *',           
                 }
        }
@@ -223,27 +223,32 @@ def compose_full_body (body, opts):
 
        # urg: breaks on \include of full score
        # Use nofly option if you want to \include full score.
-       if not 'nofly' in opts and not re.search ('\\\\score', body):
-               opts.append ('fly')
+       if 'nofly'  not in opts and not re.search ('\\\\score', body):
+               opts.append ('fragment')
 
-       if  'fragment' in opts or 'singleline' in opts:
+       if 'fragment' in opts and 'nosingleline' not in opts:
+               opts.append ('singleline')
+
+       if 'singleline' in opts:
                l = -1.0;
        else:
                l = latex_linewidths[cols][paper][latex_size]
 
 
-       if 'fly' in opts:
+       if 'relative' in opts:
+               body = '\\relative c { %s }' % body
+
+       
+       if 'fragment' in opts:
                body = r"""\score { 
-  \notes\relative c {
-    %s
-  }
+  \notes { %s }
   \paper { }  
 }""" % body
 
         opts = uniq (opts)
         optstring = string.join (opts, ' ')
        optstring = re.sub ('\n', ' ', optstring)
-               
+       
        body = r"""
 %% Generated by mudela-book.py; options are %s
 \include "paper%d.ly"
@@ -420,7 +425,8 @@ def find_mudela_shorthands (b):
                str = f.read (-1)
                opts = match.group (1)
                if opts:
-                       opts = re.split (',[ \n\t]*', opts[1:-1])
+                       opts = opts[1:-1]
+                       opts = re.split (',[ \n\t]*', opts)
                else:
                        opts = []
 
@@ -432,8 +438,6 @@ def find_mudela_shorthands (b):
                        opts .append ('nofly')
                        
                str_opts = string.join (opts, ',')
-               if str_opts: str_opts = '[' + str_opts + ']'
-
 
                str = ("%% copied from file `%s'\n" % full_path) + str 
                return get_output ('output-mudela') % (str_opts, str)
@@ -444,7 +448,7 @@ def find_mudela_shorthands (b):
        
 def find_mudela_chunks (str):
        """Find mudela blocks, while watching for verbatim. Returns
-       (STR,MUDS) with \mudelagraphic substituted for the blocks in STR,
+       (STR,MUDS) with  substituted for the blocks in STR,
        and the blocks themselves MUDS"""
   
        chunks = []
@@ -499,7 +503,7 @@ def advance_counters (counter, opts, str):
                                pass
                elif g == 'chapter':
                        (chapter, section, count)  = (chapter + 1, 0, 0)
-               elif g == 'section' or g == 'node':
+               elif g == 'section':
                        (section, count)  = (section + 1, 0)