MathJax and HTML
How it works
If you convert your document to HTML using the HTML converter, and the
stem document attribute is set on your document, the HTML will be configured to automatically load MathJax into the page from a CDN.
There’s nothing you have to install.
Specifically, it loads the MathJax bundle that includes support for both TeX and AsciiMath, as shown here:
After the page loads, MathJax scans for expressions inside special delimiters and transforms them into a displayable format. You may notice a brief flash of the expression in source form while this is happening.
Here’s an example of a STEM expression written in AsciiMath and rendered by MathJax.
If you right click on the rendered expression, you’ll notice its interactive. One of the options even allows you to view the original AsciiMath input.
The delimiters that the HTML converter places around the expressions to tell MathJax what to process are not the same as the ones MathJax looks for by default. These custom delimiters were chosen to avoid conflicts with other syntax in the AsciiDoc language.
The converter configures MathJax to look for the custom delimiters it emits. If you look at the HTML source, you’ll see a text/x-mathjax-config stanza that defines them, as well as some other settings.
The MathJax integration is currently only designed for HTML output. When converting to other backend formats, additional libraries are needed. A good alternative is Asciidoctor Mathematical.