Skip to content

Commit bcfa9ac

Browse files
authored
Fix bug introduced in Tex rendering via #2574 (#2587)
* Bugfix * Changes to log data * Add test * Seperate test
1 parent f23db3d commit bcfa9ac

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

manim/utils/tex_file_writing.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ def generate_tex_file(expression, environment=None, tex_template=None):
8484

8585
result = os.path.join(tex_dir, tex_hash(output)) + ".tex"
8686
if not os.path.exists(result):
87-
logger.info(f"Writing {expression} to %(path)s", {"path": f"{result}"})
87+
logger.info(
88+
"Writing %(expression)s to %(path)s",
89+
{"expression": expression, "path": f"{result}"},
90+
)
8891
with open(result, "w", encoding="utf-8") as outfile:
8992
outfile.write(output)
9093
return result

tests/control_data/logs_data/bad_tex_scene_BadTex.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{"levelname": "INFO", "module": "logger_utils", "message": "Log file will be saved in <>"}
2-
{"levelname": "INFO", "module": "tex_file_writing", "message": "Writing \\frac{1}{0} to <>"}
2+
{"levelname": "INFO", "module": "tex_file_writing", "message": "Writing <> to <>"}
33
{"levelname": "ERROR", "module": "tex_file_writing", "message": "LaTeX compilation error: LaTeX Error: File `notapackage.sty' not found.\n"}
44
{"levelname": "ERROR", "module": "tex_file_writing", "message": "Context of error: \n\\documentclass[preview]{standalone}\n-> \\usepackage{notapackage}\n\\begin{document}\n\n\\begin{center}\n"}
55
{"levelname": "INFO", "module": "tex_file_writing", "message": "You do not have package notapackage.sty installed."}

tests/test_texmobject.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ def test_tex():
3333
assert Path(config.media_dir, "Tex", "983949cac5bdd272.svg").exists()
3434

3535

36+
def test_percent_char_rendering():
37+
Tex(r"\%")
38+
assert Path(config.media_dir, "Tex", "ce6e53f2d9c537bb.tex").exists()
39+
40+
3641
def test_tex_whitespace_arg():
3742
"""Check that correct number of submobjects are created per string with whitespace separator"""
3843
separator = "\t"

0 commit comments

Comments
 (0)