Skip to content

Commit 79a2033

Browse files
authored
Configure le bon chemin pour les extensions MathJax (#6691)
1 parent d38b46a commit 79a2033

File tree

3 files changed

+42
-40
lines changed

3 files changed

+42
-40
lines changed

templates/base.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,5 @@ <h2 class="subtitle" {% if schema %}itemprop="description"{% endif %}>{{ headlin
248248
{% block extra_js %}
249249
{% endblock %}
250250
<script src="{% static "js/script.js" %}"></script>
251-
252-
{% include "mathjax_config.html" %}
253251
</body>
254252
</html>

templates/mathjax.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
11
{% load static %}
2+
3+
<script type="text/x-mathjax-config">
4+
MathJax.Hub.Config({
5+
root: "/static/js",
6+
tex2jax: {
7+
inlineMath: [['$', '$']],
8+
displayMath: [['$$','$$']],
9+
processEscapes: true,
10+
processClass: "mathjax-wrapper|mathjax-span",
11+
ignoreClass: "page-container"
12+
},
13+
TeX: { extensions: ["color.js", "cancel.js", "enclose.js", "bbox.js", "mathchoice.js", "newcommand.js", "verb.js", "unicode.js", "autobold.js", "mhchem.js"] },
14+
messageStyle: "none",
15+
});
16+
</script>
17+
18+
<script type="application/javascript">
19+
// When the page has been loaded (which means the DOM and Mathjax has been loaded)
20+
window.addEventListener("load", function() {
21+
22+
// We look for <span> inside contents
23+
$(".message-content span, .article-content span").each(function () {
24+
// We only want those with no CSS class
25+
if($(this).attr("class") === undefined) {
26+
var text = $(this).text();
27+
// We check that they start with $ and end with $
28+
if (text && text[0] == "$" && text[text.length - 1] == "$") {
29+
// We add a class to mark them
30+
$(this).addClass("mathjax-span");
31+
}
32+
}
33+
});
34+
35+
// If there is content waiting for Mathjax
36+
if($(".mathjax-span, .mathjax-wrapper").length) {
37+
// We run Mathjax
38+
MathJax.Hub.Configured();
39+
}
40+
41+
});
42+
</script>
43+
244
<script src="{% static "js/MathJax.js" %}?locale=fr&config=TeX-AMS_HTML&delayStartupUntil=configured" async></script>

templates/mathjax_config.html

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)