1 var mathjax = require('mathjax-node'),
5 mathjax.config({ MathJax: { loader: {load: ['ui/safe']},
6 extensions: ["Safe.js"] } });
8 process.stdin.on('data', (chunk) => {
10 size = chunk.readUInt32LE();
11 onDataChunk(chunk.subarray(4));
17 function onDataChunk(chunk) {
18 if(chunk.length > size) {
19 var excessChunk = chunk.subarray(size);
20 process.stdin.unshift(excessChunk);
21 chunk = chunk.subarray(0, size);
26 if(chunk.length == size) {
27 onMessage(Buffer.concat(chunks).toString());
32 size -= remainingChunk.length;
36 function onMessage(input) {
44 var sizeBuf = Buffer.alloc(4);
46 sizeBuf.writeUInt32LE(0);
47 process.stdout.write(sizeBuf);
50 var dataBuf = Buffer.from("<style>"+data.css+"</style>"+data.html);
51 sizeBuf.writeUInt32LE(dataBuf.length);
52 process.stdout.write(sizeBuf);
53 process.stdout.write(dataBuf);