aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/fun/latex/_latex_cog.py4
-rw-r--r--bot/exts/fun/latex/_renderer.py8
2 files changed, 7 insertions, 5 deletions
diff --git a/bot/exts/fun/latex/_latex_cog.py b/bot/exts/fun/latex/_latex_cog.py
index 239f499c..9ab85238 100644
--- a/bot/exts/fun/latex/_latex_cog.py
+++ b/bot/exts/fun/latex/_latex_cog.py
@@ -1,13 +1,12 @@
import asyncio
import hashlib
+import re
import sys
from pathlib import Path
-import re
import discord
from discord.ext import commands
-
FORMATTED_CODE_REGEX = re.compile(
r"(?P<delim>(?P<block>```)|``?)" # code delimiter: 1-3 backticks; (?P=block) only matches if it's a block
r"(?(block)(?:(?P<lang>[a-z]+)\n)?)" # if we're in a block, match optional language (only letters plus newline)
@@ -34,6 +33,7 @@ def _prepare_input(text: str) -> str:
class Latex(commands.Cog):
"""Renders latex."""
+
@commands.command()
@commands.max_concurrency(1, commands.BucketType.guild, wait=True)
async def latex(self, ctx: commands.Context, *, query: str) -> None:
diff --git a/bot/exts/fun/latex/_renderer.py b/bot/exts/fun/latex/_renderer.py
index 3f6528ad..fb72b94c 100644
--- a/bot/exts/fun/latex/_renderer.py
+++ b/bot/exts/fun/latex/_renderer.py
@@ -1,5 +1,4 @@
import sys
-
from pathlib import Path
from typing import BinaryIO
@@ -19,7 +18,9 @@ plt.rcParams.update(
def render(text: str, file_handle: BinaryIO) -> None:
"""
- Saves rendered image in `file_handle`. In case the input is invalid latex, it prints the error to `stderr`.
+ Saves rendered image in `file_handle`.
+
+ In case the input is invalid latex, it prints the error to `stderr`.
"""
fig = plt.figure()
fig.text(0, 1, text, horizontalalignment="left", verticalalignment="top")
@@ -30,9 +31,10 @@ def render(text: str, file_handle: BinaryIO) -> None:
sys.exit(err)
-def main():
+def main() -> None:
"""
Renders a latex query and saves the output in a specified file.
+
Expects two command line arguments: the query and the path to the output file.
"""
query = sys.argv[1]