Skip to content

Instantly share code, notes, and snippets.

@pkra
Last active May 27, 2016 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkra/d2894330e784f27dbc6e8b12763ca972 to your computer and use it in GitHub Desktop.
Save pkra/d2894330e784f27dbc6e8b12763ca972 to your computer and use it in GitHub Desktop.
"use strict";
var mjAPI = require("./lib/main");
var fs = require('fs');
var inputFile = "file.txt"; // use xargs or something
var output = [];
var array = fs.readFileSync('file.txt').toString().split("\n");
mjAPI.start();
for (var i = 0; i < array.length; i++) {
let index = i;
mjAPI.typeset({
math: array[index],
format: "TeX",
mml: true
}, function(data) {
var e = data.errors;
if (e) {
output.push(e);
}
if ( (index+1) === array.length){
console.log('Results: ' + output.join('\n'));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment