X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Flilypond-book.py;h=0d7659714c039837e40a78a5d7818f4ee21dc04e;hb=5c006bd489c6bceb39973a1cd4e2260c9391766a;hp=b93518628bf7b95b547696524328df968eebaa67;hpb=3bb99011330dcf1f97005a6216e2e1b7ae1052cb;p=lilypond.git diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index b93518628b..0d7659714c 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -219,12 +219,12 @@ output = { ''', OUTPUT: r''' [picture of music]''', + border="0" src="%(image)s" alt="[image of music]">''', PRINTFILENAME:'

%(filename)s

', VERBATIM: r'''
 %(verb)s
''', }, - + 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