summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDavid Kastrup <dak@gnu.org>2016-03-23 17:31:21 +0100
committerDavid Kastrup <dak@gnu.org>2016-03-29 08:01:04 +0200
commitbb3285ff1f4cd437ba52afbaa53e7ff5946a7140 (patch)
treeaf443859f0d62ed8be3493157c5a411a4ce93f28 /python
parent2a66e23f356503ef916d51efa3f00cae5958dc48 (diff)
Issue 4811/2: convert-ly rule for nicer beatStructure syntax
Diffstat (limited to 'python')
-rw-r--r--python/convertrules.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/python/convertrules.py b/python/convertrules.py
index 9de1256783..3e43a28133 100644
--- a/python/convertrules.py
+++ b/python/convertrules.py
@@ -3871,6 +3871,23 @@ def conv(str):
str = re.sub (r"#'whiteout-box(?![a-z_-])\b", r"#'whiteout", str)
return str
+@rule ((2, 19, 40), r"\time #'(2 3) ... -> \time 2,3 ...")
+def conv (str):
+ def repl (m):
+ return m.group(1) + re.sub (r"\s+", ",", m.group (2))
+
+ str = re.sub (r"(beatStructure\s*=\s*)#'\(([0-9]+(?:\s+[0-9]+)+)\)",
+ repl, str)
+
+ str = re.sub (r"(\\time\s*)#'\(([0-9]+(?:\s+[0-9]+)+)\)", repl, str)
+ def repl (m):
+ subst = re.sub (r"\s+", ",", m.group (1))
+ return subst + (4 + len (m.group (1)) - len (subst)) * " " + m.group (2)
+
+ str = re.sub (r"#'\(([0-9]+(?:\s+[0-9]+)+)\)(\s+%\s*beatStructure)",
+ repl, str)
+ return str
+
# Guidelines to write rules (please keep this at the end of this file)
#
# - keep at most one rule per version; if several conversions should be done,