]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/lilypond-book.py
* stepmake/aclocal.m4: Store computed version in variable.
[lilypond.git] / scripts / lilypond-book.py
index b93518628bf7b95b547696524328df968eebaa67..0d7659714c039837e40a78a5d7818f4ee21dc04e 100644 (file)
@@ -219,12 +219,12 @@ output = {
   <a href="%(base)s.ly">''',
        OUTPUT: r'''
     <img align="center" valign="center"
-         border="0" src="%(picture)s" alt="[picture of music]">''',
+         border="0" src="%(image)s" alt="[image of music]">''',
        PRINTFILENAME:'<p><tt><a href="%(base)s.ly">%(filename)s</a></tt></p>',
        VERBATIM: r'''<pre>
 %(verb)s</pre>''',
        },
-       
+
        LATEX : {
        AFTER: '',
        BEFORE: '',
@@ -242,19 +242,20 @@ output = {
 %(verb)s\end{verbatim}
 ''',
        },
-       
-       TEXINFO :       {
+
+       TEXINFO : {
        AFTER: '',
        BEFORE: '',
+       OUTPUT: r'''
+       @image{%(base)s,,,[image of music],%(ext)s}
+''',   
        PRINTFILENAME: '''@file{%(filename)s}
 
        ''',
        VERBATIM: r'''@example
 %(verb)s@end example
 ''',
-       
        },
-       
        }
 
 PREAMBLE_LY = r'''%% Generated by %(program_name)s
@@ -496,31 +497,46 @@ class Lilypond_snippet (Snippet):
                func = Lilypond_snippet.__dict__ ['output_' + self.format]
                return func (self)
        
-       def output_html (self):
+       def get_images (self):
                base = self.basename ()
-               str = ''
-               if format == HTML:
-                       str = self.output_print_filename (HTML)
-                       if VERBATIM in self.options:
-                               verb = verbatim_html (self.substring ('code'))
-                               str += write (output[HTML][VERBATIM] % vars ())
-                               
                # URGUGHUGHUGUGHU
                single = '%(base)s.png' % vars ()
                multiple = '%(base)s-page1.png' % vars ()
-               pictures = (single,)
+               images = (single,)
                if os.path.exists (multiple) \
                   and (not os.path.exists (single)\
                        or (os.stat (multiple)[stat.ST_MTIME] \
                            > os.stat (single)[stat.ST_MTIME])):
-                       pictures = glob.glob ('%(base)s-page*.png' % vars ())
+                       images = glob.glob ('%(base)s-page*.png' % vars ())
+               return images
                
+       def output_html (self):
+               base = self.basename ()
+               str = ''
+               if format == HTML:
+                       str = self.output_print_filename (HTML)
+                       if VERBATIM in self.options:
+                               verb = verbatim_html (self.substring ('code'))
+                               str += write (output[HTML][VERBATIM] % vars ())
+
                str += output[HTML][BEFORE] % vars ()
-               for picture in pictures:
+               for image in self.get_images ():
+                       base, ext = os.path.splitext (image)
                        str += output[HTML][OUTPUT] % vars ()
                str += output[HTML][AFTER] % vars ()
                return str
-                       
+
+       def output_info (self):
+               str = output[TEXINFO][BEFORE] % vars ()
+               for image in self.get_images ():
+                       base, ext = os.path.splitext (image)
+                       # URG, makeinfo implicitely prepends dot to ext
+                       # specifying no extension is most robust
+                       ext = ''
+                       str += output[TEXINFO][OUTPUT] % vars ()
+               str += output[TEXINFO][AFTER] % vars ()
+               return str
+
        def output_latex (self):
                str = ''
                base = self.basename ()
@@ -554,9 +570,10 @@ class Lilypond_snippet (Snippet):
                        verb = verbatim_texinfo (self.substring ('code'))
                        str +=  (output[TEXINFO][VERBATIM] % vars ())
 
+               str += ('@ifinfo\n' + self.output_info () + '\n@end ifinfo\n')
                str += ('@tex\n' + self.output_latex () + '\n@end tex\n')
                str += ('@html\n' + self.output_html () + '\n@end html\n')
-               # need par after picture
+               # need par after image
                str += '\n'
 
                return str