Skip to content

Commit

Permalink
Merge pull request #331 from mathjax/develop
Browse files Browse the repository at this point in the history
1.1.0 release
  • Loading branch information
pkra authored May 4, 2017
2 parents 2f4bf95 + f51563f commit 8720f30
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var timer; // used to reset MathJax if it runs too lon
var document, window, content, html; // the DOM elements

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

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

Expand All @@ -660,7 +660,7 @@ function StartQueue() {
// and set the content with the proper script type
//
var item = queue.shift();
data = item[0]; callback = item[1];
data = item[0]; callback = item[1]; originalData = item[2];
content.innerHTML = "";
MathJax.HTML.addElement(content,"script",{type: "math/"+TYPES[data.format]},[data.math]);
html.setAttribute("xmlns:"+data.xmlns,"http://www.w3.org/1998/Math/MathML");
Expand Down Expand Up @@ -775,7 +775,7 @@ function ReturnResult(result) {
state.ID = ID;
}
serverState = STATE.READY;
callback(result, data);
callback(result, originalData);
if (serverState === STATE.READY) StartQueue();
}

Expand Down Expand Up @@ -836,7 +836,7 @@ exports.typeset = function (data,callback) {
}}
if (data.state) {options.state = data.state}
if (!TYPES[options.format]) {ReportError("Unknown format: "+options.format,callback); return}
queue.push([options,callback]);
queue.push([options,callback,Object.assign({},data)]);
if (serverState == STATE.STOPPED) {RestartMathJax()}
if (serverState == STATE.READY) StartQueue();
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mathjax-node",
"version": "1.0.3",
"version": "1.1.0",
"description": "API's for calling MathJax from node.js",
"keywords": [
"MathJax",
Expand Down
16 changes: 16 additions & 0 deletions test/pass_data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var tape = require('tape');
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",
css: true,
something: 'expected',
}, function(data, input) {
t.equal(input.something, 'expected', 'Data was passed along to output');
});
});

0 comments on commit 8720f30

Please sign in to comment.