From 1d651b3bb2e2552a7340dfb1ef705161cfa44998 Mon Sep 17 00:00:00 2001
From: Teknium <127238744+teknium1@users.noreply.github.com>
Date: Wed, 9 Sep 2026 04:40:46 -0700
Subject: [PATCH] feat(matrix): render LaTeX in the standalone (cron) sender
too
_standalone_send builds formatted_body through its own markdown call and
never went through _markdown_to_html, so cron-delivered equations still
arrived as raw dollars. Tokenize/expand around that conversion as well.
---
plugins/platforms/matrix/adapter.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/plugins/platforms/matrix/adapter.py b/plugins/platforms/matrix/adapter.py
index 08e4db0902..9b3f5ff8b1 100644
--- a/plugins/platforms/matrix/adapter.py
+++ b/plugins/platforms/matrix/adapter.py
@@ -2924,9 +2924,11 @@ async def _standalone_send(pconfig, chat_id, message, *, thread_id=None, media_f
payload = {"msgtype": "m.text", "body": message}
with suppress(ImportError):
import markdown as _md
- html = _md.markdown(message, extensions=["fenced_code", "tables"])
+ tokenized, tex_store = _latex_to_tokens(message)
+ html = _md.markdown(tokenized, extensions=["fenced_code", "tables"])
payload["format"] = "org.matrix.custom.html"
- payload["formatted_body"] = re.sub(r"(.*?)", r"\1", html)
+ payload["formatted_body"] = _tokens_to_mx_maths(
+ re.sub(r"(.*?)", r"\1", html), tex_store)
# asyncio.wait_for, not aiohttp.ClientTimeout: cron invokes this via
# run_coroutine_threadsafe ("Timeout context manager should be used inside a task").
async with aiohttp.ClientSession() as session: