CVSROOT: /cvsroot/lilypond Module name: lilypond Branch: Changes by: Mats Bengtsson <[EMAIL PROTECTED]> 05/05/09 08:41:16
Modified files: . : ChangeLog scripts : convert-ly.py Log message: * 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. CVSWeb URLs: http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.3575&tr2=1.3576&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scripts/convert-ly.py.diff?tr1=1.244&tr2=1.245&r1=text&r2=text Patches: Index: lilypond/ChangeLog diff -u lilypond/ChangeLog:1.3575 lilypond/ChangeLog:1.3576 --- lilypond/ChangeLog:1.3575 Mon May 9 08:31:11 2005 +++ lilypond/ChangeLog Mon May 9 08:41:15 2005 @@ -1,5 +1,10 @@ 2005-05-09 Mats Bengtsson <[EMAIL PROTECTED]> + * 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: lilypond/scripts/convert-ly.py diff -u lilypond/scripts/convert-ly.py:1.244 lilypond/scripts/convert-ly.py:1.245 --- lilypond/scripts/convert-ly.py:1.244 Wed May 4 16:11:59 2005 +++ lilypond/scripts/convert-ly.py Mon May 9 08:41:16 2005 @@ -1439,6 +1439,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 _______________________________________________ Lilypond-cvs mailing list Lilypond-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-cvs