mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
A few improvements on TexMobject
This commit is contained in:
parent
5780998115
commit
ad7a2171cd
1 changed files with 11 additions and 4 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Reference in a new issue