]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/lilypond-book.py
release: 1.5.18
[lilypond.git] / scripts / lilypond-book.py
index b6d3ee6a26226895c813ac526552604c97538756..fd5386915babe6e225f9a6ba3e524e45c487bac7 100644 (file)
@@ -188,11 +188,13 @@ class LatexPaper:
                elif name[-5:] == 'paper':
                        self.m_papersize = name
                else:
-                       self._set_dimen('m_geo_'+name, value)
+                               pass 
+                       # what is _set_dimen ?? /MB
+                               #self._set_dimen('m_geo_'+name, value)
        def __setattr__(self, name, value):
                if type(value) == type("") and \
                   dimension_conversion_dict.has_key (value[-2:]):
-                       f = dimension_conversion_dict[dim]
+                       f = dimension_conversion_dict[value[-2:]]
                        self.__dict__[name] = f(float(value[:-2]))
                else:
                        self.__dict__[name] = value
@@ -365,7 +367,7 @@ output_dict= {
                'output-default-pre': "\\def\preLilypondExample{}\n",
                'usepackage-graphics': '\\usepackage{graphics}\n',
                'output-eps': '\\noindent\\parbox{\\lilypondepswidth{%(fn)s.eps}}{\includegraphics{%(fn)s.eps}}',
-               'output-tex': '\\preLilypondExample \\input %(fn)s.tex \\postLilypondExample\n',
+               'output-tex': '{\\preLilypondExample \\input %(fn)s.tex \\postLilypondExample\n}',
                'pagebreak': r'\pagebreak',
                },
        'texi' : {'output-lilypond': """@lilypond[%s]
@@ -401,7 +403,9 @@ output_dict= {
 @end tex
 @html
 <p>
-<img src=%(fn)s.png>
+<a href="%(fn)s.png">
+<img border=0 src="%(fn)s.png" alt="[picture of music]">
+</a>
 @end html
 """,
                }
@@ -416,15 +420,15 @@ def output_verbatim (body):
 re_dict = {
        'latex': {'input': r'(?m)^[^%\n]*?(?P<match>\\mbinput{?([^}\t \n}]*))',
                  'include': r'(?m)^[^%\n]*?(?P<match>\\mbinclude{(?P<filename>[^}]+)})',
-                 'option-sep' : ', *',
+                 'option-sep' : ',\s*',
                  'header': r"\\documentclass\s*(\[.*?\])?",
                  'geometry': r"^(?m)[^%\n]*?\\usepackage\s*(\[(?P<options>.*)\])?\s*{geometry}",
                  'preamble-end': r'(?P<code>\\begin{document})',
                  'verbatim': r"(?s)(?P<code>\\begin{verbatim}.*?\\end{verbatim})",
                  'verb': r"(?P<code>\\verb(?P<del>.).*?(?P=del))",
-                 'lilypond-file': r'(?m)^[^%\n]*?(?P<match>\\lilypondfile(\[(?P<options>.*?)\])?\{(?P<filename>.+)})',
-                 'lilypond' : r'(?m)^[^%\n]*?(?P<match>\\lilypond(\[(?P<options>.*?)\])?{(?P<code>.*?)})',
-                 'lilypond-block': r"(?sm)^[^%\n]*?(?P<match>\\begin(\[(?P<options>.*?)\])?{lilypond}(?P<code>.*?)\\end{lilypond})",
+                 'lilypond-file': r'(?m)^[^%\n]*?(?P<match>\\lilypondfile\s*(\[(?P<options>.*?)\])?\s*\{(?P<filename>.+)})',
+                 'lilypond' : r'(?m)^[^%\n]*?(?P<match>\\lilypond\s*(\[(?P<options>.*?)\])?\s*{(?P<code>.*?)})',
+                 'lilypond-block': r"(?sm)^[^%\n]*?(?P<match>\\begin\s*(\[(?P<options>.*?)\])?\s*{lilypond}(?P<code>.*?)\\end{lilypond})",
                  'def-post-re': r"\\def\\postLilypondExample",
                  'def-pre-re': r"\\def\\preLilypondExample",             
                  'usepackage-graphics': r"\usepackage{graphics}",
@@ -447,7 +451,7 @@ re_dict = {
                 'lilypond-file': '(?m)^(?!@c)(?P<match>@lilypondfile(\[(?P<options>.*?)\])?{(?P<filename>[^}]+)})',
                 'lilypond' : '(?m)^(?!@c)(?P<match>@lilypond(\[(?P<options>.*?)\])?{(?P<code>.*?)})',
                 'lilypond-block': r"""(?m)^(?!@c)(?P<match>(?s)(?P<match>@lilypond(\[(?P<options>.*?)\])?\s(?P<code>.*?)@end lilypond\s))""",
-                 'option-sep' : ', *',
+                 'option-sep' : ',\s*',
                  'intertext': r',?\s*intertext=\".*?\"',
                  'multiline-comment': r"(?sm)^\s*(?!@c\s+)(?P<code>@ignore\s.*?@end ignore)\s",
                  'singleline-comment': r"(?m)^.*?(?P<match>(?P<code>@c.*$\n+))",
@@ -562,10 +566,12 @@ def compose_full_body (body, opts):
        optstring = re.sub ('\n', ' ', optstring)
        body = r"""
 %% Generated automatically by: lilypond-book.py
-%% options are %s  %%ughUGH not original options
+%% options are %s  
 \include "paper%d.ly"
 \paper  { linewidth = %f \pt } 
 """ % (optstring, music_size, l) + body
+
+       # ughUGH not original options
        return body
 
 def parse_options_string(s):
@@ -984,9 +990,13 @@ def compile_all_files (chunks):
                if do_deps:
                        depfiles=map (lambda x: re.sub ('(.*)\.ly', '\\1.dep', x), tex)
                        for i in depfiles:
-                               text=open (i).read ()
+                               f =open (i)
+                               text=f.read ()
+                               f.close ()
                                text=re.sub ('\n([^:\n]*):', '\n' + foutn + ':', text)
-                               open (i, 'w').write (text)
+                               f = open (i, 'w')
+                               f.write (text)
+                               f.close ()
 
        for e in eps:
                system(r"tex '\nonstopmode \input %s'" % e)