+2005-04-20 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * 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 <janneke@gnu.org>
* configure.in (no gui_b): Remove optional gtk+ requirement.
2005-04-20 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * 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
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
TEXINFO = 'texinfo'
VERBATIM = 'verbatim'
FONTLOAD = 'fontload'
+FILENAME = 'filename'
+ALT = 'alt'
# NOTIME has no opposite so it isn't part of this dictionary.
PRINTFILENAME,
TEXIDOC,
VERBATIM,
- FONTLOAD
+ FONTLOAD,
+ FILENAME,
+ ALT
]
ly_options = {
OUTPUT: r'''
<img align="center" valign="center"
- border="0" src="%(image)s" alt="[image of music]">''',
+ border="0" src="%(image)s" alt="%(alt)s">''',
PRINTFILENAME: '<p><tt><a href="%(base)s.ly">%(filename)s</a></tt></p>',
OUTPUTIMAGE: r'''@noindent
@ifinfo
-@image{%(base)s,,,[image of music],%(ext)s}
+@image{%(base)s,,,%(alt)s,%(ext)s}
@end ifinfo
@html
<p>
<a href="%(base)s.ly">
<img align="center" valign="center"
- border="0" src="%(image)s" alt="[image of music]">
+ border="0" src="%(image)s" alt="%(alt)s">
</a>
</p>
@end html
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<q>["\'])(.*)(?P=q)','\g<1>\g<3>',options[i])
+ return options
+ else:
+ return re.split (format_res[format]['option_sep'],
+ option_string)
return []
class Chunk:
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')
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'
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
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
# 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 ()