Search code examples
djangopython-3.xescapingmathjaxmezzanine

Using local MathJax files with Django / Mezzanine


I would like to load MathJax in my base template with:

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
<script type="text/javascript"
  src="{% static "js/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" %}">
</script>

However in the rendered template the URL is returned as:

/static/js/MathJax/MathJax.js%3Fconfig%3DTeX-AMS-MML_HTMLorMML

and MathJax doesn't work.

If I hard-code the URL as src="/static/js/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" it works. How can I prevent Django/Mezzanine from escaping the ? and = characters? Is there an alternative approach?

[The reason I want to use a local MathJax is for development when I'm away from an internet connection; I use a CDN in production.]


Solution

  • I would try moving the config parameter outside the static reference and see if that helps:

    <script type="text/javascript"
      src="{% static "js/MathJax/MathJax.js" %}?config=TeX-AMS-MML_HTMLorMML">
    </script>
    

    I don't know Django or Mezzanine, but if the static is what is encoding the URL characters, moving them outside might prevent that.