From 6b822642913805192d3777236e39d87ae420b8c2 Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Tue, 30 Aug 2022 06:32:57 -0400 Subject: [PATCH] feat: support markdown style math tags (#12149) We can configure MathJax to detect the convention of single dollar signs in addition to its other methods, as it's not on by default. The inline script needs to be supported by our CSP, and if the stanza ever changes, we'll need to recalculate the hash and update the CSP accordingly. Resolves #12009 Resolves pypa/readme_renderer#214 Signed-off-by: Mike Fiedler Signed-off-by: Mike Fiedler Co-authored-by: Ee Durbin --- tests/unit/test_csp.py | 1 + warehouse/csp.py | 3 +++ warehouse/templates/packaging/detail.html | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/tests/unit/test_csp.py b/tests/unit/test_csp.py index a7d4aa942c5d..dbbb42a88c73 100644 --- a/tests/unit/test_csp.py +++ b/tests/unit/test_csp.py @@ -229,6 +229,7 @@ def test_includeme(): "'sha256-U3hKDidudIaxBDEzwGJApJgPEf2mWk6cfMWghrAa6i0='", "https://cdn.jsdelivr.net/npm/mathjax@3.2.2/", "'sha256-1CldwzdEg2k1wTmf7s5RWVd7NMXI/7nxxjJM2C4DqII='", + "'sha256-0POaN8stWYQxhzjKS+/eOfbbJ/u4YHO5ZagJvLpMypo='", ], "style-src": [ "'self'", diff --git a/warehouse/csp.py b/warehouse/csp.py index c90049d3bf48..ae1601da2d5d 100644 --- a/warehouse/csp.py +++ b/warehouse/csp.py @@ -115,6 +115,9 @@ def includeme(config): "https://cdn.jsdelivr.net/npm/mathjax@3.2.2/", # Hash for v3.2.2 of MathJax tex-svg.js "'sha256-1CldwzdEg2k1wTmf7s5RWVd7NMXI/7nxxjJM2C4DqII='", + # Hash for MathJax inline config + # See warehouse/templates/packaging/detail.html + "'sha256-0POaN8stWYQxhzjKS+/eOfbbJ/u4YHO5ZagJvLpMypo='", ], "style-src": [ SELF, diff --git a/warehouse/templates/packaging/detail.html b/warehouse/templates/packaging/detail.html index 9f913dd4f40f..3dc4960c6865 100644 --- a/warehouse/templates/packaging/detail.html +++ b/warehouse/templates/packaging/detail.html @@ -386,6 +386,13 @@

{% endblock %} {% block extra_js %} +