mirror of
https://git.freetards.xyz/array.in.a.matrix/TexLiLy.git
synced 2025-04-02 13:21:42 -04:00
[MOD] Touch up some prints
This commit is contained in:
parent
a73e9a2e5d
commit
bf6f537d21
2 changed files with 11 additions and 7 deletions
5
latex.py
5
latex.py
|
@ -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
13
main.py
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue