/********************************************************************* * * mj-page-svg.js * * Implements an API to MathJax in node.js so that MathJax can be * used server-side to generate SVG, MathML, or images (the latter * requires an external library, batik, to do the svg to png * conversion). This API accepts HTML snippets that have their * math content converted to SVG's. * * ---------------------------------------------------------------------- * * Copyright (c) 2014 The MathJax Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var http = require('http'); var fs = require('fs'); var path = require('path'); var url = require('url'); var fmt = require('util').format; var jsdom = require('jsdom').jsdom; var execFile = require('child_process').execFile; var speech = require('speech-rule-engine'); var os = require('os'); require('./patch/jsdom.js').patch(jsdom); // Fix some bugs in jsdom var displayMessages = false; // don't log Message.Set() calls var displayErrors = true; // show error messages on the console var undefinedChar = false; // unknown characters are not saved in the error array var extensions = ''; // no additional extensions used var fontURL = 'https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS'; // location of web fonts for CHTML var defaults = { ex: 6, // ex-size in pixels width: 100, // width of container (in ex) for linebreaking and tags useFontCache: true, // use and in svg output? useGlobalCache: true, // use common for all equations? linebreaks: false, // do linebreaking? equationNumbers: "none", // or "AMS" or "all" singleDollars: true, // allow single-dollar delimiter for inline TeX? html: "", // the HTML snippet to process xmlns: "mml", // the namespace to use for MathML inputs: ["AsciiMath","TeX","MathML"], // the inputs formats to support renderer: "SVG", // the output format // ("SVG", "NativeMML", "IMG", "PNG", or "None") dpi: 144, // dpi for png image addPreview: false, // turn turn into a MathJax preview, and keep the jax removeJax: true, // remove MathJax