summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDavid Kastrup <dak@gnu.org>2015-05-10 16:03:42 +0200
committerDavid Kastrup <dak@gnu.org>2015-05-16 10:23:14 +0200
commit73620b9029d04102a2e98d7dbd55c756b13e5512 (patch)
tree10503bc9a68fcd3e7e668bd87e9fd6b46c208172 /python
parent7eef6e252aea1c29512a2df501aaa5c832f57038 (diff)
Issue 4372: convert-ly misses some bflat -> b-flat
In python/convert-rules.py, using '\b' for note name boundaries turns out to be too audacious since bflat4 is one word. A proper solution would be to match the variable wordsyntax and let the match expression use a replacement function that triggers on the right words. However, such a large number of matches would be expensive. So instead we are using positive lookahead and lookbehind expressions to get reasonably good matches.
Diffstat (limited to 'python')
-rw-r--r--python/convertrules.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/python/convertrules.py b/python/convertrules.py
index 0df4b09b1d..05beeec455 100644
--- a/python/convertrules.py
+++ b/python/convertrules.py
@@ -3723,11 +3723,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 ('(' + before_id + r'[a-g])((?:sharp){1,2}|(?:flat){1,2})'
+ + after_id, r'\1-\2', str)
str = re.sub (r'\\shiftOff\b', r'\\undo\\shiftOn', str)
return str