Using MathJax v2 script tags

This file demonstrates a configuration that locates <script> tags like the ones used in MathJax v2 to mark the mathematics within the page.

This example shows how to process a complete HTML page containing MathJax version 2 styled <script> tags (that store the math content in the page). In version 2, these tags are generated automatically by the tex2jax or other pre-processors, but they could also be created by other software that generates the page so as to avoid the need for the pre-processing step, and the need for quoting HTML special characters like less-than signs and ampersands.

MathJax version 4 does not look for such <script> tags itself, but you can implement it yourself, as in this example.

The key lines are in the renderAction in the MathJax configuration, as described in the comments there. The renderAction replaces the usual page-search action (the find action at priority 10) with one that searches for <script> tags with type="math/tex" (or type="math/tex; mode=display"), and creates the needed MathItem instances for them. The <script> tags are replaced by empty text nodes, and the math items refers to these for their starting and ending locations.