Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #6690: Configure le bon chemin pour les extensions MathJax #6691

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.