Skip to content

Commit

Permalink
refactor: refactor StringMobject
Browse files Browse the repository at this point in the history
  • Loading branch information
YishiMichael committed Aug 22, 2022
1 parent 19c757e commit c2a75e1
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 292 deletions.
9 changes: 4 additions & 5 deletions manimlib/mobject/svg/mtex_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@ def get_file_path_by_content(self, content: str) -> str:

@staticmethod
def get_command_matches(string: str) -> list[re.Match]:
# Group together adjacent braces
# Lump together adjacent brace pairs
pattern = re.compile(r"""
(?P<command>\\(?:[a-zA-Z]+|.))
|(?P<script>[_^])
|(?P<open>{+)
|(?P<close>}+)
""", flags=re.X | re.S)
Expand Down Expand Up @@ -131,9 +130,9 @@ def replace_for_content(match_obj: re.Match) -> str:

@staticmethod
def replace_for_matching(match_obj: re.Match) -> str:
if match_obj.group("script"):
return ""
return match_obj.group()
if match_obj.group("command"):
return match_obj.group()
return ""

@staticmethod
def get_attr_dict_from_command_pair(
Expand Down
Loading

0 comments on commit c2a75e1

Please sign in to comment.