]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix numeric tempi and detached lyrics in abc2ly
authorPhil Holmes <mail@philholmes.net>
Tue, 18 Sep 2012 14:06:10 +0000 (15:06 +0100)
committerPhil Holmes <mail@philholmes.net>
Mon, 24 Sep 2012 08:42:32 +0000 (09:42 +0100)
scripts/abc2ly.py

index 60900ca8315d78890eebea3a208b4a139790c8f0..15161032f2b251155b69cfc3b1ef4c58fb5775c0 100644 (file)
@@ -222,11 +222,11 @@ def dump_header (outf,hdr):
 
 def dump_lyrics (outf):
     if (len(lyrics)):
-        outf.write("\n\\score\n{\n \\lyrics\n <<\n")
+        outf.write("\n\\markup \\column {\n")
         for i in range (len (lyrics)):
-            outf.write ( lyrics [i])
+            outf.write (lyrics [i])
             outf.write ("\n")
-        outf.write("    >>\n    \\layout{}\n}\n")
+        outf.write("}\n")
 
 def dump_default_bar (outf):
     """
@@ -284,7 +284,15 @@ def try_parse_q(a):
         dur = duration_to_lilypond_duration ((numerator,denominator), 1, 0)
         voices_append ("\\tempo " + descr + " " + dur + "=" + tempo + "\n")
     else:
-        sys.stderr.write("abc2ly: Warning, unable to parse Q specification: %s\n" % a)
+        # Parsing of numeric tempi, as these are fairly
+        # common.  The spec says the number is a "beat" so using
+        # a quarter note as the standard time
+        numericQ = re.compile ('[0-9]+')
+        m = numericQ.match (a)
+        if m:
+            voices_append ("\\tempo 4=" + m.group(0))
+        else:
+            sys.stderr.write("abc2ly: Warning, unable to parse Q specification: %s\n" % a)
 
 def dump_score (outf):
     outf.write (r"""
@@ -617,7 +625,7 @@ def repeat_prepend():
 def lyrics_append(a):
     a = re.sub ('#', '\\#', a)        # latex does not like naked #'s
     a = re.sub ('"', '\\"', a)        # latex does not like naked "'s
-    a = '\t{  "' + a + '" }\n'
+    a = '  \\line { "' + a + '" }\n'
     stuff_append (lyrics, current_lyric_idx, a)
 
 # break lyrics to words and put "'s around words containing numbers and '"'s