]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scripts/convert-ly.py: In the conversion to version 1.9.0,
authorMats Bengtsson <mats.bengtsson@s3.kth.se>
Mon, 9 May 2005 08:41:16 +0000 (08:41 +0000)
committerMats Bengtsson <mats.bengtsson@s3.kth.se>
Mon, 9 May 2005 08:41:16 +0000 (08:41 +0000)
keep Scheme expressions and strings unmodified when doing the
conversion to postfix notation for slurs and beams. Should
hopefully solve most related conversion problems.

ChangeLog
scripts/convert-ly.py

index 8387f9e8035829cb70d2e8a55fa7d5fcef59eb59..6118eea17031094b705b499d174d06ae598d56c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-05-09  Mats Bengtsson  <mabe@drongo.s3.kth.se>
 
+       * scripts/convert-ly.py: In the conversion to version 1.9.0, 
+       keep Scheme expressions and strings unmodified when doing the
+       conversion to postfix notation for slurs and beams. Should
+       hopefully solve most related conversion problems. 
+
        * Documentation/user/lilypond-book.itely : Clarify and correct how
        to call dvips with -h psfonts.
 
index abc5e2d81d590398c63bdd79ea36f789a174388d..4119d0f8f196b2471bcf46d0bfd4c5d94ce515b8 100644 (file)
@@ -1439,6 +1439,7 @@ if 1:
 
        markup_start = re.compile(r"([-^_]|\\mark)\s*(#\s*'\s*)\(")
        musicglyph = re.compile(r"\(\s*music\b")
+       columns = re.compile(r"\(\s*columns\b")
        submarkup_start = re.compile(r"\(\s*([a-zA-Z]+)")
        leftpar = re.compile(r"\(")
        rightpar = re.compile(r"\)")
@@ -1466,6 +1467,7 @@ if 1:
                        markup = str[:markup_end]
                        # Modify to new syntax:
                        markup = musicglyph.sub (r"{\\musicglyph", markup)
+                       markup = columns.sub (r"{", markup)
                        markup = submarkup_start.sub (r"{\\\1", markup)
                        markup = leftpar.sub ("{", markup)
                        markup = rightpar.sub ("}", markup)
@@ -1478,7 +1480,7 @@ if 1:
                return result
 
        def articulation_substitute (str):
-               str = re.sub (r"""([^-])\[ *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
+               str = re.sub (r"""([^-])\[ *(\\?\)?[a-z]+[,']*[!?]?[0-9:]*\.*)""",
                              r"\1 \2[", str)
                str = re.sub (r"""([^-])\\\) *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
                              r"\1 \2\\)", str)
@@ -1488,6 +1490,44 @@ if 1:
                              r"\1 \2\\!", str)
                return str
 
+       string_or_scheme = re.compile ('("(?:[^"\\\\]|\\\\.)*")|(#\\s*\'?\\s*\\()')
+
+       # Only apply articulation_substitute () outside strings and 
+       # Scheme expressions:
+       def smarter_articulation_subst (str):
+               result = ''
+               # Find the beginning of next string or Scheme expr.:
+               match = string_or_scheme.search (str)
+               while match:
+                       # Convert the preceding LilyPond code:
+                       previous_chunk = str[:match.start()]
+                       result = result + articulation_substitute (previous_chunk)
+                       if match.group (1): # Found a string
+                               # Copy the string to output:
+                               result = result + match.group (1)
+                               str = str[match.end(1):]
+                       else: # Found a Scheme expression. Count 
+                               # matching parentheses to find its end
+                               str = str[match.start ():]
+                               nesting_level = 0
+                               pars = re.finditer(r"[()]",str)
+                               for par in pars:
+                                       if par.group () == '(':
+                                               nesting_level = nesting_level + 1
+                                       else:
+                                               nesting_level = nesting_level - 1
+                                       if nesting_level == 0:
+                                               scheme_end = par.end ()
+                                               break
+                               # Copy the Scheme expression to output:
+                               result = result + str[:scheme_end]
+                               str = str[scheme_end:]
+                       # Find next string or Scheme expression:
+                       match = string_or_scheme.search (str)
+               # Convert the remainder of the file
+               result = result + articulation_substitute (str)
+               return result
+
        def conv_relative(str):
                if re.search (r"\\relative", str):
                        str= "#(ly:set-option 'old-relative)\n" + str
@@ -1500,7 +1540,7 @@ if 1:
                str = sub_chords (str)
 
                str = text_markup (str)
-               str = articulation_substitute (str)
+               str = smarter_articulation_subst (str)
                str = re.sub ("@SCM_EOL@", "#'()", str)
 
                return str