A few improvements on TexMobject

This commit is contained in:
Solara570 2018-01-23 02:14:18 +08:00
parent 5780998115
commit ad7a2171cd

View file

@ -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):