From ab470c3ee598e335c4f2252a8802d71a8cc59e93 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Mon, 19 Dec 2022 16:19:43 -0800 Subject: [PATCH] Move display_during_exection associated with Latex rendering Only have it display when a new SVG is being written --- manimlib/mobject/svg/mtex_mobject.py | 8 +++----- manimlib/mobject/svg/tex_mobject.py | 8 +++----- manimlib/utils/tex_file_writing.py | 3 ++- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/manimlib/mobject/svg/mtex_mobject.py b/manimlib/mobject/svg/mtex_mobject.py index fdf33663..dda35e9b 100644 --- a/manimlib/mobject/svg/mtex_mobject.py +++ b/manimlib/mobject/svg/mtex_mobject.py @@ -3,7 +3,6 @@ from __future__ import annotations import re from manimlib.mobject.svg.string_mobject import StringMobject -from manimlib.utils.tex_file_writing import display_during_execution from manimlib.utils.tex_file_writing import tex_content_to_svg_file from typing import TYPE_CHECKING @@ -79,10 +78,9 @@ class MTex(StringMobject): ) def get_file_path_by_content(self, content: str) -> str: - with display_during_execution(f"Writing \"{self.tex_string}\""): - file_path = tex_content_to_svg_file( - content, self.template, self.additional_preamble - ) + file_path = tex_content_to_svg_file( + content, self.template, self.additional_preamble + ) return file_path # Parsing diff --git a/manimlib/mobject/svg/tex_mobject.py b/manimlib/mobject/svg/tex_mobject.py index 8883edd0..2101163c 100644 --- a/manimlib/mobject/svg/tex_mobject.py +++ b/manimlib/mobject/svg/tex_mobject.py @@ -11,7 +11,6 @@ from manimlib.constants import MED_LARGE_BUFF, SMALL_BUFF from manimlib.mobject.geometry import Line from manimlib.mobject.svg.svg_mobject import SVGMobject from manimlib.mobject.types.vectorized_mobject import VGroup -from manimlib.utils.tex_file_writing import display_during_execution from manimlib.utils.tex_file_writing import tex_content_to_svg_file from typing import TYPE_CHECKING @@ -86,10 +85,9 @@ class SingleStringTex(SVGMobject): def get_file_path(self) -> str: content = self.get_tex_file_body(self.tex_string) - with display_during_execution(f"Writing \"{self.tex_string}\""): - file_path = tex_content_to_svg_file( - content, self.template, self.additional_preamble - ) + file_path = tex_content_to_svg_file( + content, self.template, self.additional_preamble + ) return file_path def get_tex_file_body(self, tex_string: str) -> str: diff --git a/manimlib/utils/tex_file_writing.py b/manimlib/utils/tex_file_writing.py index 35304b9e..fd45262a 100644 --- a/manimlib/utils/tex_file_writing.py +++ b/manimlib/utils/tex_file_writing.py @@ -78,7 +78,8 @@ def tex_content_to_svg_file( ) if not os.path.exists(svg_file): # If svg doesn't exist, create it - create_tex_svg(full_tex, svg_file, compiler) + with display_during_execution(f"Writing \"{content}\""): + create_tex_svg(full_tex, svg_file, compiler) return svg_file