Skip to content
Advertisement

Preview Text with MathJax Using async

Below is an example of a text preview using jQuery.

I would have thought inserting the following snippet in the third line would preview MathJax.

JavaScript

I am confused why adding this portion does not convert LaTeX. How can I activate MathJax to make it convert the message below in only the preview below? I have seen other examples of this working online, and I feel like I am missing something.

JavaScript

Advertisement

Answer

Admittedly, this took longer than I would have liked.

edit some background:

I think how math jax works is that it will render all configured dom nodes once, on page load. To render dynamically, you will need to call the relevant dynamic typeset functions (see below)

MathJax < v3

use MathJax.Hub.Queue as in this SO post

MathJax v3 or above (per post’s requirement) read on:

It seems you will need to use the new typesetting API per mathjax v3 doc:

I don’t know much mathML, but I tried with LaTeX $$M_1$$ seems to produce the correct output

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement