Skip to content

Commit 8720f30

Browse files
authored
Merge pull request #331 from mathjax/develop
1.1.0 release
2 parents 2f4bf95 + f51563f commit 8720f30

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

lib/main.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var timer; // used to reset MathJax if it runs too lon
8585
var document, window, content, html; // the DOM elements
8686

8787
var queue = []; // queue of typesetting requests of the form [data,callback]
88-
var data, callback; // the current queue item
88+
var data, callback, originalData; // the current queue item
8989
var errors = []; // errors collected durring the typesetting
9090
var ID = 0; // id for this SVG element
9191

@@ -648,7 +648,7 @@ function GetSVG(result) {
648648
// Start typesetting the queued expressions
649649
//
650650
function StartQueue() {
651-
data = callback = null; // clear existing equation, if any
651+
data = callback = originalData = null; // clear existing equation, if any
652652
errors = []; // clear any errors
653653
if (!queue.length) return; // return if nothing to do
654654

@@ -660,7 +660,7 @@ function StartQueue() {
660660
// and set the content with the proper script type
661661
//
662662
var item = queue.shift();
663-
data = item[0]; callback = item[1];
663+
data = item[0]; callback = item[1]; originalData = item[2];
664664
content.innerHTML = "";
665665
MathJax.HTML.addElement(content,"script",{type: "math/"+TYPES[data.format]},[data.math]);
666666
html.setAttribute("xmlns:"+data.xmlns,"http://www.w3.org/1998/Math/MathML");
@@ -775,7 +775,7 @@ function ReturnResult(result) {
775775
state.ID = ID;
776776
}
777777
serverState = STATE.READY;
778-
callback(result, data);
778+
callback(result, originalData);
779779
if (serverState === STATE.READY) StartQueue();
780780
}
781781

@@ -836,7 +836,7 @@ exports.typeset = function (data,callback) {
836836
}}
837837
if (data.state) {options.state = data.state}
838838
if (!TYPES[options.format]) {ReportError("Unknown format: "+options.format,callback); return}
839-
queue.push([options,callback]);
839+
queue.push([options,callback,Object.assign({},data)]);
840840
if (serverState == STATE.STOPPED) {RestartMathJax()}
841841
if (serverState == STATE.READY) StartQueue();
842842
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mathjax-node",
3-
"version": "1.0.3",
3+
"version": "1.1.0",
44
"description": "API's for calling MathJax from node.js",
55
"keywords": [
66
"MathJax",

test/pass_data.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var tape = require('tape');
2+
var mjAPI = require("../lib/main.js");
3+
4+
tape('Passing data along', function(t) {
5+
t.plan(1);
6+
mjAPI.start();
7+
var tex = 'x';
8+
mjAPI.typeset({
9+
math: tex,
10+
format: "TeX",
11+
css: true,
12+
something: 'expected',
13+
}, function(data, input) {
14+
t.equal(input.something, 'expected', 'Data was passed along to output');
15+
});
16+
});

0 commit comments

Comments
 (0)