Skip to content

Commit

Permalink
Merge pull request #75 from musicEnfanthen/feature/add-glyphs
Browse files Browse the repository at this point in the history
fix(utils): add missing glyphs
  • Loading branch information
musicEnfanthen authored Oct 1, 2024
2 parents 077f126 + add7743 commit cc0a11a
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions convert_source_description/utils_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,33 @@ 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",
"sf",
"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
Expand Down

0 comments on commit cc0a11a

Please sign in to comment.