MathJax v3 Developers Tools
Some developers tools for testing local MathJax v3 code base.
General setup
To run most scripts in the tools you need to connect to your current version of
MathJax3. Assuming that MathJax3 sources are at <MJ3-PATH> you need to link
in the JavaScript sources there:
ln -s <MJ3-PATH> mathjax3For the remainder we assume that this symlink has been set.
Getting the Lab to work
You need to install the MathJax context menu first:
nmp install mj-context-menuCreate a symbolic link for the context menu. MathJax expects it to be in parallel to its code.
ln -s node_modules/mj-context-menuThen run the lab by loading v3-lab.html in your webbrowser via a local
webserver. E.g., create a symbolic link
sudo ln -s <MathJax-dev-PATH> /var/www/html/Run the lab on localhost using the URL
http://localhost/MathJax-dev/v3-lab.htmlOr alternatively serve directly from the directory, i.e., by running a python server:
python -m SimpleHTTPServer 8000and then run the lab at the following URL
http://localhost:8000/v3-lab.htmlRunning Samples
Samples are small scripts to test various MathJax features or to use MathJax
directly for a specific purpose. They are particularly useful to work with local
MathJax variants or test changes to the code base directly. Samples can be run
using node or in a browser.
Running Samples in Node
Samples are run in node using the esm package on load. You need to first install esm by
npm install esmThe general command to run scripts is then:
node -r esm samples/<SCRIPT>.js <INPUT>As example consider the script to parse LaTeX expressions into MathML:
node -r esm samples/tex2mml.js x^2<math display="block">
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
</math>Running Samples in a Browser
Samples can be run in the browser using the load.html page. This either loads
the main.js file or the particular sample file given in the parameters. For example, running
http://localhost/v3-dev/load.html?samples/asciimath-document.js
will give you a rendered page of AsciiMath expressions in the browser. Note, that the output will also be displayed on the console. In fact, many scripts will only produce console output. For example, the URL:
http://localhost/v3-dev/load.html?samples/tex2mml.js&x^2
will print the corresponding MathML expression in the console:
<math display="block">
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
</math>Scripts
Sample names should be self-explanatory.
samples/asciimath-document.js
samples/asciimath-json.js
samples/asciimath2mml-component.js
samples/asciimath2mml.js
samples/asyncLoad.js
samples/bits.js
samples/css.js
samples/find-asciimath.js
samples/find-mml.js
samples/find-strings.js
samples/find-tex-dollars.js
samples/find-tex.js
samples/html-full.js
samples/mfenced.js
samples/mml-bbox.js
samples/mml-nodes.js
samples/mml2html.js
samples/mml2svg.js
samples/notagids.js
samples/tag-format.js
samples/tex-document.js
samples/tex-json.js
samples/tex-multi-document.js
samples/tex-nodes.js
samples/tex-string.js
samples/tex2html.js
samples/tex2mml-component.js
samples/tex2mml-require.js
samples/tex2mml-speech.js
samples/tex2mml.js
samples/tex2svg-speech.js
samples/tex2svg.jsThe following two scripts need jsdom package for testing:
samples/test-adaptor.js
samples/test-styles.jsTests
All tests are located in the ./tests/ directory. We use
Jest as test framework.
Running Tests
Just go to the ./tests/ directory and run the following two commands:
npm install
npm testTeX parser tests in particular are run with the command:
npx jest src/parser.test.jsTo only test a single file run
npx jest src/parser.test.js json/FILE.jsonTests initially run against mathjax-full package. They can be run against your
local repository by rerouting the js and es5 directories.
Test Format
Tests are provided in a JSON test format.
{
"name": NameOfTest,
"factory": TestFactory,
"tests": {
"TEST1": {
"input": INPUT
"expected": EXPECTED
...rest
}
...more tests
}
}
To add new tests, simply add a new .json file in the json sub-directory. For
new test classes add a new entry in src/test-factory.js.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
