Skip to content

Commit

Permalink
[main] pass input data to output
Browse files Browse the repository at this point in the history
Resolves #303
  • Loading branch information
pkra committed Apr 11, 2017
1 parent 3eff897 commit 9846f93
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ function StartQueue() {
// and set the content with the proper delimiters
//
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 @@ -773,7 +773,7 @@ function ReturnResult(result) {
state.n = GLYPH.n;
state.ID = ID;
}
callback(result, data);
callback(result, originalData);
serverState = STATE.READY;
StartQueue();
}
Expand Down Expand Up @@ -835,7 +835,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
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 9846f93

Please sign in to comment.