From a393f8394b84450f4f80882b66976a0fb6c8b22c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-S=C3=A9bastien=20Caux?= <git@jscaux.org>
Date: Wed, 27 Oct 2021 07:06:34 +0200
Subject: [PATCH] Ensure MathJax runs after HTMX settles

---
 scipost_django/scipost/templates/scipost/bare_base.html | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scipost_django/scipost/templates/scipost/bare_base.html b/scipost_django/scipost/templates/scipost/bare_base.html
index 5e59a7b77..c949e0ab9 100644
--- a/scipost_django/scipost/templates/scipost/bare_base.html
+++ b/scipost_django/scipost/templates/scipost/bare_base.html
@@ -41,6 +41,12 @@
     <script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML,Safe"></script>
 
     {% block footer_script %}
+      <script nonce="{{ request.csp_nonce }}">
+       document.body.addEventListener('htmx:afterSettle', function () {
+	   console.log('session-acad-field-set event')
+	   MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
+       })
+      </script>
     {% endblock footer_script %}
 
   </body>
-- 
GitLab