I'm using a library that wraps pandoc
for node. But I can't figure out how to pass STDIN to the child process `execFile...
var execFile = require('child_process').execFile;
var optipng = require('pandoc-bin').path;
// STDIN SHOULD GO HERE!
execFile(optipng, ['--from=markdown', '--to=html'], function (err, stdout, stderr) {
console.log(err);
console.log(stdout);
console.log(stderr);
});
On the CLI it would look like this:
echo "# Hello World" | pandoc -f markdown -t html
UPDATE 1
Trying to get it working with spawn
:
var cp = require('child_process');
var optipng = require('pandoc-bin').path;
var child = cp.spawn(optipng, ['--from=markdown', '--to=html'], { stdio: [ 0, 'pipe', 'pipe' ] });
child.stdin.write('# HELLO');
// then what?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…