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"
Permalink
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
doc/test_results
lib Update to service-template-node v0.4.0 Jul 21, 2016
routes
scripts
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
README.md
app.js Update to service-template-node v0.4.0 Jul 21, 2016
config.dev.yaml Update to service-template-node v0.4.0 Jul 21, 2016
config.prod.yaml
config.yaml Small improvements May 17, 2015
package.json
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

README.md

Mathoid-server

Build Status dependency status dev dependency status Coverage Status

NPM

Mathoid-server is a service that uses MathJax to create SVGs and MathML on server side. Mathoid-server is a based on svgtex - https://github.com/agrbin/svgtex.

Installation

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)

nospeech

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

Config

  • 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.

Performance

The performance tests can be run by executing the performance.sh 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 https://wikitech.wikimedia.org/wiki/Git-buildpackage

publish as ppa

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

Tests

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

Troubleshooting

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