Merge pull request #83 from Solara570/tex-mobject-fixes

A few improvements on TexMobject
This commit is contained in:
Grant Sanderson 2018-01-22 11:42:11 -08:00 committed by GitHub
commit 22c11286b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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