From bb3285ff1f4cd437ba52afbaa53e7ff5946a7140 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Wed, 23 Mar 2016 17:31:21 +0100 Subject: [PATCH] Issue 4811/2: convert-ly rule for nicer beatStructure syntax --- python/convertrules.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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, -- 2.39.5