forked from Eelis/cxxdraft-htmlgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mathjax-batch
executable file
·36 lines (30 loc) · 832 Bytes
/
mathjax-batch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /usr/bin/env node
var mjAPI = require("mathjax-node");
var split = require("split");
mjAPI.config(
{ extensions: ""
, fontURL: "https://cdn.mathjax.org/mathjax/latest/fonts/HTML-CSS" });
mjAPI.start();
var math = '';
function processLine(line)
{
var format;
if (line == "NONINLINE") format = "TeX";
else if (line == "INLINE") format = "inline-TeX";
else
{
if (math != '') math += '\n';
math += line;
return;
}
mjAPI.typeset({
math: math, format: format, html: true, css: false,
speakText: true, ex: 6, width: 100, linebreaks: true
}, function (data) {
// todo: if (data.errors) abort
console.log(data.html)
console.log("DONE")
});
math = '';
}
process.stdin.pipe(split(/\n/, null, {trailing: false})).on('data', processLine)