From ad7a2171cd6a54df1a9febb5c17d212deeb9a4a9 Mon Sep 17 00:00:00 2001 From: Solara570 Date: Tue, 23 Jan 2018 02:14:18 +0800 Subject: [PATCH] A few improvements on TexMobject --- mobject/tex_mobject.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mobject/tex_mobject.py b/mobject/tex_mobject.py index fe5a3cdd..8401f5b7 100644 --- a/mobject/tex_mobject.py +++ b/mobject/tex_mobject.py @@ -87,7 +87,7 @@ class TexMobject(SVGMobject): should_replace = reduce(op.and_, [ t1 in tex, t2 not in tex, - len(tex) > len(t1) and tex[len(t1)] in "()[]|\\" + len(tex) > len(t1) and tex[len(t1)] in "()[]<>|.\\" ]) if should_replace: tex = tex.replace(t1, "\\big") @@ -166,9 +166,16 @@ class TexMobject(SVGMobject): part.highlight(color) return self - def highlight_by_tex_to_color_map(self, tex_to_color_map): - for tex, color in tex_to_color_map.items(): - self.highlight_by_tex(tex, color) + def highlight_by_tex_to_color_map(self, texs_to_color_map, **kwargs): + for texs, color in texs_to_color_map.items(): + try: + # If the given key behaves like strings + texs + '' + self.highlight_by_tex(texs, color, **kwargs) + except TypeError: + # If the given key is a tuple + for tex in texs: + self.highlight_by_tex(tex, color, **kwargs) return self def index_of_part(self, part):