diff --git a/web/src/message_notifications.js b/web/src/message_notifications.js
index f9f6bde815..b40da13d72 100644
--- a/web/src/message_notifications.js
+++ b/web/src/message_notifications.js
@@ -19,6 +19,7 @@ function get_notification_content(message) {
// Convert the content to plain text, replacing emoji with their alt text
const $content = $("
").html(message.content);
ui_util.replace_emoji_with_text($content);
+ ui_util.change_katex_to_raw_latex($content);
spoilers.hide_spoilers_in_notification($content);
if (
diff --git a/web/src/ui_util.ts b/web/src/ui_util.ts
index fb6efba3ac..c1f3f2428e 100644
--- a/web/src/ui_util.ts
+++ b/web/src/ui_util.ts
@@ -30,6 +30,20 @@ export function replace_emoji_with_text($element: JQuery): void {
});
}
+export function change_katex_to_raw_latex($element: JQuery): void {
+ // Find all the span elements with the class "katex"
+ $element.find("span.katex").each(function () {
+ // Find the text within the
tag
+ const latex_text = $(this).find('annotation[encoding="application/x-tex"]').text();
+
+ // Create a new element with the raw latex wrapped in $$
+ const $latex_span = $("").text("$$" + latex_text + "$$");
+
+ // Replace the current .katex element with the new containing the text
+ $(this).replaceWith($latex_span);
+ });
+}
+
export function blur_active_element(): void {
// this blurs anything that may perhaps be actively focused on.
if (document.activeElement instanceof HTMLElement) {
diff --git a/web/tests/notifications.test.js b/web/tests/notifications.test.js
index 47590cd2fd..15bc318463 100644
--- a/web/tests/notifications.test.js
+++ b/web/tests/notifications.test.js
@@ -340,6 +340,7 @@ test("message_is_notifiable", () => {
test("basic_notifications", () => {
$("").set_find_results(".emoji", {replaceWith() {}});
+ $("
").set_find_results("span.katex", {each() {}});
let n; // Object for storing all notification data for assertions.
let last_closed_message_id = null;