> can you have a look at the lilypond-book.py in 2.5.20 to see what parts
> are still missing, and which you need? I added meaningful error messages
> (including file and line numbers for input snippets) to lilypond-book
> recently.

Upgrading guile fixed the segfaults.

Here are updated patches, in order of application and importance:

htmlquote.patch2 -- This can be considered a bugfix, since real html
attributes cannot be parsed with a simple split.

filename.patch2 -- Allows snippets to be given distinct filenames. This
makes managing and (re)using your snippets easier, as I have explained
elsewhere.

alt.patch2 -- Mostly cosmetic, allows the default alt text to be
overridden.  Note: do_options must be called in order for
default_ly_options to take effect.

inline.patch2 -- adds inline option to remove <p> and <a> tags from around
the music image.  This is also one way to achieve my goal of being able to
link to a .midi file or have no link at all.

An alternative to inline.patch2 would be to remove the <p> tags by
default, as you suggest.  I would then propose a link=[midi|ly|none]
option to control the link.  I still need to figure out how to get it to
generate the midi file on demand though.

~ John Williams
--- lilypond-book       2005/04/20 01:44:26     1.1.1.1.1.5
+++ lilypond-book       2005/04/20 01:44:53
@@ -153,6 +153,7 @@
 FONTLOAD = 'fontload'
 FILENAME = 'filename'
 ALT = 'alt'
+INLINE = 'inline'
 
 
 # NOTIME has no opposite so it isn't part of this dictionary.
@@ -393,7 +394,8 @@
        VERBATIM,
        FONTLOAD,
        FILENAME,
-       ALT
+       ALT,
+       INLINE
 ]
 
 ly_options = {
@@ -965,12 +967,14 @@
                        if QUOTE in self.option_dict:
                                str = output[HTML][QUOTE] % vars ()
 
-               str += output[HTML][BEFORE] % vars ()
+               if not INLINE in self.option_dict:
+                       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 ()
+               if not INLINE in self.option_dict:
+                       str += output[HTML][AFTER] % vars ()
                return str
 
        def output_info (self):
--- lilypond-book       2005/04/20 01:12:52     1.1.1.1.1.2
+++ lilypond-book       2005/04/20 01:13:07
@@ -622,8 +622,14 @@
 
 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:
--- lilypond-book       2005/04/20 01:23:02     1.1.1.1.1.3
+++ lilypond-book       2005/04/20 01:32:36     1.1.1.1.1.4
@@ -151,6 +151,7 @@
 TEXINFO = 'texinfo'
 VERBATIM = 'verbatim'
 FONTLOAD = 'fontload'
+FILENAME = 'filename'
 
 
 # NOTIME has no opposite so it isn't part of this dictionary.
@@ -389,7 +390,8 @@
        PRINTFILENAME,
        TEXIDOC,
        VERBATIM,
-       FONTLOAD
+       FONTLOAD,
+       FILENAME
 ]
 
 ly_options = {
@@ -877,6 +879,8 @@
                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'
@@ -898,8 +902,9 @@
                     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
--- lilypond-book       2005/04/20 01:32:36     1.1.1.1.1.4
+++ lilypond-book       2005/04/20 01:38:17
@@ -117,7 +117,7 @@
 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,7 @@
 VERBATIM = 'verbatim'
 FONTLOAD = 'fontload'
 FILENAME = 'filename'
+ALT = 'alt'
 
 
 # NOTIME has no opposite so it isn't part of this dictionary.
@@ -391,7 +392,8 @@
        TEXIDOC,
        VERBATIM,
        FONTLOAD,
-       FILENAME
+       FILENAME,
+       ALT
 ]
 
 ly_options = {
@@ -444,7 +446,7 @@
 
                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>',
 
@@ -508,13 +510,13 @@
 
                OUTPUTIMAGE: r'''@noindent
 @ifinfo
[EMAIL PROTECTED](base)s,,,[image of music],%(ext)s}
[EMAIL PROTECTED](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
@@ -690,8 +692,7 @@
        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')
@@ -967,6 +968,7 @@
                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
@@ -979,6 +981,7 @@
                        # 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 ()
_______________________________________________
bug-lilypond mailing list
bug-lilypond@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-lilypond

Reply via email to