From 5c0232a5e0581c613cbb7fd34577ffa302d838f5 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Mon, 19 Dec 2022 16:20:19 -0800 Subject: [PATCH] Have LatexError show line of error and the next line This is where undefined control sequence errors will show up. --- manimlib/utils/tex_file_writing.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/manimlib/utils/tex_file_writing.py b/manimlib/utils/tex_file_writing.py index fd45262a..a6473572 100644 --- a/manimlib/utils/tex_file_writing.py +++ b/manimlib/utils/tex_file_writing.py @@ -113,14 +113,15 @@ def create_tex_svg(full_tex: str, svg_file: str, compiler: str) -> None: log.error( "LaTeX Error! Not a worry, it happens to the best of us." ) + error_str = "" with open(root + ".log", "r", encoding="utf-8") as log_file: - error_match_obj = re.search(r"(?<=\n! ).*", log_file.read()) + error_match_obj = re.search(r"(?<=\n! ).*\n.*\n", log_file.read()) if error_match_obj: + error_str = error_match_obj.group() log.debug( - "The error could be: `%s`", - error_match_obj.group() + f"The error could be:\n`{error_str}`", ) - raise LatexError() + raise LatexError(error_str) # dvi to svg os.system(" ".join((