]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/lilypond-book.py
* scm/output-tex.scm (comment): idem.
[lilypond.git] / scripts / lilypond-book.py
index cbf018bd50efea07afe9bc6b5ff2bbe4f7a8bbae..1797084fadc926fc128bdec25efa4e6cc91f2c0f 100644 (file)
@@ -103,14 +103,13 @@ global _;_=ly._
 global re;re = ly.re
 
 # lilylib globals
+program_version = '@TOPLEVEL_VERSION@'
 program_name = 'lilypond-book'
 verbose_p = 0
 pseudo_filter_p = 0
 original_dir = os.getcwd ()
-#temp_dir = os.path.join (original_dir,  '%s.dir' % program_name)
-#urg
-temp_dir = '/tmp'
-keep_temp_dir_p = 0
+
+
 preview_resolution = 90
 
 ## FIXME
@@ -126,9 +125,9 @@ option_definitions = [
        (_ ("DIM"),  '', 'default-music-fontsize', _ ("default fontsize for music.  DIM is assumed to be in points")),
        (_ ("DIM"),  '', 'default-lilypond-fontsize', _ ("deprecated, use --default-music-fontsize")),
        (_ ("OPT"), '', 'extra-options', _ ("pass OPT quoted to the lilypond command line")),
-       (_ ("DIM"), '', 'force-music-fontsize', _ ("force fontsize for all inline lilypond. DIM is assumed be to in points")),
+       (_ ("DIM"), '', 'force-music-fontsize', _ ("force fontsize for all inline lilypond. DIM is assumed to be in points")),
        (_ ("DIM"), '', 'force-lilypond-fontsize', _ ("deprecated, use --force-music-fontsize")),
-       ('', 'h', 'help', _ ("this help")),
+       ('', 'h', 'help', _ ("print this help")),
        (_ ("DIR"), 'I', 'include', _ ("include path")),
        ('', 'M', 'dependencies', _ ("write dependencies")),
        (_ ("PREF"), '',  'dep-prefix', _ ("prepend PREF before each -M dependency")),
@@ -139,7 +138,7 @@ option_definitions = [
        (_ ("FILE"), '', 'outdir', _ ("where to place generated files")),
        (_ ('RES'), '', 'preview-resolution',
         _ ("set the resolution of the preview to RES")),
-       ('', 'V', 'verbose', _ ("verbose")),
+       ('', 'V', 'verbose', _ ("be verbose")),
        ('', 'v', 'version', _ ("print version information")),
        ('', 'w', 'warranty', _ ("show warranty and copyright")),
        ]
@@ -150,7 +149,6 @@ option_definitions = [
 
 include_path = [os.getcwd ()]
 
-
 #lilypond_binary = 'valgrind --suppressions=/home/hanwen/usr/src/guile-1.6.supp  --num-callers=10 /home/hanwen/usr/src/lilypond/lily/out/lilypond'
 
 lilypond_binary = os.path.join ('@bindir@', 'lilypond')
@@ -378,7 +376,7 @@ output_dict= {
                ## inline music doesn't.
                ## possibly other center options?
                'output-html': r'''
-%(pageimages)s''',
+%(htmlimages)s''',
                },
 
 
@@ -404,20 +402,20 @@ output_dict= {
                'output-small-verbatim': r'''{\small\begin{verbatim}
 %s\end{verbatim}}
 ''',
-               'output-default-post': "\\def\postLilypondExample{}\n",
-               'output-default-pre': "\\def\preLilypondExample{}\n",
+               'output-default-post': "\\def\postLilyPondExample{}\n",
+               'output-default-pre': "\\def\preLilyPondExample{}\n",
                'usepackage-graphics': '\\usepackage{graphics}\n',
                'output-eps': '\\noindent\\parbox{\\lilypondepswidth{%(fn)s.eps}}{\includegraphics{%(fn)s}}',
                'output-noinline': r'''
 %% generated: %(fn)s.eps
 ''',
-               'output-latex-quoted': r'''{\preLilypondExample
+               'output-latex-quoted': r'''{\preLilyPondExample
 \input %(fn)s.tex
-\postLilypondExample}''',
+\postLilyPondExample}''',
                'output-latex-noquote': r'''{\parindent 0pt
-\preLilypondExample
+\preLilyPondExample
 \input %(fn)s.tex
-\postLilypondExample}''',
+\postLilyPondExample}''',
                'pagebreak': r'\pagebreak',
                },
 
@@ -543,8 +541,8 @@ re_dict = {
                '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",
+               'def-post-re': r"\\def\\postLilyPondExample",
+               'def-pre-re': r"\\def\\preLilyPondExample",
                'usepackage-graphics': r"\usepackage\s*{graphics}",
                'intertext': r',?\s*intertext=\".*?\"',
                'multiline-comment': no_match,
@@ -635,7 +633,7 @@ def error (str):
 
 
 def compose_full_body (body, opts):
-       '''Construct the lilypond code to send to Lilypond.
+       '''Construct the lilypond code to send to LilyPond.
        Add stuff to BODY using OPTS as options.'''
        music_size = default_music_fontsize
        if g_force_music_fontsize:
@@ -1252,7 +1250,7 @@ linking to the menu.
                outname = base + '.ly'
                changed = update_file (content, outname)
 
-               preview = base + ".png"
+               preview = base + ".preview.png"
                preview_page = base + '-page1.png'
                
                if changed or not (os.path.isfile (preview) or
@@ -1260,7 +1258,7 @@ linking to the menu.
                        
                        ly.system ('%s --preview --postscript --verbose %s ' % (ly2dvi_binary, base) ) 
 
-                       ly.make_ps_images (base)
+                       ly.make_ps_images (base + '.ps')
                        ly.system ('gzip -9 - < %s.ps > %s.ps.gz' %  (base, base))
                        
                def size_str (fn):
@@ -1283,7 +1281,7 @@ linking to the menu.
                menu = ''
                page_files = glob.glob ('%s-page*.png' % base)
 
-               for p in string.split (page_files, '\n'):
+               for p in page_files:
                        p = p.strip()
                        if os.path.isfile (p):
                                sz = size_str (p)
@@ -1321,7 +1319,7 @@ use scalable fonts and should look OK at any resolution."""
                
                open (base + '.html','w'). write (separate_menu)
 
-               inline_menu = '<p/><a href="%s.html"><img src="%s"><p/></a>' % (base, original_name, preview)
+               inline_menu = '<p/><a href="%s.html"><img alt="%s" src="%s"></a><p/>' % (base, original_name, preview)
 
                return ('ly2dvi', inline_menu)
 
@@ -1374,6 +1372,9 @@ def compile_all_files (chunks):
                texfiles = string.join (tex)
                cmd = string.join ((lilypond_binary, lilyopts, g_extra_opts,
                                    texfiles))
+
+               ly.lilypond_version_check (lilypond_binary, '@TOPLEVEL_VERSION@')
+               
                ly.system (cmd, ignore_error = 0, progress_p = 1)
 
                #
@@ -1579,7 +1580,7 @@ for opt in options:
        elif o == '--outname' or o == '-o':
                if len (files) > 1:
                        #HACK
-                       sys.stderr.write ("Lilypond-book is confused by --outname on multiple files")
+                       sys.stderr.write ("lilypond-book is confused by --outname on multiple files")
                        sys.exit (1)
                outname = a
        elif o == '--help' or o == '-h':