]> git.donarmstrong.com Git - lilypond.git/blobdiff - python/convertrules.py
Revert "Some more issue 3229 rules"
[lilypond.git] / python / convertrules.py
index 0df4b09b1d735a863bd8d4bdd76a66e6a35bfc66..68c7288de865548afab85684746bd5d23f7b3b90 100644 (file)
@@ -3298,12 +3298,15 @@ def brace_matcher (n):
     return r"[^{}]*?(?:{"*n+r"[^{}]*?"+r"}[^{}]*?)*?"*n
 
 matchstring = r'"(?:[^"\\]|\\.)*"'
-matcharg = (r"\s+(?:[$#]['`]?\s*(?:[a-zA-Z]\S*|" + matchstring + r"|\("
-            + paren_matcher(20) + r"\))|" + matchstring + r"|\\[a-z_A-Z]+)")
-matchmarkup = (r'(?:\\markup\s*(?:{' + brace_matcher (20) +r'}|' +
+matcharg = (r"\s+(?:[$#]['`]?\s*(?:[a-zA-Z][^ \t\n()\\]*|" + matchstring
+            + r"|#?\(" + paren_matcher(20) + r"\)|"
+            + r"-?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)|"
+            + r"#(?:[tf]|\\.|@?\{" + brace_matcher (10) + r"#@?\}))|"
+            + matchstring + r"|\\[a-z_A-Z]+|[0-9]+(?:/[0-9]+)?|-[0-9]+)")
+matchmarkup = (r'(?:\\markup\s*(?:@?\{' + brace_matcher (20) +r'\}|' +
                matchstring + r'|(?:\\[a-z_A-Z][a-z_A-Z-]*(?:' + matcharg +
-               r')*?\s*)*(?:' + matchstring + "|{" + brace_matcher (20) +
-               "}))|" + matchstring + ")")
+               r')*?\s*)*(?:' + matchstring + r"|@?\{" + brace_matcher (20) +
+               r"\}))|" + matchstring + ")")
 
 @rule((2, 15, 25), r"\(auto)?Footnote(Grob)? -> \footnote")
 def conv (str):
@@ -3665,7 +3668,7 @@ def conv(str):
 
 @rule((2, 17, 27), r'''\stringTuning \notemode -> \stringTuning''')
 def conv(str):
-    str = re.sub (r"\\stringTuning\s*\\notemode(\s*)@?\{\s*(.*?)\s*@?}",
+    str = re.sub (r"\\stringTuning\s*\\notemode(\s*)@?\{\s*(.*?)\s*@?\}",
                   r"\\stringTuning\1\2", str)
     if re.search (r'[^-\w]staff-padding[^-\w]', str):
         stderr_write (NOT_SMART % "staff-padding")
@@ -3723,12 +3726,24 @@ def conv(str):
     str = re.sub (r'\bthin-kern\b', 'segno-kern', str)
     return str
 
+# before_id is written in a manner where it will only substantially
+# (rather than as a lookbefore assertion) match material that could
+# not be part of a previous id.  In that manner, one replacement does
+# not inhibit an immediately adjacent replacement.
+
+before_id = r'(?:^|(?<!\\)(?:\\\\)+|(?<=[^-_\\a-zA-Z])|(?<=[^a-zA-Z][-_]))'
+
+# after_id is a pure lookbehind assertion so its match string is
+# always empty
+
+after_id = r'(?![a-zA-Z]|[-_][a-zA-Z])'
+
 @rule ((2, 19, 16), """implicitTimeSignatureVisibility -> initialTimeSignatureVisibility
 csharp -> c-sharp""")
 def conv(str):
     str = re.sub (r'\bimplicitTimeSignatureVisibility\b', 'initialTimeSignatureVisibility', str)
-    str = re.sub (r'\b([a-g])((?:sharp){1,2}|(?:flat){1,2})\b',r'\1-\2', str)
-    str = re.sub (r'\\shiftOff\b', r'\\undo\\shiftOn', str)
+    str = re.sub ('(' + before_id + r'[a-g])((?:sharp){1,2}|(?:flat){1,2})'
+                  + after_id, r'\1-\2', str)
     return str
 
 # Guidelines to write rules (please keep this at the end of this file)