Skip to content

Commit

Permalink
Configure le bon chemin pour les extensions MathJax (#6691)
Browse files Browse the repository at this point in the history
  • Loading branch information
Situphen authored Dec 15, 2024
1 parent d38b46a commit 79a2033
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 40 deletions.
2 changes: 0 additions & 2 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,5 @@ <h2 class="subtitle" {% if schema %}itemprop="description"{% endif %}>{{ headlin
{% block extra_js %}
{% endblock %}
<script src="{% static "js/script.js" %}"></script>

{% include "mathjax_config.html" %}
</body>
</html>
42 changes: 42 additions & 0 deletions templates/mathjax.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,44 @@
{% load static %}

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
root: "/static/js",
tex2jax: {
inlineMath: [['$', '$']],
displayMath: [['$$','$$']],
processEscapes: true,
processClass: "mathjax-wrapper|mathjax-span",
ignoreClass: "page-container"
},
TeX: { extensions: ["color.js", "cancel.js", "enclose.js", "bbox.js", "mathchoice.js", "newcommand.js", "verb.js", "unicode.js", "autobold.js", "mhchem.js"] },
messageStyle: "none",
});
</script>

<script type="application/javascript">
// When the page has been loaded (which means the DOM and Mathjax has been loaded)
window.addEventListener("load", function() {

// We look for <span> inside contents
$(".message-content span, .article-content span").each(function () {
// We only want those with no CSS class
if($(this).attr("class") === undefined) {
var text = $(this).text();
// We check that they start with $ and end with $
if (text && text[0] == "$" && text[text.length - 1] == "$") {
// We add a class to mark them
$(this).addClass("mathjax-span");
}
}
});

// If there is content waiting for Mathjax
if($(".mathjax-span, .mathjax-wrapper").length) {
// We run Mathjax
MathJax.Hub.Configured();
}

});
</script>

<script src="{% static "js/MathJax.js" %}?locale=fr&config=TeX-AMS_HTML&delayStartupUntil=configured" async></script>
38 changes: 0 additions & 38 deletions templates/mathjax_config.html

This file was deleted.

0 comments on commit 79a2033

Please sign in to comment.