[MOD] Touch up some prints

This commit is contained in:
LoaD Accumulator 2023-06-12 17:47:21 +02:00
parent a73e9a2e5d
commit bf6f537d21
No known key found for this signature in database
GPG key ID: 6898757653ABE3E6
2 changed files with 11 additions and 7 deletions

View file

@ -1,7 +1,8 @@
# Converts a TeX file into a PNG/SVG file.
template = r"""
\documentclass{{standalone}}
\documentclass[utf8]{{standalone}}
\usepackage{{amsmath}}
\usepackage[utf8]{{inputenc}}
% TODO: Add user packages here.
\begin{{document}}
% The user content goes here.
@ -24,7 +25,7 @@ def render(user: str, source: str, png: bool = True) -> str:
# Parse our templated file thru' LaTeX and dvipng.
# TODO: Allow arbitrary DPI and foreground color.
ret = subprocess.run(["latex", "-halt-on-error", tmp.name], cwd="/tmp").returncode
if ret is not 0:
if ret != 0:
raise FileNotFoundError("DVI couldn't be built.")
if png:

13
main.py
View file

@ -50,6 +50,8 @@ async def msg_cb(room: MatrixRoom, event: RoomMessageText) -> None:
await client.room_send(room.room_id, message_type="m.room.message", content=content)
# Our file callback.
async def file_cb(room: MatrixRoom, event: RoomMessageFile) -> None:
url = event.url
filename = event.body
@ -68,13 +70,14 @@ async def main() -> None:
user = str(config["user"])
token = str(config["token"])
# path = str(config["path"]) # not used
# if config file does not exist, quit
# if config file does not exist, quit
except FileNotFoundError:
print("No config file found.\nPlease create a file named `texlily.yaml` and read the README file.")
quit()
print("No config file found.")
print("Please create a file named `texlily.yaml` and read the README file.")
quit()
except TypeError:
print("Invalid configuration file.")
quit()
print("Invalid configuration file.")
quit()
client = AsyncClient(homeserver)
client.access_token = token