diff options
| author | Bobby <[email protected]> | 2023-03-06 07:12:39 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2023-03-06 07:12:39 -0500 |
| commit | f2424b1dc1f2c5ad1cc339747fd8f253f7a3201c (patch) | |
| tree | d228e4f03ff75ca3e3c8e6e95d3678ac4601094f | |
| parent | 0d9d268b3b581d10d96ff9991e31ecdcaf56e771 (diff) | |
| download | thatcomputerscientist-f2424b1dc1f2c5ad1cc339747fd8f253f7a3201c.tar.xz thatcomputerscientist-f2424b1dc1f2c5ad1cc339747fd8f253f7a3201c.zip | |
Added Local MathJax Configuration
| -rw-r--r-- | .gitmodules | 3 | ||||
| m--------- | static/js/MathJax | 0 | ||||
| -rw-r--r-- | templates/blog/activity.html | 34 | ||||
| -rw-r--r-- | templates/blog/home.html | 30 | ||||
| -rw-r--r-- | templates/blog/post.html | 30 |
5 files changed, 90 insertions, 7 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..09a0cde3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "static/js/MathJax"] + path = static/js/MathJax + url = https://github.com/mathjax/MathJax.git diff --git a/static/js/MathJax b/static/js/MathJax new file mode 160000 +Subproject 6273842a9746731b9ecca0de18ec9fd50a36df9 diff --git a/templates/blog/activity.html b/templates/blog/activity.html index 7c24fb4a..dce9256f 100644 --- a/templates/blog/activity.html +++ b/templates/blog/activity.html @@ -52,6 +52,38 @@ {% endif %} </div> - +<script type="text/javascript" src="{% static 'js/MathJax/MathJax.js' %}?config=TeX-AMS-MML_HTMLorMML-full"> +</script> +<script type="text/x-mathjax-config"> + MathJax.Hub.Register.StartupHook("End Jax",function () { + var BROWSER = MathJax.Hub.Browser; + + var canUseMML = (BROWSER.isFirefox && BROWSER.versionAtLeast("1.5")) || + (BROWSER.isMSIE && BROWSER.hasMathPlayer) || + (BROWSER.isSafari && BROWSER.versionAtLeast("5.0")) || + (BROWSER.isOpera && BROWSER.versionAtLeast("9.52") && + !BROWSER.versionAtLeast("14.0")); + + var CONFIG = MathJax.Hub.CombineConfig("MMLorHTML",{ + prefer: { + MSIE:"MML", Firefox:"HTML", Opera:"HTML", Chrome:"HTML", Safari:"HTML", + other:"HTML" + } + }); + + var jax = CONFIG.prefer[BROWSER] || CONFIG.prefer.other; + if (jax === "HTML") jax = "HTML-CSS"; else if (jax === "MML") jax = "NativeMML"; + if (jax === "NativeMML" && !canUseMML) jax = CONFIG.prefer.other; + return MathJax.Hub.setRenderer(jax); + }); + MathJax.Hub.Config({ + "tex2jax": { + "inlineMath": [['$','$'], ['\\(','\\)']], + }, + "fast-preview": { + disabled: true + } + }); +</script> {% endblock %} diff --git a/templates/blog/home.html b/templates/blog/home.html index ee158897..e07440a4 100644 --- a/templates/blog/home.html +++ b/templates/blog/home.html @@ -71,12 +71,36 @@ </div> {% endfor %} </div> -<script type="text/javascript" src="http{% if request.is_secure %}s{% endif %}://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full"> +<script type="text/javascript" src="{% static 'js/MathJax/MathJax.js' %}?config=TeX-AMS-MML_HTMLorMML-full"> </script> <script type="text/x-mathjax-config"> + MathJax.Hub.Register.StartupHook("End Jax",function () { + var BROWSER = MathJax.Hub.Browser; + + var canUseMML = (BROWSER.isFirefox && BROWSER.versionAtLeast("1.5")) || + (BROWSER.isMSIE && BROWSER.hasMathPlayer) || + (BROWSER.isSafari && BROWSER.versionAtLeast("5.0")) || + (BROWSER.isOpera && BROWSER.versionAtLeast("9.52") && + !BROWSER.versionAtLeast("14.0")); + + var CONFIG = MathJax.Hub.CombineConfig("MMLorHTML",{ + prefer: { + MSIE:"MML", Firefox:"HTML", Opera:"HTML", Chrome:"HTML", Safari:"HTML", + other:"HTML" + } + }); + + var jax = CONFIG.prefer[BROWSER] || CONFIG.prefer.other; + if (jax === "HTML") jax = "HTML-CSS"; else if (jax === "MML") jax = "NativeMML"; + if (jax === "NativeMML" && !canUseMML) jax = CONFIG.prefer.other; + return MathJax.Hub.setRenderer(jax); + }); MathJax.Hub.Config({ - tex2jax: { - inlineMath: [['$','$'], ['\\(','\\)']], + "tex2jax": { + "inlineMath": [['$','$'], ['\\(','\\)']], + }, + "fast-preview": { + disabled: true } }); </script> diff --git a/templates/blog/post.html b/templates/blog/post.html index 67231db3..80c7d625 100644 --- a/templates/blog/post.html +++ b/templates/blog/post.html @@ -109,12 +109,36 @@ <p><em>You must be logged in to leave a comment.</em></p> </div> {% endif %} -<script type="text/javascript" src="http{% if request.is_secure %}s{% endif %}://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS-MML_HTMLorMML-full"> +<script type="text/javascript" src="{% static 'js/MathJax/MathJax.js' %}?config=TeX-AMS-MML_HTMLorMML-full"> </script> <script type="text/x-mathjax-config"> + MathJax.Hub.Register.StartupHook("End Jax",function () { + var BROWSER = MathJax.Hub.Browser; + + var canUseMML = (BROWSER.isFirefox && BROWSER.versionAtLeast("1.5")) || + (BROWSER.isMSIE && BROWSER.hasMathPlayer) || + (BROWSER.isSafari && BROWSER.versionAtLeast("5.0")) || + (BROWSER.isOpera && BROWSER.versionAtLeast("9.52") && + !BROWSER.versionAtLeast("14.0")); + + var CONFIG = MathJax.Hub.CombineConfig("MMLorHTML",{ + prefer: { + MSIE:"MML", Firefox:"HTML", Opera:"HTML", Chrome:"HTML", Safari:"HTML", + other:"HTML" + } + }); + + var jax = CONFIG.prefer[BROWSER] || CONFIG.prefer.other; + if (jax === "HTML") jax = "HTML-CSS"; else if (jax === "MML") jax = "NativeMML"; + if (jax === "NativeMML" && !canUseMML) jax = CONFIG.prefer.other; + return MathJax.Hub.setRenderer(jax); + }); MathJax.Hub.Config({ - tex2jax: { - inlineMath: [['$','$'], ['\\(','\\)']], + "tex2jax": { + "inlineMath": [['$','$'], ['\\(','\\)']], + }, + "fast-preview": { + disabled: true } }); </script> |
