A community-maintained Python framework for creating mathematical animations.
Fixed TextMobject bug
Grant Sanderson1ca7e8ecdab0
diff --git a/mobject/svg/tex_mobject.py b/mobject/svg/tex_mobject.pyindex 2fc855ac8..97a817843 100644--- a/mobject/svg/tex_mobject.py+++ b/mobject/svg/tex_mobject.py@@ -4,7 +4,7 @@ from constants import *from .svg_mobject import SVGMobjectfrom .svg_mobject import VMobjectFromSVGPathstringfrom utils.config_ops import digest_config-from utils.strings import split_string_list_to_isolate_substring+from utils.strings import split_string_list_to_isolate_substringsfrom utils.tex_file_writing import tex_to_svg_filefrom mobject.geometry import Linefrom mobject.types.vectorized_mobject import VGroup@@ -155,10 +155,9 @@ class TexMobject(SingleStringTexMobject):self.substrings_to_isolate,list(self.tex_to_color_map.keys()))- split_list = split_string_list_to_isolate_substring(+ split_list = split_string_list_to_isolate_substrings(tex_strings, *substrings_to_isolate)- split_list = [item for sublist in split_list for item in sublist]split_list = list(map(str.strip, split_list))split_list = [s for s in split_list if s != '']return split_list@@ -314,8 +313,8 @@ class Title(TextMobject):"underline_buff": MED_SMALL_BUFF,}- def __init__(self, text, **kwargs):- TextMobject.__init__(self, text, **kwargs)+ def __init__(self, *text_parts, **kwargs):+ TextMobject.__init__(self, *text_parts, **kwargs)self.scale(self.scale_factor)self.to_edge(UP)if self.include_underline:diff --git a/utils/strings.py b/utils/strings.pyindex 9034bca43..6f1cb8812 100644--- a/utils/strings.py+++ b/utils/strings.py@@ -43,12 +43,12 @@ def split_string_to_isolate_substrings(full_string, *substrings_to_isolate):))))all_substrings.pop(-1)all_substrings = [s for s in all_substrings if s != ""]- return split_string_list_to_isolate_substring(+ return split_string_list_to_isolate_substrings(all_substrings, *substrings_to_isolate[1:])-def split_string_list_to_isolate_substring(string_list, *substrings_to_isolate):+def split_string_list_to_isolate_substrings(string_list, *substrings_to_isolate):"""Similar to split_string_to_isolate_substrings, but the first argumentis a list of strings, thought of as something already broken up a bit.