From b86561dab687880d37383b28b3ad7ca08a98dc6b Mon Sep 17 00:00:00 2001 From: musicEnfanthen Date: Tue, 1 Oct 2024 14:43:26 +0200 Subject: [PATCH 1/3] fix(utils): add missing glyphs for mf, mp and ped --- convert_source_description/utils_helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/convert_source_description/utils_helper.py b/convert_source_description/utils_helper.py index 41ee047..1c3b571 100644 --- a/convert_source_description/utils_helper.py +++ b/convert_source_description/utils_helper.py @@ -208,7 +208,7 @@ def replace_glyphs(self, text: str) -> str: Returns: str: The replaced text. """ - glyphs = ["a", "b", "bb", "#", "x", "f", "ff", "fff", "p", "pp", "ppp"] + glyphs = ["a", "b", "bb", "#", "x", "f", "ff", "fff", "mf", "mp", "p", "pp", "ppp", "ped"] glyph_pattern = '|'.join(re.escape(glyph) for glyph in glyphs) return re.sub( From f3fa7957adc91f48fa176474613ddba638b8c985 Mon Sep 17 00:00:00 2001 From: musicEnfanthen Date: Tue, 1 Oct 2024 14:52:49 +0200 Subject: [PATCH 2/3] fix(utils): add missing glyphs for sf and sp --- convert_source_description/utils_helper.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/convert_source_description/utils_helper.py b/convert_source_description/utils_helper.py index 1c3b571..17d07f7 100644 --- a/convert_source_description/utils_helper.py +++ b/convert_source_description/utils_helper.py @@ -208,7 +208,23 @@ def replace_glyphs(self, text: str) -> str: Returns: str: The replaced text. """ - glyphs = ["a", "b", "bb", "#", "x", "f", "ff", "fff", "mf", "mp", "p", "pp", "ppp", "ped"] + glyphs = [ + "a", + "b", + "bb", + "#", + "x", + "f", + "ff", + "fff", + "mf", + "mp", + "p", + "pp", + "ppp", + "ped", + "sf", + "sp"] glyph_pattern = '|'.join(re.escape(glyph) for glyph in glyphs) return re.sub( From add7743603dd869a64f08300eee0d163c1d72c61 Mon Sep 17 00:00:00 2001 From: musicEnfanthen Date: Tue, 1 Oct 2024 15:03:48 +0200 Subject: [PATCH 3/3] fix(utils): exclude hyphenated text syllables from glyph regex --- convert_source_description/utils_helper.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/convert_source_description/utils_helper.py b/convert_source_description/utils_helper.py index 17d07f7..e8203af 100644 --- a/convert_source_description/utils_helper.py +++ b/convert_source_description/utils_helper.py @@ -227,10 +227,14 @@ def replace_glyphs(self, text: str) -> str: "sp"] glyph_pattern = '|'.join(re.escape(glyph) for glyph in glyphs) + # Match pattern for glyphs in square brackets, but not followed by a hyphen + match_pattern = rf'\[({glyph_pattern})\](?!-)' + return re.sub( - rf'\[({glyph_pattern})\]', - lambda match: f"{{{{ref.getGlyph('{match.group(0)}')}}}}", - text) + match_pattern, + lambda match: f"{{{{ref.getGlyph('{match.group(1)}')}}}}", + text + ) ############################################ # Helper function: _get_comment