Disabling MathJax in Brightspace

Posted on Oct 1, 2025

The night before an early class, I discovered that Brightspace was cheating on me. I use HTML files generated outside BS for lab instructions, and normally BS presents them correctly. However, BS is also MathJax capable, i.e., if it sees LaTeX-style maths expressions, it displays them as maths. So if it sees \(\sqrt{2}\) it will present it as the square-root of two, properly typeset.

The catch is that BS is indiscriminate about where it sees the \( and \) pairs. It will typeset them as maths even if they’re marked as pre-formatted text or code. Given that I was preparing for a class on regular expressions in Julia, I had examples like this:

match(r"\([0-9]+\)", "01 (234) 4567")

This matches the (234) in the target, and the backslashes are needed to refer to literal parentheses (unescaped parentheses mark sub-matches).

BS was taking this, eating the slash-parentheses, and presenting the [0-9]+ as maths text.

This made nonsense of the example (and a few others), and destroyed my workflow: I can’t trust a system which corrupts my examples.

I have a vague recollection of changed a setting to turn on MathJax support in BS, but likely in an earlier version. I can’t find any option to enable or disable it in the current version. Searching online yields nothing relevant (and using AI to search yields what can best be described as speculation, certainly not useful information).

So I investigated. If you type “raw HTML” directly into BS (i.e., via its editor, clicking on the “code” icon), then <pre>\(\sqrt{2}\)</pre> remains uncorrupted, while outside the “pre” tags it is converted to maths. However, if you look at the code of the resulting page, the content is not HTML, but encoded in Javascript. The editor is not saving as HTML what you think you’re entering as HTML.

I tried stripping down the uploaded HTML. I finally got some traction by just uploading the contents of the <body> section. Somehow BS doesn’t know what to do with it, just serves up the content, and browsers do their best, rendering a default-style page with no meta-info. A bit too raw for me though.

So I looked at the HTML of the page BS serves, to compare it with the uploaded HTML. The key difference is the insertion of a load of Javascript in the <head> section. What seems to be the key relevant detail is the creation of an EventListener keyed on the DOMContentLoaded event. It might be possible to amend this to de-activate MathJax in preformatted text, but I don’t know enough Javascript to do it (or know if it’s possible). What you can do, however, is pre-empt this event listener by creating one (keyed on the same event) in the <head> section of the HTML file. BS will retain this, thereby blocking its own version. The BS code is wrapped in a conditional, and does various things including setting a renderLatex attribute to true), but I find if it’s stripped down to the following it disables MathJax:

<script>
    document.addEventListener('DOMContentLoaded', function() {
        window.D2L.MathJax.loadMathJax({
            renderLatex: false
        });
    });
</script>

So if you insert this code in the <head> of the HTML file, upload it to BS and get it to serve it, MathJax is disabled in that file.

I’m using Emacs’ org-mode to write this material and export it to HTML, and I can include this Javascript by turning it into a one-liner and adding the following to the top of the org file:

#+HTML_HEAD: <script>document.addEventListener('DOMContentLoaded', function() { window.D2L.MathJax.loadMathJax({ renderLatex: false });});</script>

Other methods of creating HTML files will offer other ways of doing this. But at least now I have a way of presenting my escaped parentheses to students correctly (even if it cost me a few hours sleep before an early class).