I use a library that wraps pandoc for node. But I canβt understand 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); });
In the CLI, it will look like this:
echo "# Hello World" | pandoc -f markdown -t html
UPDATE 1
Trying to make it work 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');
source share