From 5a15bd47b655392892c9f135fb54b01d5570dee5 Mon Sep 17 00:00:00 2001 From: Justin Tracey Date: Sun, 4 Sep 2022 20:06:20 -0400 Subject: [PATCH] Prevent escaping math mode --- tex.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tex.py b/tex.py index a7587c2..a6eb4fb 100644 --- a/tex.py +++ b/tex.py @@ -51,8 +51,12 @@ async def start(self) -> None: @command.new(name=lambda self: self.config["command"], help="Render LaTeX") @command.argument("formula", required=True, pass_raw=True) async def tex(self, evt: MessageEvent, formula: str) -> None: + # prevent escaping math mode + # (' ' prevents unexpected interactions, and isn't rendered) + formula = formula.replace("$", " \\$") + fig = plot.figure(figsize=(0.01, 0.01)) - text = fig.text(0, 0, rf"${formula}$", + text = fig.text(0, 0, rf"$ {formula} $", fontsize=self.config["font_size"], usetex=self.config["use_tex"]) info = ImageInfo(thumbnail_info=ThumbnailInfo())