]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/lilypond-book.py
* scripts/lilypond-book.py: Fix typo gs-load-font -> gs-load-fonts
[lilypond.git] / scripts / lilypond-book.py
index 7861c524a568b6ef30b0497bbd6cdad1e4e17ff7..60a5b204db1b24c3fe32d32b32d4b350400b1884 100644 (file)
@@ -47,6 +47,8 @@ for d in ['@lilypond_datadir@',
 
 # dynamic relocation, for GUB binaries.
 bindir = os.path.abspath (os.path.split (sys.argv[0])[0])
+
+os.environ['PATH'] = bindir + ':' + os.environ['PATH']
 for p in ['share', 'lib']:
     datadir = os.path.abspath (bindir + '/../%s/lilypond/current/python/' % p)
     sys.path.insert (0, datadir)
@@ -132,6 +134,7 @@ def get_option_parser ():
     p.add_option ('-f', '--format',
                   help=_('''use output format FORMAT (texi [default], texi-html, latex, html)'''),
                   action='store')
+    
     p.add_option ("-I", '--include', help=_('add DIR to include path'),
                   metavar="DIR",
                   action='append', dest='include_path',
@@ -535,7 +538,6 @@ output = {
     LATEX: {
         OUTPUT: r'''{%%
 \parindent 0pt%%
-\catcode`\@=12%%
 \ifx\preLilyPondExample \undefined%%
  \relax%%
 \else%%
@@ -827,7 +829,9 @@ class Lilypond_snippet (Snippet):
         self.do_options (os, self.type)
 
     def ly (self):
-        return self.substring ('code')
+        contents = self.substring ('code')
+        return ('\\sourcefileline %d\n%s'
+                % (self.line_number - 1, contents))
 
     def full_ly (self):
         s = self.ly ()
@@ -841,7 +845,7 @@ class Lilypond_snippet (Snippet):
         options = split_options (option_string)
 
         for i in options:
-            if string.find (i, '=') > 0:
+            if '=' in i:
                 (key, value) = re.split ('\s*=\s*', i)
                 self.option_dict[key] = value
             else:
@@ -1206,8 +1210,8 @@ class Lilypond_file_snippet (Lilypond_snippet):
         ## strip version string to make automated regtest comparisons
         ## across versions easier.
         contents = re.sub (r'\\version *"[^"]*"', '', contents)
-        
-        return ('\\sourcefilename \"%s\"\n%s'
+
+        return ('\\sourcefilename \"%s\"\n\\sourcefileline 0\n%s'
                 % (name, contents))
 
 snippet_type_to_class = {
@@ -1362,8 +1366,8 @@ def process_snippets (cmd, ly_snippets, texstr_snippets, png_snippets):
     status = 0
     def my_system (cmd):
         status = ly.system (cmd,
-                  be_verbose=global_options.verbose, 
-                  progress_p=1)
+                            be_verbose=global_options.verbose, 
+                            progress_p=1)
 
     if global_options.format in (HTML, TEXINFO):
         cmd += ' --formats=png '
@@ -1378,7 +1382,11 @@ def process_snippets (cmd, ly_snippets, texstr_snippets, png_snippets):
             my_system ('latex %s.texstr' % l)
 
     if ly_names:
-        my_system (string.join ([cmd, 'snippet-map.ly'] + ly_names))
+        open ('snippet-names', 'w').write ('\n'.join (['snippet-map.ly']
+                                                      + ly_names))
+        
+        my_system (string.join ([cmd, 'snippet-names']))
+
 
 LATEX_INSPECTION_DOCUMENT = r'''
 \nonstopmode
@@ -1476,11 +1484,9 @@ def write_file_map (lys, name):
 #(ly:add-file-name-alist '(
 """)
     for ly in lys:
-        snippet_map.write ('("%s.ly" . "%s:%d (%s.ly)")\n'
+        snippet_map.write ('("%s.ly" . "%s")\n'
                  % (ly.basename (),
-                   name,
-                   ly.line_number,
-                   ly.basename ()))
+                   name))
 
     snippet_map.write ('))\n')
 
@@ -1704,15 +1710,24 @@ def main ():
                                       + ' --formats=%s --backend eps ' % formats)
 
     if global_options.process_cmd:
-        global_options.process_cmd += string.join ([(' -I %s' % commands.mkarg (p))
+        global_options.process_cmd += string.join ([(' -I %s' % ly.mkarg (p))
                               for p in global_options.include_path])
 
+    if global_options.format in (TEXINFO, LATEX):
+        ## prevent PDF from being switched on by default.
+        global_options.process_cmd += ' --formats=eps '
+        
     if (global_options.format in (TEXINFO, LATEX)
         and global_options.create_pdf):
-        global_options.process_cmd += "--pdf  -deps-font-include -dgs-font-load "
+        global_options.process_cmd += "--pdf  -dinclude-eps-fonts -dgs-load-fonts "
 
+        
+    
     if global_options.verbose:
         global_options.process_cmd += " --verbose "
+
+    global_options.process_cmd += " -dread-file-list -dpad-eps-boxes "
+
     identify ()
 
     try: