From e3d281e61372d24fcc7dadfb1990f61f9360c460 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 20 Apr 2005 10:52:20 +0000 Subject: [PATCH] patches by John Williams: htmlquote bugfix. Allow snippets to be given distinct filenames. Allow the default alt text to be overridden. --- ChangeLog | 10 +++++++ Documentation/user/basic-notation.itely | 3 ++- lily/slur-scoring.cc | 2 -- scripts/lilypond-book.py | 36 +++++++++++++++++-------- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 493451251c..987469c926 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,19 @@ +2005-04-20 Han-Wen Nienhuys + + * scripts/lilypond-book.py: patches by John Williams: + htmlquote bugfix. + Allow snippets to be given distinct filenames. + Allow the default alt text to be overridden. + 2005-04-20 Jan Nieuwenhuizen * configure.in (no gui_b): Remove optional gtk+ requirement. 2005-04-20 Han-Wen Nienhuys + * Documentation/user/basic-notation.itely (Pitches): add + LedgerLineSpanner. + * lily/dynamic-engraver.cc (process_music): set right bound to script if present. Else, do not set. (acknowledge_grob): only set right bound of finished spanner to diff --git a/Documentation/user/basic-notation.itely b/Documentation/user/basic-notation.itely index 41aa207038..740a7d0a37 100644 --- a/Documentation/user/basic-notation.itely +++ b/Documentation/user/basic-notation.itely @@ -138,7 +138,8 @@ espanol.ly do re mi fa sol la sib si -s -b @seealso -Program reference: @internalsref{NoteEvent}, and @internalsref{NoteHead}. +Program reference: @internalsref{NoteEvent}, +@internalsref{LedgerLineSpanner}, and @internalsref{NoteHead}. diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc index f0cebb1a73..160e157089 100644 --- a/lily/slur-scoring.cc +++ b/lily/slur-scoring.cc @@ -32,8 +32,6 @@ - curve around flag for y coordinate - - this file is a mess, clean it up - - short-cut: try a smaller region first. - handle non-visible stems better. diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 04ac4a65aa..49c0a46565 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -118,7 +118,7 @@ output_name = '' latex_filter_cmd = 'latex "\\nonstopmode \input /dev/stdin"' filter_cmd = 0 process_cmd = '' -default_ly_options = {} +default_ly_options = { 'alt': "[image of music]" } # # Is this pythonic? Personally, I find this rather #define-nesque. --hwn @@ -152,6 +152,8 @@ TEXIDOC = 'texidoc' TEXINFO = 'texinfo' VERBATIM = 'verbatim' FONTLOAD = 'fontload' +FILENAME = 'filename' +ALT = 'alt' # NOTIME has no opposite so it isn't part of this dictionary. @@ -390,7 +392,9 @@ simple_options = [ PRINTFILENAME, TEXIDOC, VERBATIM, - FONTLOAD + FONTLOAD, + FILENAME, + ALT ] ly_options = { @@ -443,7 +447,7 @@ output = { OUTPUT: r''' [image of music]''', + border="0" src="%(image)s" alt="%(alt)s">''', PRINTFILENAME: '

%(filename)s

', @@ -507,13 +511,13 @@ output = { OUTPUTIMAGE: r'''@noindent @ifinfo -@image{%(base)s,,,[image of music],%(ext)s} +@image{%(base)s,,,%(alt)s,%(ext)s} @end ifinfo @html

[image of music] + border="0" src="%(image)s" alt="%(alt)s">

@end html @@ -623,8 +627,14 @@ def verbatim_texinfo (s): def split_options (option_string): if option_string: - return re.split (format_res[format]['option_sep'], - option_string) + if format == HTML: + options = re.findall('[\w\.-:]+(?:\s*=\s*(?:"[^"]*"|\'[^\']*\'|\S+))?',option_string) + for i in range(len(options)): + options[i] = re.sub('^([^=]+=\s*)(?P["\'])(.*)(?P=q)','\g<1>\g<3>',options[i]) + return options + else: + return re.split (format_res[format]['option_sep'], + option_string) return [] class Chunk: @@ -683,8 +693,7 @@ class Lilypond_snippet (Snippet): def __init__ (self, type, match, format, line_number): Snippet.__init__ (self, type, match, format, line_number) os = match.group ('options') - if os: - self.do_options (os, self.type) + self.do_options (os, self.type) def ly (self): return self.substring ('code') @@ -872,6 +881,8 @@ class Lilypond_snippet (Snippet): return self.hash def basename (self): + if FILENAME in self.option_dict: + return self.option_dict[FILENAME] if use_hash_p: return 'lily-%d' % self.get_hash () raise 'to be done' @@ -893,8 +904,9 @@ class Lilypond_snippet (Snippet): and os.path.exists (system_file)\ and os.stat (system_file)[stat.ST_SIZE] \ and re.match ('% eof', open (system_file).readlines ()[-1]) - if ok and (use_hash_p \ - or self.ly () == open (ly_file).read ()): + if ok and (not use_hash_p or FILENAME in self.option_dict): + ok = (self.full_ly () == open (ly_file).read ()) + if ok: # TODO: Do something smart with target formats # (ps, png) and m/ctimes. return None @@ -957,6 +969,7 @@ class Lilypond_snippet (Snippet): str += output[HTML][BEFORE] % vars () for image in self.get_images (): (base, ext) = os.path.splitext (image) + alt = self.option_dict[ALT] str += output[HTML][OUTPUT] % vars () str += output[HTML][AFTER] % vars () return str @@ -969,6 +982,7 @@ class Lilypond_snippet (Snippet): # URG, makeinfo implicitly prepends dot to extension. # Specifying no extension is most robust. ext = '' + alt = self.option_dict[ALT] str += output[TEXINFO][OUTPUTIMAGE] % vars () base = self.basename () -- 2.39.5