diff --git a/.travis.yml b/.travis.yml index bb650cbf..6ec03494 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ node_js: - '7' - '8' - '9' +- '10' - stable sudo: false script: diff --git a/lib/main.js b/lib/main.js index aac703e1..073a9e94 100644 --- a/lib/main.js +++ b/lib/main.js @@ -74,7 +74,8 @@ var STATE = { STOPPED: 1, // no DOM or MathJax available STARTED: 2, // DOM loaded, MathJax starting up READY: 3, // MathJax initialized and ready to process math - BUSY: 4 // MathJax currently processing math + BUSY: 4, // MathJax currently processing math + RESTART: 5, // start() called while MathJax is starting up }; // @@ -91,6 +92,7 @@ var document, window, content, html; // the DOM elements var queue = []; // queue of typesetting requests of the form [data,callback] var data, callback, originalData; // the current queue item var errors = []; // errors collected durring the typesetting +var sErrors = []; // errors collected durring MathJax startup var ID = 0; // id for this SVG element // @@ -518,8 +520,15 @@ function ConfigureMathJax() { MathJax.Hub.Register.StartupHook("End",function () { if (MathJax.OutputJax.SVG.resetGlyphs) MathJax.OutputJax.SVG.resetGlyphs(true); MathJax.ElementJax.mml.ID = 0; - serverState = STATE.READY; - MathJax.Hub.Queue(StartQueue); + if (serverState === STATE.RESTART) { + setTimeout(RestartMathJax, 100); + } else { + serverState = STATE.READY; + MathJax.Hub.Queue( + function () {sErrors = errors}, + StartQueue + ); + } }); } }; @@ -528,7 +537,7 @@ function ConfigureMathJax() { // // Parse added extensions list and add to standard ones // - var extensionList = extensions.split(/s*,\s*/); + var extensionList = extensions.split(/\s*,\s*/); for (var i = 0; i < extensionList.length; i++) { var matches = extensionList[i].match(/^(.*?)(\.js)?$/); window.MathJax.extensions.push(matches[1] + '.js'); @@ -730,7 +739,7 @@ function GetSVG(result) { // function StartQueue() { data = callback = originalData = null; // clear existing equation, if any - errors = []; // clear any errors + errors = sErrors; sErrors = []; // clear any errors if (!queue.length) return; // return if nothing to do serverState = STATE.BUSY; @@ -943,9 +952,17 @@ exports.typeset = function (data, callback) { // // Manually start MathJax (this is done automatically -// when the first typeset() call is made) -// -exports.start = function () {RestartMathJax()} +// when the first typeset() call is made), but delay +// restart if we are already starting up (prevents +// multiple calls to start() from causing confusion). +// +exports.start = function () { + if (serverState === STATE.STARTED) { + serverState = STATE.RESTART; + } else if (serverState !== STATE.ABORT) { + RestartMathJax(); + } +} // // Configure MathJax and the API diff --git a/package-lock.json b/package-lock.json index 4fdf1320..314fd9f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mathjax-node", - "version": "2.1.0", + "version": "2.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -19,7 +19,7 @@ "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.1.0.tgz", "integrity": "sha512-KjZwU26uG3u6eZcfGbTULzFcsoz6pegNKtHPksZPOUsiKo5bUmiBPa38FuHZ/Eun+XYh/JCCkS9AS3Lu4McQOQ==", "requires": { - "acorn": "5.4.1" + "acorn": "^5.0.0" } }, "ajv": { @@ -27,10 +27,10 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "requires": { - "co": "4.6.0", - "fast-deep-equal": "1.0.0", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.3.1" + "co": "^4.6.0", + "fast-deep-equal": "^1.0.0", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.3.0" } }, "array-equal": { @@ -64,9 +64,9 @@ "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" }, "aws4": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=" + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", + "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==" }, "balanced-match": { "version": "1.0.0", @@ -80,15 +80,7 @@ "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", "optional": true, "requires": { - "tweetnacl": "0.14.5" - } - }, - "boom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", - "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", - "requires": { - "hoek": "4.2.0" + "tweetnacl": "^0.14.3" } }, "brace-expansion": { @@ -97,7 +89,7 @@ "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -117,11 +109,11 @@ "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" }, "combined-stream": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", "requires": { - "delayed-stream": "1.0.0" + "delayed-stream": "~1.0.0" } }, "concat-map": { @@ -140,24 +132,6 @@ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" }, - "cryptiles": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", - "requires": { - "boom": "5.2.0" - }, - "dependencies": { - "boom": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", - "requires": { - "hoek": "4.2.0" - } - } - } - }, "cssom": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.2.tgz", @@ -168,7 +142,7 @@ "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-0.2.37.tgz", "integrity": "sha1-VBCXI0yyUTyDzu06zdwn/yeYfVQ=", "requires": { - "cssom": "0.3.2" + "cssom": "0.3.x" } }, "dashdash": { @@ -176,7 +150,7 @@ "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" } }, "deep-equal": { @@ -196,8 +170,8 @@ "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=", "dev": true, "requires": { - "foreach": "2.0.5", - "object-keys": "1.0.11" + "foreach": "^2.0.5", + "object-keys": "^1.0.8" } }, "defined": { @@ -216,7 +190,7 @@ "resolved": "https://registry.npmjs.org/domexception/-/domexception-1.0.1.tgz", "integrity": "sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug==", "requires": { - "webidl-conversions": "4.0.2" + "webidl-conversions": "^4.0.2" } }, "ecc-jsbn": { @@ -225,7 +199,7 @@ "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", "optional": true, "requires": { - "jsbn": "0.1.1" + "jsbn": "~0.1.0" } }, "es-abstract": { @@ -234,11 +208,11 @@ "integrity": "sha512-Cf9/h5MrXtExM20gSS55YFrGKCyPrRBjIVBtVyy8vmlsDfe0NPKMWj65tPLgzyfPuapWxh5whpXCtW4+AW5mRg==", "dev": true, "requires": { - "es-to-primitive": "1.1.1", - "function-bind": "1.1.1", - "has": "1.0.1", - "is-callable": "1.1.3", - "is-regex": "1.0.4" + "es-to-primitive": "^1.1.1", + "function-bind": "^1.1.0", + "has": "^1.0.1", + "is-callable": "^1.1.3", + "is-regex": "^1.0.4" } }, "es-to-primitive": { @@ -247,9 +221,9 @@ "integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=", "dev": true, "requires": { - "is-callable": "1.1.3", - "is-date-object": "1.0.1", - "is-symbol": "1.0.1" + "is-callable": "^1.1.1", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.1" } }, "escodegen": { @@ -257,11 +231,11 @@ "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.9.0.tgz", "integrity": "sha512-v0MYvNQ32bzwoG2OSFzWAkuahDQHK92JBN0pTAALJ4RIxEZe766QJPDR8Hqy7XNUy5K3fnVL76OqYAdc4TZEIw==", "requires": { - "esprima": "3.1.3", - "estraverse": "4.2.0", - "esutils": "2.0.2", - "optionator": "0.8.2", - "source-map": "0.5.7" + "esprima": "^3.1.3", + "estraverse": "^4.2.0", + "esutils": "^2.0.2", + "optionator": "^0.8.1", + "source-map": "~0.5.6" } }, "esprima": { @@ -290,9 +264,9 @@ "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" }, "fast-deep-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", + "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=" }, "fast-json-stable-stringify": { "version": "2.0.0", @@ -310,7 +284,7 @@ "integrity": "sha1-LEBFC5NI6X8oEyJZO6lnBLmr1NQ=", "dev": true, "requires": { - "is-function": "1.0.1" + "is-function": "~1.0.0" } }, "foreach": { @@ -325,13 +299,13 @@ "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" }, "form-data": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", - "integrity": "sha1-b7lPvXGIUwbXPRXMSX/kzE7NRL8=", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz", + "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=", "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.17" + "asynckit": "^0.4.0", + "combined-stream": "1.0.6", + "mime-types": "^2.1.12" } }, "fs.realpath": { @@ -351,7 +325,7 @@ "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "requires": { - "assert-plus": "1.0.0" + "assert-plus": "^1.0.0" } }, "glob": { @@ -360,12 +334,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "har-schema": { @@ -378,8 +352,8 @@ "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", "requires": { - "ajv": "5.5.2", - "har-schema": "2.0.0" + "ajv": "^5.1.0", + "har-schema": "^2.0.0" } }, "has": { @@ -388,31 +362,15 @@ "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", "dev": true, "requires": { - "function-bind": "1.1.1" + "function-bind": "^1.0.2" } }, - "hawk": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", - "requires": { - "boom": "4.3.1", - "cryptiles": "3.1.2", - "hoek": "4.2.0", - "sntp": "2.1.0" - } - }, - "hoek": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.0.tgz", - "integrity": "sha512-v0XCLxICi9nPfYrS9RL8HbYnXi9obYAeLbSP00BmnZwCK9+Ih9WOjoZ8YoHCoav2csqn4FOz4Orldsy2dmDwmQ==" - }, "html-encoding-sniffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", "integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==", "requires": { - "whatwg-encoding": "1.0.3" + "whatwg-encoding": "^1.0.1" } }, "http-signature": { @@ -420,9 +378,9 @@ "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "requires": { - "assert-plus": "1.0.0", - "jsprim": "1.4.1", - "sshpk": "1.13.1" + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" } }, "iconv-lite": { @@ -436,8 +394,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -475,7 +433,7 @@ "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", "dev": true, "requires": { - "has": "1.0.1" + "has": "^1.0.1" } }, "is-symbol": { @@ -505,32 +463,32 @@ "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-11.6.2.tgz", "integrity": "sha512-pAeZhpbSlUp5yQcS6cBQJwkbzmv4tWFaYxHbFVSxzXefqjvtRA851Z5N2P+TguVG9YeUDcgb8pdeVQRJh0XR3Q==", "requires": { - "abab": "1.0.4", - "acorn": "5.4.1", - "acorn-globals": "4.1.0", - "array-equal": "1.0.0", - "browser-process-hrtime": "0.1.2", - "content-type-parser": "1.0.2", - "cssom": "0.3.2", - "cssstyle": "0.2.37", - "domexception": "1.0.1", - "escodegen": "1.9.0", - "html-encoding-sniffer": "1.0.2", - "left-pad": "1.2.0", - "nwmatcher": "1.4.3", + "abab": "^1.0.4", + "acorn": "^5.3.0", + "acorn-globals": "^4.1.0", + "array-equal": "^1.0.0", + "browser-process-hrtime": "^0.1.2", + "content-type-parser": "^1.0.2", + "cssom": ">= 0.3.2 < 0.4.0", + "cssstyle": ">= 0.2.37 < 0.3.0", + "domexception": "^1.0.0", + "escodegen": "^1.9.0", + "html-encoding-sniffer": "^1.0.2", + "left-pad": "^1.2.0", + "nwmatcher": "^1.4.3", "parse5": "4.0.0", - "pn": "1.1.0", - "request": "2.83.0", - "request-promise-native": "1.0.5", - "sax": "1.2.4", - "symbol-tree": "3.2.2", - "tough-cookie": "2.3.3", - "w3c-hr-time": "1.0.1", - "webidl-conversions": "4.0.2", - "whatwg-encoding": "1.0.3", - "whatwg-url": "6.4.0", - "ws": "4.0.0", - "xml-name-validator": "3.0.0" + "pn": "^1.1.0", + "request": "^2.83.0", + "request-promise-native": "^1.0.5", + "sax": "^1.2.4", + "symbol-tree": "^3.2.2", + "tough-cookie": "^2.3.3", + "w3c-hr-time": "^1.0.1", + "webidl-conversions": "^4.0.2", + "whatwg-encoding": "^1.0.3", + "whatwg-url": "^6.4.0", + "ws": "^4.0.0", + "xml-name-validator": "^3.0.0" } }, "json-schema": { @@ -569,8 +527,8 @@ "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "requires": { - "prelude-ls": "1.1.2", - "type-check": "0.3.2" + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" } }, "lodash": { @@ -589,16 +547,16 @@ "integrity": "sha512-HEKJYRofOD5k9RmTj1amdA32JIJOqJ8SO+lq50mffZzdfFz+bNnsB0tJ8efMfYpiffvUHkqFRZFxXftW4BaBOw==" }, "mime-db": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", - "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" }, "mime-types": { - "version": "2.1.17", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", - "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", "requires": { - "mime-db": "1.30.0" + "mime-db": "~1.33.0" } }, "minimatch": { @@ -607,7 +565,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "1.1.8" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -644,7 +602,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "optionator": { @@ -652,12 +610,12 @@ "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", "requires": { - "deep-is": "0.1.3", - "fast-levenshtein": "2.0.6", - "levn": "0.3.0", - "prelude-ls": "1.1.2", - "type-check": "0.3.2", - "wordwrap": "1.0.0" + "deep-is": "~0.1.3", + "fast-levenshtein": "~2.0.4", + "levn": "~0.3.0", + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2", + "wordwrap": "~1.0.0" } }, "parse5": { @@ -698,37 +656,35 @@ "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" }, "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" }, "request": { - "version": "2.83.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.83.0.tgz", - "integrity": "sha512-lR3gD69osqm6EYLk9wB/G1W/laGWjzH90t1vEa2xuxHD5KUrSzp9pUSfTm+YC5Nxt2T8nMPEvKlhbQayU7bgFw==", - "requires": { - "aws-sign2": "0.7.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.3.1", - "har-validator": "5.0.3", - "hawk": "6.0.2", - "http-signature": "1.2.0", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.17", - "oauth-sign": "0.8.2", - "performance-now": "2.1.0", - "qs": "6.5.1", - "safe-buffer": "5.1.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.3", - "tunnel-agent": "0.6.0", - "uuid": "3.2.1" + "version": "2.87.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", + "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.6.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.1", + "forever-agent": "~0.6.1", + "form-data": "~2.3.1", + "har-validator": "~5.0.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.17", + "oauth-sign": "~0.8.2", + "performance-now": "^2.1.0", + "qs": "~6.5.1", + "safe-buffer": "^5.1.1", + "tough-cookie": "~2.3.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.1.0" } }, "request-promise-core": { @@ -736,7 +692,7 @@ "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz", "integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=", "requires": { - "lodash": "4.17.5" + "lodash": "^4.13.1" } }, "request-promise-native": { @@ -745,8 +701,8 @@ "integrity": "sha1-UoF3D2jgyXGeUWP9P6tIIhX0/aU=", "requires": { "request-promise-core": "1.1.1", - "stealthy-require": "1.1.1", - "tough-cookie": "2.3.3" + "stealthy-require": "^1.1.0", + "tough-cookie": ">=2.3.3" } }, "resolve": { @@ -755,7 +711,7 @@ "integrity": "sha512-aW7sVKPufyHqOmyyLzg/J+8606v5nevBgaliIlV7nUpVMsDnoBGV/cbSLNjZAg9q0Cfd/+easKVKQ8vOu8fn1Q==", "dev": true, "requires": { - "path-parse": "1.0.5" + "path-parse": "^1.0.5" } }, "resumer": { @@ -764,7 +720,7 @@ "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", "dev": true, "requires": { - "through": "2.3.8" + "through": "~2.3.4" } }, "safe-buffer": { @@ -777,14 +733,6 @@ "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" }, - "sntp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", - "requires": { - "hoek": "4.2.0" - } - }, "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -792,18 +740,18 @@ "optional": true }, "sshpk": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.1.tgz", - "integrity": "sha1-US322mKHFEMW3EwY/hzx2UBzm+M=", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.1.tgz", + "integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=", "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "tweetnacl": "~0.14.0" } }, "stealthy-require": { @@ -817,16 +765,11 @@ "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", "dev": true, "requires": { - "define-properties": "1.1.2", - "es-abstract": "1.8.0", - "function-bind": "1.1.1" + "define-properties": "^1.1.2", + "es-abstract": "^1.5.0", + "function-bind": "^1.0.2" } }, - "stringstream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=" - }, "symbol-tree": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz", @@ -838,19 +781,19 @@ "integrity": "sha512-TWILfEnvO7I8mFe35d98F6T5fbLaEtbFTG/lxWvid8qDfFTxt19EBijWmB4j3+Hoh5TfHE2faWs73ua+EphuBA==", "dev": true, "requires": { - "deep-equal": "1.0.1", - "defined": "1.0.0", - "for-each": "0.3.2", - "function-bind": "1.1.1", - "glob": "7.1.2", - "has": "1.0.1", - "inherits": "2.0.3", - "minimist": "1.2.0", - "object-inspect": "1.3.0", - "resolve": "1.4.0", - "resumer": "0.0.0", - "string.prototype.trim": "1.1.2", - "through": "2.3.8" + "deep-equal": "~1.0.1", + "defined": "~1.0.0", + "for-each": "~0.3.2", + "function-bind": "~1.1.0", + "glob": "~7.1.2", + "has": "~1.0.1", + "inherits": "~2.0.3", + "minimist": "~1.2.0", + "object-inspect": "~1.3.0", + "resolve": "~1.4.0", + "resumer": "~0.0.0", + "string.prototype.trim": "~1.1.2", + "through": "~2.3.8" } }, "through": { @@ -864,7 +807,7 @@ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz", "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=", "requires": { - "punycode": "1.4.1" + "punycode": "^1.4.1" } }, "tr46": { @@ -872,7 +815,7 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=", "requires": { - "punycode": "2.1.0" + "punycode": "^2.1.0" }, "dependencies": { "punycode": { @@ -887,7 +830,7 @@ "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "requires": { - "safe-buffer": "5.1.1" + "safe-buffer": "^5.0.1" } }, "tweetnacl": { @@ -901,7 +844,7 @@ "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "requires": { - "prelude-ls": "1.1.2" + "prelude-ls": "~1.1.2" } }, "ultron": { @@ -919,9 +862,9 @@ "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "requires": { - "assert-plus": "1.0.0", + "assert-plus": "^1.0.0", "core-util-is": "1.0.2", - "extsprintf": "1.3.0" + "extsprintf": "^1.2.0" } }, "w3c-hr-time": { @@ -929,7 +872,7 @@ "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz", "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=", "requires": { - "browser-process-hrtime": "0.1.2" + "browser-process-hrtime": "^0.1.2" } }, "webidl-conversions": { @@ -950,9 +893,9 @@ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.4.0.tgz", "integrity": "sha512-Z0CVh/YE217Foyb488eo+iBv+r7eAQ0wSTyApi9n06jhcA3z6Nidg/EGvl0UFkg7kMdKxfBzzr+o9JF+cevgMg==", "requires": { - "lodash.sortby": "4.7.0", - "tr46": "1.0.1", - "webidl-conversions": "4.0.2" + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.0", + "webidl-conversions": "^4.0.1" } }, "wordwrap": { @@ -971,9 +914,9 @@ "resolved": "https://registry.npmjs.org/ws/-/ws-4.0.0.tgz", "integrity": "sha512-QYslsH44bH8O7/W2815u5DpnCpXWpEK44FmaHffNwgJI4JMaSZONgPBTOfrxJ29mXKbXak+LsJ2uAkDTYq2ptQ==", "requires": { - "async-limiter": "1.0.0", - "safe-buffer": "5.1.1", - "ultron": "1.1.1" + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0", + "ultron": "~1.1.0" } }, "xml-name-validator": { diff --git a/package.json b/package.json index 0e0deac0..4a37c18a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mathjax-node", - "version": "2.1.0", + "version": "2.1.1", "description": "API's for calling MathJax from node.js", "keywords": [ "MathJax", diff --git a/test/base-config-extensions.js b/test/base-config-extensions.js new file mode 100644 index 00000000..8d07733c --- /dev/null +++ b/test/base-config-extensions.js @@ -0,0 +1,22 @@ +var tape = require('tape'); +var mjAPI = require('../lib/main.js'); + +tape('Options "extension": multiple extensions', function(t) { + t.plan(1); + mjAPI.config({ + extensions: 'TeX/autoload-all.js, TeX/color.js' + }); + mjAPI.typeset( + { + math: 'E = mc^2', + format: 'TeX', + mml: true + }, + function(data) { + t.notOk( + data.errors, + 'Config block with multiple extensions throws no error' + ); + } + ); +}); diff --git a/test/base-config-fonturl.js b/test/base-config-fonturl.js index ad641bc8..29899aa8 100644 --- a/test/base-config-fonturl.js +++ b/test/base-config-fonturl.js @@ -6,27 +6,41 @@ tape('basic configuration: check fontURL', function (t) { t.plan(2); var tex = 'a'; + mjAPI.typeset({ math: tex, format: "TeX", - css: true + css: true, + htmlNode: true }, function (result, data) { - t.ok(result.css.indexOf('https://cdnjs.cloudflare.com/ajax/libs/mathjax/' + mjVersion + '/fonts/HTML-CSS') > -1, 'Default fontURL'); - }); - // reconfigure - mjAPI.typeset({ - math: '' - }, function () { + var mjVersion = result.htmlNode.ownerDocument.defaultView.MathJax.version; + var URL = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/' + mjVersion + '/fonts/HTML-CSS'; + t.ok(result.css.indexOf(URL) > -1, 'Default fontURL'); + + // + // reconfigure + // mjAPI.config({ fontURL: 'https://example.com' }); mjAPI.start(); - }) - mjAPI.typeset({ - math: tex, - format: "TeX", - css: true, - }, function (result, data) { - t.ok(result.css.indexOf('https://example.com') > -1, 'Configuring fontURL'); + + // + // Next test + // + + mjAPI.typeset({ + math: 'a', + format: "TeX", + css: true, + }, function (result, data) { + t.ok(result.css.indexOf('https://example.com') > -1, 'Configuring fontURL'); + // + // reconfigure + // + mjAPI.config({fontURL: ''}); + mjAPI.start(); + }); + }); }); diff --git a/test/base-errors-startup.js b/test/base-errors-startup.js new file mode 100644 index 00000000..a35c3c26 --- /dev/null +++ b/test/base-errors-startup.js @@ -0,0 +1,28 @@ +var tape = require('tape'); +var mjAPI = require('../lib/main.js'); + +tape('Catch errors during startup phase', function(t) { + t.plan(1); + mjAPI.config({ + extensions: 'blargh' + }); + mjAPI.start(); + mjAPI.typeset( + { + math: 'x', + format: 'TeX', + mml: true + }, + function(data) { + t.ok( + data.errors, + 'Error (loading non-existent extension) is caught in output' + ); + // reset configuration + mjAPI.config({ + extensions: '' + }); + mjAPI.start(); + } + ); +}); diff --git a/test/base-mathjax.js b/test/base-mathjax.js index a2a74a72..c87cee85 100644 --- a/test/base-mathjax.js +++ b/test/base-mathjax.js @@ -2,17 +2,17 @@ var tape = require('tape'); var mjAPI = require("../lib/main.js"); tape('basic test: check MathJax core', function(t) { - t.plan(2); + t.plan(2); - var tex = ''; - mjAPI.start(); + var tex = ''; + + mjAPI.typeset({ + math: tex, + format: "TeX", + mml: true + }, function(result,data) { + t.ok(result.mml, 'MathJax core seems ok'); + t.ok(data.format, 'MathJax input preserved'); + }); - mjAPI.typeset({ - math: tex, - format: "TeX", - mml: true - }, function(result,data) { - t.ok(result.mml, 'MathJax core seems ok'); - t.ok(data.format, 'MathJax input preserved'); - }); }); diff --git a/test/base-typeset-promise.js b/test/base-typeset-promise.js index 25b52b5d..55cd1a6e 100644 --- a/test/base-typeset-promise.js +++ b/test/base-typeset-promise.js @@ -4,20 +4,33 @@ var mjAPI = require("../lib/main.js"); tape('basic test: check typeset promise API', function (t) { t.plan(2); - var tex = ''; mjAPI.config({displayErrors: false}); - mjAPI.start(); + var tex = ''; + + // // promise resolved + // mjAPI.typeset({ math: tex, format: "TeX", mml: true }).then((result) => t.ok(result.mml, 'Typset promise resolved on success')); + // + // promise frejected + // mjAPI.typeset({ math: tex, format: "MathML", mml: true }).catch((error) => t.ok(error, 'Typeset promise rejected on error')); + + // + // reset configuration + // + mjAPI.typeset({math: '', format: 'TeX', mml: true}, () => { + mjAPI.config({displayErrors: true}); + }); + }); diff --git a/test/base-warnings.js b/test/base-warnings.js index ff3575b4..b16a3b87 100644 --- a/test/base-warnings.js +++ b/test/base-warnings.js @@ -4,9 +4,19 @@ mjAPI.config({undefinedCharError: true}); tape('basic test: check warnings', function (t) { t.plan(2); + mjAPI.config({displayErrors: false}); + mjAPI.typeset({math:'\u5475', html:true}) .catch(errors => t.ok(errors, 'CommonHTML output reports error')); mjAPI.typeset({math:'\u5475', svg:true}) .catch(errors => t.ok(errors, 'SVG output reports error')); + + // + // reset configuration + // + mjAPI.typeset({math: '', format: 'TeX', mml: true}, () => { + mjAPI.config({displayErrors: true}); + }); + }); diff --git a/test/config-third-party-extensions.js b/test/config-third-party-extensions.js index e9ba4386..0d0f481f 100644 --- a/test/config-third-party-extensions.js +++ b/test/config-third-party-extensions.js @@ -4,7 +4,7 @@ const path = require('path'); tape('Configuring third party extensions', function(t) { t.plan(1); - var tex = '\\test'; + mjAPI.config( { extensions: '[test]/test.js', paths: { @@ -12,11 +12,20 @@ tape('Configuring third party extensions', function(t) { } }); mjAPI.start(); + + var tex = '\\test'; + mjAPI.typeset({ math: tex, format: "TeX", mmlNode: true }, function(data) { t.notOk(data.errors, 'No error loading the extension'); + // + // reset configuration + // + mjAPI.config({extensions: '', paths: {}}); + mjAPI.start(); }); + }); diff --git a/test/css.js b/test/css.js index 3fb2ba02..26ab5026 100644 --- a/test/css.js +++ b/test/css.js @@ -3,8 +3,7 @@ var mjAPI = require("../lib/main.js"); tape('CSS output', function(t) { t.plan(3); - mjAPI.start(); - var tex = 'x'; + mjAPI.typeset({ math: tex, format: "TeX", @@ -12,6 +11,9 @@ tape('CSS output', function(t) { }, function(data) { t.ok(data.css, 'css output while no other output'); }); + + var tex = 'x'; + mjAPI.typeset({ math: tex, format: "TeX", @@ -21,4 +23,5 @@ tape('CSS output', function(t) { t.ok(data.css, 'css output created alongside SVG output'); t.ok(data.svg, 'svg output is created'); }); + }); diff --git a/test/issue104.js b/test/issue104.js index a67a84ea..4b9541c9 100644 --- a/test/issue104.js +++ b/test/issue104.js @@ -5,7 +5,6 @@ var JSDOM = require('jsdom').JSDOM; tape('the SVG width should match the default', function(t) { t.plan(1); - mjAPI.start(); var tex = 'a \\\\ b'; var expected = '100ex'; @@ -20,4 +19,5 @@ tape('the SVG width should match the default', function(t) { var width = element.getAttribute('width'); t.equal(width, expected); }); + }); diff --git a/test/issue175.js b/test/issue175.js index 4accfa03..b2b7f7f7 100644 --- a/test/issue175.js +++ b/test/issue175.js @@ -3,27 +3,31 @@ var mjAPI = require("../lib/main.js"); var JSDOM = require('jsdom').JSDOM; tape('color extension should be reset', function(t) { - t.plan(3); - mjAPI.config({displayErrors: false}); - mjAPI.start(); - var tex = '\\colorbox{green}{x}'; - var tex2 = '\\color{red}{x}x'; + t.plan(3); + + mjAPI.config({displayErrors: false}); + + var tex = '\\colorbox{green}{x}'; + var tex2 = '\\color{red}{x}x'; + + mjAPI.typeset({ + math: tex, + format: "TeX", + mml: true + }, function(data) { + t.ok(data.errors, 'Color extension disabled'); + }); + + mjAPI.typeset({ + math: tex2, + format: "TeX", + mml: true + }, function(data) { + var document = new JSDOM(data.mml).window.document; + var mstyle = document.querySelector('mstyle'); + t.ok(document.querySelectorAll('mi')[0].parentNode === mstyle, 'Color macro behaves correctly (1 of 2)'); + t.notOk(document.querySelectorAll('mi')[1].parentNode === mstyle, 'Color macro behaves correctly (2 of 2)'); + mjAPI.config({displayErrors: true}); // reset configuration + }); - mjAPI.typeset({ - math: tex, - format: "TeX", - mml: true - }, function(data) { - t.ok(data.errors, 'Color extension disabled'); - }); - mjAPI.typeset({ - math: tex2, - format: "TeX", - mml: true - }, function(data) { - var document = new JSDOM(data.mml).window.document; - var mstyle = document.querySelector('mstyle'); - t.ok(document.querySelectorAll('mi')[0].parentNode === mstyle, 'Color macro behaves correctly (1 of 2)'); - t.notOk(document.querySelectorAll('mi')[1].parentNode === mstyle, 'Color macro behaves correctly (2 of 2)'); - }); }); diff --git a/test/issue207.js b/test/issue207.js index 34a7cb1a..95385b2a 100644 --- a/test/issue207.js +++ b/test/issue207.js @@ -3,55 +3,64 @@ var mjAPI = require("../lib/main.js"); var JSDOM = require('jsdom').JSDOM; tape('Generate dummy speechText', function(t) { - t.plan(9); - mjAPI.start(); - var input1 = 'source'; - var input2 = 'x'; - var input3 = 'x'; - var expected1 = 'source'; - var expected2 = 'alttext'; - var expected3 = 'Equation'; - var desc1 = 'source'; - var desc2 = 'original MathML alttext'; - var desc3 = 'default dummy value'; + t.plan(9); - mjSpeechTest = function(data, expected, desc) { - var document = new JSDOM(data.html).window.document; - var element = document.querySelector('.mjx-math'); - var actual = element.getAttribute('aria-label'); - t.equal(actual, expected, 'HTML output contains speechText from ' + desc); - document = new JSDOM(data.mml).window.document; - element = document.querySelector('math'); - actual = element.getAttribute('alttext'); - t.equal(actual, expected, 'MathML output contains speechText from ' + desc); - document = new JSDOM(data.svg).window.document; - var svgTitle = document.querySelector('title'); - actual = svgTitle.innerHTML; - t.equal(actual, expected, 'SVG output contains speechText from ' + desc); - }; + var input1 = 'source'; + var input2 = 'x'; + var input3 = 'x'; + var expected1 = 'source'; + var expected2 = 'alttext'; + var expected3 = 'Equation'; + var desc1 = 'source'; + var desc2 = 'original MathML alttext'; + var desc3 = 'default dummy value'; + + mjSpeechTest = function(data, expected, desc) { + var document = new JSDOM(data.html).window.document; + var element = document.querySelector('.mjx-math'); + var actual = element.getAttribute('aria-label'); + t.equal(actual, expected, 'HTML output contains speechText from ' + desc); + document = new JSDOM(data.mml).window.document; + element = document.querySelector('math'); + actual = element.getAttribute('alttext'); + t.equal(actual, expected, 'MathML output contains speechText from ' + desc); + document = new JSDOM(data.svg).window.document; + var svgTitle = document.querySelector('title'); + actual = svgTitle.innerHTML; + t.equal(actual, expected, 'SVG output contains speechText from ' + desc); + }; + + // + // TeX source + // + mjAPI.typeset({ + math: input1, + format: "TeX", + html: true, + svg: true, + mml: true + }, function(data) {mjSpeechTest(data, expected1, desc1)}); + + // + // MathML alttext + // + mjAPI.typeset({ + math: input2, + format: "MathML", + html: true, + svg: true, + mml: true + }, function(data) {mjSpeechTest(data, expected2, desc2)}); + + // + // MathML without alttext + // + mjAPI.typeset({ + math: input3, + format: "MathML", + html: true, + svg: true, + mml: true + }, function(data) {mjSpeechTest(data, expected3, desc3)}); - // TeX source - mjAPI.typeset({ - math: input1, - format: "TeX", - html: true, - svg: true, - mml: true - }, function(data) {mjSpeechTest(data, expected1, desc1)}); - // MathML alttext - mjAPI.typeset({ - math: input2, - format: "MathML", - html: true, - svg: true, - mml: true - }, function(data) {mjSpeechTest(data, expected2, desc2)}); - // MathML without alttext - mjAPI.typeset({ - math: input3, - format: "MathML", - html: true, - svg: true, - mml: true - }, function(data) {mjSpeechTest(data, expected3, desc3)}); }); diff --git a/test/issue215.js b/test/issue215.js index b97fe05f..6215837c 100644 --- a/test/issue215.js +++ b/test/issue215.js @@ -3,21 +3,21 @@ var mjAPI = require("../lib/main.js"); var JSDOM = require('jsdom').JSDOM; tape('HTML output should remove automatically generated IDs', function(t) { - t.plan(2); + t.plan(2); - mjAPI.start(); - var tex = 'a \\\\ b'; - var expected = '100ex'; + var tex = 'a \\\\ b'; + var expected = '100ex'; + + mjAPI.typeset({ + math: tex, + format: "TeX", + html: true + }, function(data) { + var document = new JSDOM(data.html).window.document; + var id = document.querySelector('[id^="MJXc-Node-"]'); + var frame = document.querySelector('[id^="MathJax-Element-"]'); + t.notOk(id, 'automatic ids successfully removed'); + t.notOk(frame, 'MathJax-Element-[n]-frame id successfully removed'); + }); - mjAPI.typeset({ - math: tex, - format: "TeX", - html: true - }, function(data) { - var document = new JSDOM(data.html).window.document; - var id = document.querySelector('[id^="MJXc-Node-"]'); - var frame = document.querySelector('[id^="MathJax-Element-"]'); - t.notOk(id, 'automatic ids successfully removed'); - t.notOk(frame, 'MathJax-Element-[n]-frame id successfully removed'); - }); }); diff --git a/test/issue219.js b/test/issue219.js index e6a9f9f9..57d5deae 100644 --- a/test/issue219.js +++ b/test/issue219.js @@ -3,24 +3,24 @@ var mjAPI = require("../lib/main.js"); var JSDOM = require('jsdom').JSDOM; tape('Basic Check: pass jsdom object to output', function(t) { - t.plan(3); + t.plan(3); - mjAPI.start(); - var tex = 'x'; + var tex = 'x'; + + mjAPI.typeset({ + math: tex, + format: "TeX", + html: true, + htmlNode: true, + svg: true, + svgNode: true, + mml: true, + mmlNode: true + }, function(data) { + var window = new JSDOM().window; + t.ok(data.htmlNode instanceof window.HTMLElement, 'htmlNode is an HTMLElement'); + t.ok(data.svgNode instanceof window.SVGElement, 'svgNode is an SVGElement'); + t.ok(data.mmlNode instanceof window.Element, 'mmlNode is an Element'); + }); - mjAPI.typeset({ - math: tex, - format: "TeX", - html: true, - htmlNode: true, - svg: true, - svgNode: true, - mml: true, - mmlNode: true - }, function(data) { - var window = new JSDOM().window; - t.ok(data.htmlNode instanceof window.HTMLElement, 'htmlNode is an HTMLElement'); - t.ok(data.svgNode instanceof window.SVGElement, 'svgNode is an SVGElement'); - t.ok(data.mmlNode instanceof window.Element, 'mmlNode is an Element'); - }); }); diff --git a/test/issue220.js b/test/issue220.js index 23c7d89b..6b3fd0c3 100644 --- a/test/issue220.js +++ b/test/issue220.js @@ -3,20 +3,28 @@ var mjAPI = require("../lib/main.js"); var JSDOM = require('jsdom').JSDOM; tape('displayAlign:left in HTML output', function(t) { - t.plan(1); - mjAPI.config({MathJax: {"displayAlign": "left"}}); - mjAPI.start(); - var tex = 'x'; - var expected = "text-align: left;"; + t.plan(1); + + mjAPI.config({MathJax: {"displayAlign": "left"}}); + mjAPI.start(); + + var tex = 'x'; + var expected = "text-align: left;"; + + mjAPI.typeset({ + math: tex, + format: "TeX", + html: true + }, function(data) { + var document = new JSDOM(data.html).window.document; + var element = document.getElementsByClassName("MJXc-display")[0]; + var result = element.getAttribute('style'); + t.equal(result, expected); + // + // reset configuration + // + mjAPI.config({MathJax: {}}); + mjAPI.start(); + }); - mjAPI.typeset({ - math: tex, - format: "TeX", - html: true - }, function(data) { - var document = new JSDOM(data.html).window.document; - var element = document.getElementsByClassName("MJXc-display")[0]; - var result = element.getAttribute('style'); - t.equal(result, expected); - }); }); diff --git a/test/issue223.js b/test/issue223.js index 6ba16c7d..5d19012f 100644 --- a/test/issue223.js +++ b/test/issue223.js @@ -3,40 +3,46 @@ var mjAPI = require("../lib/main.js"); var JSDOM = require('jsdom').JSDOM; tape('displayIndent:left in HTML output', function(t) { - t.plan(2); - mjAPI.config({MathJax: {displayIndent: '10em'}}); - mjAPI.start(); - var first = 'x'; - var second = 'x \\tag{1}' - expected = "10em"; + t.plan(2); - // basic text - mjAPI.typeset({ - math: first, - format: "TeX", - html: true - }, function(data) { - var document = new JSDOM(data.html).window.document; - var element = document.getElementsByClassName('MJXc-display')[0]; - var result = element.style.marginLeft; - t.ok((result === expected), 'style includes a margin'); - }); + mjAPI.config({MathJax: {displayIndent: '10em'}}); + mjAPI.start(); + + var first = 'x'; + var second = 'x \\tag{1}' + expected = "10em"; - // test for mlabeledtr - mjAPI.typeset({ - math: second, - format: "TeX", - html: true - }, function(data) { - var document = new JSDOM(data.html).window.document; - var element = document.getElementsByClassName('mjx-table')[0]; - var result = element.style.marginLeft; - t.ok((result === expected), 'style includes a margin'); - }); - // reset configuration + // + // basic text + // mjAPI.typeset({ - math: '' - }, function(){ - mjAPI.config({MathJax: {displayIndent: '0em'}}); - }) + math: first, + format: "TeX", + html: true + }, function(data) { + var document = new JSDOM(data.html).window.document; + var element = document.getElementsByClassName('MJXc-display')[0]; + var result = element.style.marginLeft; + t.ok((result === expected), 'style includes a margin'); + }); + + // + // test for mlabeledtr + // + mjAPI.typeset({ + math: second, + format: "TeX", + html: true + }, function(data) { + var document = new JSDOM(data.html).window.document; + var element = document.getElementsByClassName('mjx-table')[0]; + var result = element.style.marginLeft; + t.ok((result === expected), 'style includes a margin'); + // + // reset configuration + // + mjAPI.config({MathJax: {}}); + mjAPI.start(); + }); + }); diff --git a/test/issue241.js b/test/issue241.js index e5eb2301..ac982af9 100644 --- a/test/issue241.js +++ b/test/issue241.js @@ -2,16 +2,17 @@ var tape = require('tape'); var mjAPI = require("../lib/main.js"); tape('SVG output: add xlink to href in ', function(t) { - t.plan(1); - mjAPI.start(); - var mml = ''; - var expected = /xlink:href/; + t.plan(1); + + var mml = ''; + var expected = /xlink:href/; + + mjAPI.typeset({ + math: mml, + format: "MathML", + svg: true + }, function(data) { + t.ok(data.svg.match(expected)); + }); - mjAPI.typeset({ - math: mml, - format: "MathML", - svg: true - }, function(data) { - t.ok(data.svg.match(expected)); - }); }); diff --git a/test/issue260.js b/test/issue260.js index 1fc1877c..34b6f05d 100644 --- a/test/issue260.js +++ b/test/issue260.js @@ -2,24 +2,25 @@ var tape = require('tape'); var mjAPI = require('../lib/main.js'); tape('getSVG should increment state.ID', function(t) { - t.plan(1); + t.plan(1); + + var mml = '1'; + var state = {}; + + mjAPI.typeset({ + math: mml, + format: 'MathML', + speakText: true, + svg: true, + state: state}, function(data) {}); + mjAPI.typeset({ + math: mml, + format: 'MathML', + speakText: true, + svg: true, + state: state + }, function(data) { + t.equal(state.ID, 2, 'state.ID incremented') + }); - mjAPI.start(); - var mml = '1'; - var state = {}; - mjAPI.typeset({ - math: mml, - format: 'MathML', - speakText: true, - svg: true, - state: state}, function(data) {}); - mjAPI.typeset({ - math: mml, - format: 'MathML', - speakText: true, - svg: true, - state: state - }, function(data) { - t.equal(state.ID, 2, 'state.ID incremented') - }); }); diff --git a/test/issue276.js b/test/issue276.js index 30c56316..0dfb222c 100644 --- a/test/issue276.js +++ b/test/issue276.js @@ -3,17 +3,18 @@ var mjAPI = require("../lib/main.js"); var JSDOM = require('jsdom').JSDOM; tape('SVG output: physical units', function(t) { - t.plan(1); - mjAPI.start(); - var mml = ''; + t.plan(1); + + var mml = ''; + + mjAPI.typeset({ + math: mml, + format: "MathML", + svg: true + }, function(data) { + var document = new JSDOM(data.svg).window.document; + var width = document.querySelector('svg').getAttribute('width'); + t.notEqual(width, '0', ''); + }); - mjAPI.typeset({ - math: mml, - format: "MathML", - svg: true - }, function(data) { - var document = new JSDOM(data.svg).window.document; - var width = document.querySelector('svg').getAttribute('width'); - t.notEqual(width, '0', ''); - }); }); diff --git a/test/issue277.js b/test/issue277.js index ce6647a4..df0bdaf7 100644 --- a/test/issue277.js +++ b/test/issue277.js @@ -3,7 +3,7 @@ var mjAPI = require("../lib/main.js"); tape('mmlNode should not produce mml', function(t) { t.plan(1); - mjAPI.start(); + var tex = 'x'; mjAPI.typeset({ @@ -13,4 +13,5 @@ tape('mmlNode should not produce mml', function(t) { }, function(data) { t.ok(data.mml === undefined, 'mml not generated'); }); + }); diff --git a/test/issue288.js b/test/issue288.js index 498b6e09..9765f329 100644 --- a/test/issue288.js +++ b/test/issue288.js @@ -3,7 +3,7 @@ var mjAPI = require("../lib/main.js"); tape('HTML output when requesting both SVG and HTML', function(t) { t.plan(2); - mjAPI.start(); + var tex = 'x'; mjAPI.typeset({ @@ -23,4 +23,5 @@ tape('HTML output when requesting both SVG and HTML', function(t) { }, function(data) { t.ok(data.html, 'html output is present') }); + }); diff --git a/test/issue289.js b/test/issue289.js index b740232a..4e7f7ab1 100644 --- a/test/issue289.js +++ b/test/issue289.js @@ -3,7 +3,7 @@ var mjAPI = require("../lib/main.js"); tape('HTML output: add aria-label to correct childnode', function(t) { t.plan(1); - mjAPI.start(); + var mml = '1'; mjAPI.typeset({ @@ -14,4 +14,5 @@ tape('HTML output: add aria-label to correct childnode', function(t) { }, function(data) { t.equal(data.htmlNode.parentNode.querySelectorAll('[aria-label]').length, 1, 'Aria-label is unique'); }); + }); diff --git a/test/mathjax-config-combined.js b/test/mathjax-config-combined.js index 13bc9d10..2ba5148c 100644 --- a/test/mathjax-config-combined.js +++ b/test/mathjax-config-combined.js @@ -3,17 +3,25 @@ var mjAPI = require("../lib/main.js"); tape('MathJax configuration: strip config block', function (t) { t.plan(1); + mjAPI.config({ MathJax: { config: ["TeX-AMS_SVG.js"] } }); + mjAPI.start(); + mjAPI.typeset({ math: 'E = mc^2', format: "TeX", mml: true, }, function (data) { t.ok(data, 'Config block did not cause errors'); + // + // reset configuration + // + mjAPI.config({MathJax: {}}); + mjAPI.start(); }); }); diff --git a/test/output-html-linebreaks-manual.js b/test/output-html-linebreaks-manual.js index 0505976d..e5c14823 100644 --- a/test/output-html-linebreaks-manual.js +++ b/test/output-html-linebreaks-manual.js @@ -2,15 +2,17 @@ var tape = require('tape'); var mjAPI = require("../lib/main.js"); tape('Output, HTML: linebreaks, manual', function(t) { - t.plan(1); - mjAPI.start(); - var tex = 'A \\\\ B'; - var expected = '' - mjAPI.typeset({ - math: tex, - format: "TeX", - html: true - }, function(data) { - t.equal(data.html, expected, 'HTML output as expected'); - }); + t.plan(1); + + var tex = 'A \\\\ B'; + var expected = '' + + mjAPI.typeset({ + math: tex, + format: "TeX", + html: true + }, function(data) { + t.equal(data.html, expected, 'HTML output as expected'); + }); + }); diff --git a/test/pass_data.js b/test/pass_data.js index d30b1808..058eea43 100644 --- a/test/pass_data.js +++ b/test/pass_data.js @@ -3,8 +3,9 @@ var mjAPI = require("../lib/main.js"); tape('Passing data along', function(t) { t.plan(1); - mjAPI.start(); + var tex = 'x'; + mjAPI.typeset({ math: tex, format: "TeX", @@ -13,4 +14,5 @@ tape('Passing data along', function(t) { }, function(data, input) { t.equal(input.something, 'expected', 'Data was passed along to output'); }); + }); diff --git a/test/svg-full-width-chars.js b/test/svg-full-width-chars.js index 6fc202a1..33b21310 100644 --- a/test/svg-full-width-chars.js +++ b/test/svg-full-width-chars.js @@ -2,17 +2,19 @@ var tape = require('tape'); var mjAPI = require("../lib/main.js"); tape('the SVG output should renders full-width characters correctly', function(t) { - t.plan(1); + t.plan(1); - mjAPI.config({displayErrors: false}); - mjAPI.start(); - var tex = '\\text{\u62FE\u96F6}^i'; + mjAPI.config({displayErrors: false}); + + var tex = '\\text{\u62FE\u96F6}^i'; + + mjAPI.typeset({ + math: tex, + format: "TeX", + svg: true + }, function(data) { + t.ok(data.width, '5.133ex', 'Width is correct'); + mjAPI.config({displayErrors: true}); // reset configuration + }); - mjAPI.typeset({ - math: tex, - format: "TeX", - svg: true - }, function(data) { - t.ok(data.width, '5.133ex', 'Width is correct'); - }); }); diff --git a/test/svg-metadata.js b/test/svg-metadata.js index 086a10d7..d00195bb 100644 --- a/test/svg-metadata.js +++ b/test/svg-metadata.js @@ -3,18 +3,18 @@ var mjAPI = require("../lib/main.js"); var jsdom = require('jsdom').jsdom; tape('the SVG output should add dimensions and styles', function(t) { - t.plan(3); + t.plan(3); - mjAPI.start(); - var tex = 'a + b'; + var tex = 'a + b'; + + mjAPI.typeset({ + math: tex, + format: "TeX", + svg: true + }, function(data) { + t.ok(data.width, 'Width is present'); + t.ok(data.height, 'Height is present'); + t.ok(data.style, 'Style is present'); + }); - mjAPI.typeset({ - math: tex, - format: "TeX", - svg: true - }, function(data) { - t.ok(data.width, 'Width is present'); - t.ok(data.height, 'Height is present'); - t.ok(data.style, 'Style is present'); - }); }); diff --git a/test/useFontCache.js b/test/useFontCache.js index 829fdc82..a60c0865 100644 --- a/test/useFontCache.js +++ b/test/useFontCache.js @@ -5,6 +5,7 @@ tape('basic configuration: useFontCache', function (t) { t.plan(2); var tex = 'a'; + mjAPI.typeset({ math: tex, format: "TeX", @@ -13,6 +14,7 @@ tape('basic configuration: useFontCache', function (t) { }, function (result, data) { t.ok(result.svg.indexOf(' -1, 'useFontCache set to true'); }); + }); diff --git a/test/userconfig-autoload.js b/test/userconfig-autoload.js index 21ce5eb1..cbdff183 100644 --- a/test/userconfig-autoload.js +++ b/test/userconfig-autoload.js @@ -4,17 +4,24 @@ var mjAPI = require("../lib/main.js"); tape('User config: autoload-all should enable color extension', function(t) { t.plan(1); - var tex = '\\definecolor{myorange}{RGB}{255,165,100}\\color{myorange}e^{i \\pi}\\color{Black} = -1'; mjAPI.config( { extensions: 'TeX/autoload-all', // a convenience option to add MathJax extensions }); mjAPI.start(); + var tex = '\\definecolor{myorange}{RGB}{255,165,100}\\color{myorange}e^{i \\pi}\\color{Black} = -1'; + mjAPI.typeset({ math: tex, format: "inline-TeX", mml: true }, function(data) { t.ok(!data.errors, 'definecolor should be a known function'); + // + // reset configuration + // + mjAPI.config({extenstion: ''}); + mjAPI.start(); }); + }); diff --git a/test/userconfig-jax.js b/test/userconfig-jax.js index 7bd3f8c1..e9acf5e5 100644 --- a/test/userconfig-jax.js +++ b/test/userconfig-jax.js @@ -2,18 +2,26 @@ var tape = require('tape'); var mjAPI = require('../lib/main.js'); tape('User configuration with jax array', function (t) { - t.plan(1); + t.plan(1); + + mjAPI.config({ + MathJax: { + jax: ["input/MathML", "output/SVG"] + } + }); + mjAPI.start(); + + mjAPI.typeset({ + math: '1', + format: 'MathML', + svg: true + }, function (data) { + t.ok(!data.errors, 'No errors'); + // + // reset configuration + // + mjAPI.config({MathJax: {}}); + mjAPI.start(); + }); - mjAPI.config({ - MathJax: { - jax: ["input/MathML", "output/SVG"] - } - }); - mjAPI.typeset({ - math: '1', - format: 'MathML', - svg: true - }, function (data) { - t.ok(!data.errors, 'No errors'); - }); });