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 8bd01d6 commit 4dfe8af
Show file tree
Hide file tree
Showing 7 changed files with 756 additions and 484 deletions.
2 changes: 0 additions & 2 deletions manimlib/default_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ directories:
temporary_storage: ""
universal_import_line: "from manimlib import *"
style:
# "latex" | "xelatex"
tex_compiler: "latex"
tex_template: "default"
font: "Consolas"
text_alignment: "LEFT"
Expand Down
9 changes: 2 additions & 7 deletions manimlib/mobject/svg/mtex_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,8 @@ def get_content_prefix_and_suffix(
if self.alignment:
prefix_lines.append(self.alignment)
if self.tex_environment:
if isinstance(self.tex_environment, str):
env_prefix = f"\\begin{{{self.tex_environment}}}"
env_suffix = f"\\end{{{self.tex_environment}}}"
else:
env_prefix, env_suffix = self.tex_environment
prefix_lines.append(env_prefix)
suffix_lines.append(env_suffix)
prefix_lines.append(f"\\begin{{{self.tex_environment}}}")
suffix_lines.append(f"\\end{{{self.tex_environment}}}")
return (
"".join([line + "\n" for line in prefix_lines]),
"".join(["\n" + line for line in suffix_lines])
Expand Down
8 changes: 4 additions & 4 deletions manimlib/mobject/svg/string_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,13 @@ def get_submob_indices_lists_by_selector(
def build_parts_from_indices_lists(
self, indices_lists: list[list[int]]
) -> VGroup:
return VGroup(*[
VGroup(*[
return VGroup(*(
VGroup(*(
self.submobjects[submob_index]
for submob_index in indices_list
])
))
for indices_list in indices_lists
])
))

def build_groups(self) -> VGroup:
return self.build_parts_from_indices_lists([
Expand Down
10 changes: 5 additions & 5 deletions manimlib/mobject/svg/text_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def replace_for_content(match_obj: re.Match) -> str:

@staticmethod
def replace_for_matching(match_obj: re.Match) -> str:
if match_obj.group("tag"):
if match_obj.group("tag") or match_obj.group("passthrough"):
return ""
if match_obj.group("entity"):
if match_obj.group("unicode"):
Expand Down Expand Up @@ -311,7 +311,7 @@ def get_attr_dict_from_command_pair(

def get_configured_items(self) -> list[tuple[Span, dict[str, str]]]:
return [
*[
*(
(span, {key: val})
for t2x_dict, key in (
(self.t2c, "foreground"),
Expand All @@ -321,12 +321,12 @@ def get_configured_items(self) -> list[tuple[Span, dict[str, str]]]:
)
for selector, val in t2x_dict.items()
for span in self.find_spans_by_selector(selector)
],
*[
),
*(
(span, local_config)
for selector, local_config in self.local_configs.items()
for span in self.find_spans_by_selector(selector)
]
)
]

@staticmethod
Expand Down
Loading

0 comments on commit 4dfe8af

Please sign in to comment.