Using MathJax and PhantomJS to create SVGs and MathML server side with minimum overhead.
JavaScript Ruby Shell
Pull request Compare This branch is 2221 commits ahead, 11 commits behind agrbin:master.
Latest commit c5e12f8 Aug 2, 2017 jenkins-bot committed with Gerrit Code Review Merge "jshint use es6"
Failed to load latest commit information.
debian Update debian release notes Aug 2, 2015
dist Add the Dockerfile to be used in Kubernetes Jun 2, 2017
lib Update to service-template-node v0.4.0 Jul 21, 2016
test Update to service-template-node v0.4.0 Jul 21, 2016
.dockerignore Add a simple Dockerfile Feb 24, 2015
.gitignore Add the Dockerfile to be used in Kubernetes Jun 2, 2017
.gitreview Add debian package description Mar 6, 2015
.jshintignore Update to service-template-node v0.2.2 Oct 20, 2015
.jshintrc jshint use es6 Jul 17, 2017
.travis.yml Test node 6 & latest Oct 31, 2016
LICENSE Initial commit Feb 16, 2015
Makefile.ignore Add debian package description Mar 6, 2015
app.js Update to service-template-node v0.4.0 Jul 21, 2016 Update to service-template-node v0.4.0 Jul 21, 2016
config.yaml Small improvements May 17, 2015
server.js Update to service-template-node v0.4.0 Jul 21, 2016
spec.yaml Put the mathoid-style headers to the complete endpoint response as well Feb 16, 2016
targets.yaml Add deploy-related config and remove docker.js Apr 21, 2015


Build Status dependency status dev dependency status Coverage Status


Mathoid-server is a service that uses MathJax to create SVGs and MathML on server side. Mathoid-server is a based on svgtex -


Install node 6.9.0 or a compatible node version. In addition the prerequisites from librsvg are needed. For Debian based systems installing the librsvg2-dev should be sufficient.

sudo apt-get install librsvg2-dev

Thereafter, install mathoid by running

npm install mathoid
node /node_modules/mathoid/server.js

To install mathoid as a unix service there is a script.

Running the tests

To run the tests you need to install mocha. After that you can run the tests from the mathoid folder.

npm test

API Description

The main entry point is '/' with one required POST parameter 'q'.

Additional entry points for individual formats are

  • /texvcinfo does not do any rendering. Only displays information regarding the texvc input.
  • /speech returns the speech output only
  • /mml only MathML
  • /svg only SVG
  • /png only PNG
  • /json (same as /)
  • /complete (see below)

The 'complete' output format is equal to the 'json' one except that it also includes the headers for individual types in the response body as well. The output specification is identical, except that the 'mml', 'svg' and 'png' fields are now (JSON) objects containing the 'body' and 'headers' fields.

q (input to be converted)

  • required parameter
  • no $ for (La)TeX input

type (the input type)

  • optional
  • defalult 'tex'
  • possible values
    • tex (texvc input will be verified by texvccheck)
    • inline-tex (texvc input will be rendered with small operators)
    • mml (MathML input, used in latexml rendering mode)
    • ascii (ascii mathml input, experimental)


  • optional
  • if speech output is enabled this switch suppresses speech output for one particular request


  • svg: creates and svg image (turned on by default)
  • img: creates a img element with dimension information about the svg image
  • png: creates png images using java
  • speech: creates speech output using speech rule engine
  • texvcinfo: displays information regarding the texvc input (experimental)
  • speechOn: default setting for speech output. 'true' is equivalent to the old speakText.


The performance tests can be run by executing the script.

On our labs-vagrant test instance with 8 workers and 100 request the following results were obtained for the input $E = m c^2$:

format time sd
texvcinfo 0005 003.2
mml 0334 061.2
svg 0343 058.6
png 0027 007.2
format (without speech support) time sd
texvcinfo 0005 003.0
mml 0030 004.5
svg 0030 004.2
png 0030 005.7
The time, i.e. "Total Connection Times" were measured in unit ms.

Create a new release

Checkout the latest version and switch to the master branch:

  • git-dch -R -N version
  • git-buildpackage --git-tag -S

see also

publish as ppa

  • dput ppa:physikerwelt/mathoid ../version.changes


Based on the Template for creating MediaWiki Services in Node.js The template also includes a test suite a small set of executable tests. To fire them up, simply run:

npm test

If you haven't changed anything in the code (and you have a working Internet connection), you should see all the tests passing. As testing most of the code is an important aspect of service development, there is also a bundled tool reporting the percentage of code covered. Start it with:

npm run-script coverage


In a lot of cases when there is an issue with node it helps to recreate the node_modules directory:

rm -r node_modules
npm install