Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

remove_stray_braces quickfix (#240)

mz71a3d2429a180f
diff --git a/manim/mobject/svg/tex_mobject.py b/manim/mobject/svg/tex_mobject.py
index c63824387..9b14e8819 100644
--- a/manim/mobject/svg/tex_mobject.py
+++ b/manim/mobject/svg/tex_mobject.py
@@ -104,7 +104,9 @@ class SingleStringTexMobject(SVGMobject):
"""
Makes TexMobject resiliant to unmatched { at start
"""
- num_lefts, num_rights = [tex.count(char) for char in "{}"]
+ # "\{" does not count (it's a brace literal), but "\\{" counts (it's a new line and then brace)
+ num_lefts = tex.count("{") - tex.count("\\{") + tex.count("\\\\{")
+ num_rights = tex.count("}") - tex.count("\\}") + tex.count("\\\\}")
while num_rights > num_lefts:
tex = "{" + tex
num_lefts += 1