aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/evergreen/latex.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/bot/exts/evergreen/latex.py b/bot/exts/evergreen/latex.py
index a8ed56fb..7cc3432f 100644
--- a/bot/exts/evergreen/latex.py
+++ b/bot/exts/evergreen/latex.py
@@ -36,18 +36,17 @@ class Latex(commands.Cog):
def _render(text: str) -> BytesIO:
"""Return the rendered image if latex compiles without errors, otherwise raise a BadArgument Exception."""
fig = plt.figure()
+ rendered_image = BytesIO()
+ fig.text(0, 1, text, horizontalalignment="left", verticalalignment="top")
try:
- fig.text(0, 1, text, horizontalalignment="left", verticalalignment="top")
-
- rendered_image = BytesIO()
plt.savefig(rendered_image, bbox_inches="tight", dpi=600)
- rendered_image.seek(0)
- return rendered_image
-
except ValueError as e:
raise commands.BadArgument(str(e))
+ rendered_image.seek(0)
+ return rendered_image
+
@staticmethod
def _prepare_input(text: str) -> str:
text = text.replace(r"\\", "$\n$") # matplotlib uses \n for newlines, not \\