CVSROOT: /cvsroot/lilypond
Module name: lilypond
Branch:
Changes by: Mats Bengtsson <[EMAIL PROTECTED]> 05/05/04 16:11:59
Modified files:
. : ChangeLog
scripts : convert-ly.py
Log message:
* scripts/convert-ly.py: Attempt to do a smarter update of
text markups from versions < 1.9.0 with arbitrary nesting.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.3552&tr2=1.3553&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scripts/convert-ly.py.diff?tr1=1.243&tr2=1.244&r1=text&r2=text
Patches:
Index: lilypond/ChangeLog
diff -u lilypond/ChangeLog:1.3552 lilypond/ChangeLog:1.3553
--- lilypond/ChangeLog:1.3552 Wed May 4 14:26:43 2005
+++ lilypond/ChangeLog Wed May 4 16:11:59 2005
@@ -1,3 +1,8 @@
+2005-05-04 Mats Bengtsson <[EMAIL PROTECTED]>
+
+ * scripts/convert-ly.py: Attempt to do a smarter update of
+ text markups from versions < 1.9.0 with arbitrary nesting.
+
2005-05-04 Heikki Junes <[EMAIL PROTECTED]>
* po/fi.po: convert to utf-8, and update.
Index: lilypond/scripts/convert-ly.py
diff -u lilypond/scripts/convert-ly.py:1.243
lilypond/scripts/convert-ly.py:1.244
--- lilypond/scripts/convert-ly.py:1.243 Mon May 2 10:34:19 2005
+++ lilypond/scripts/convert-ly.py Wed May 4 16:11:59 2005
@@ -1437,16 +1437,45 @@
str = re.sub (r'@ACCENT@', '>', str)
return str
+ markup_start = re.compile(r"([-^_]|\\mark)\s*(#\s*'\s*)\(")
+ musicglyph = re.compile(r"\(\s*music\b")
+ submarkup_start = re.compile(r"\(\s*([a-zA-Z]+)")
+ leftpar = re.compile(r"\(")
+ rightpar = re.compile(r"\)")
+
def text_markup (str):
- str = re.sub (r"""([-_^]) *# *' *\( *music *(\"[^"]*\") *\)""",
- r"\1\\markup { \\musicglyph #\2 }", str)
- str = re.sub (r"""([-_^]) *# *' *\( *([a-z]+) *([^()]*)\)""",
- r"\1\\markup { \\\2 \3 }", str)
- str = re.sub (r"""\\mark *# *' *\( *music *(\"[^"]*\") *\)""",
- r"\\mark \\markup { \\musicglyph #\1 }", str)
- str = re.sub (r"""\\mark *# *' *\( *([a-z]+) *([^()]*)\)""",
- r"\\mark \\markup { \\\1 \2 }", str)
- return str
+ result = ''
+ # Find the beginning of each markup:
+ match = markup_start.search (str)
+ while match:
+ result = result + str[:match.end (1)] + " \markup"
+ str = str[match.end( 2):]
+ # Count matching parentheses to find the end of the
+ # current markup:
+ 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:
+ markup_end = par.end ()
+ break
+ # The full markup in old syntax:
+ markup = str[:markup_end]
+ # Modify to new syntax:
+ markup = musicglyph.sub (r"{\\musicglyph", markup)
+ markup = submarkup_start.sub (r"{\\\1", markup)
+ markup = leftpar.sub ("{", markup)
+ markup = rightpar.sub ("}", markup)
+
+ result = result + markup
+ # Find next markup
+ str = str[markup_end:]
+ match = markup_start.search(str)
+ result = result + str
+ return result
def articulation_substitute (str):
str = re.sub (r"""([^-])\[ *([a-z]+[,']*[!?]?[0-9:]*\.*)""",
_______________________________________________
Lilypond-cvs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-cvs