You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the command showdown makehtml -i foo.md > foo.html
works as expected, the command showdown makehtml < foo.md > foo.html
produces an empty output file and the response
Enabling option ghCodeBlocks
Enabling option encodeEmails
...
Reading data from stdin...
ERROR: Could not read from stdin, reason: The "buffer" argument must be one of type Buffer, TypedArray, or DataView. Received type number
Run 'showdown <command> -h' for help
under Ubuntu 16.04 (4.4.0-134-generic) running node 10.10.0, showdown 1.8.6.
The problem seems to lie in the file showdown/src/cli/makehtml.cmd.js, where readFromStdIn
calls fs.readSync:
function readFromStdIn () {
try {
var size = fs.fstatSync(process.stdin.fd).size;
return size > 0 ? fs.readSync(process.stdin.fd, size)[0] : '';
} catch (e) {
var err = new Error('Could not read from stdin, reason: ' + e.message);
messenger.errorExit(err);
}
}
According to the nodejs web site, the readSync interface is: fs.readSync(fd, buffer, offset, length, position). (Perhaps it's changed since the code was first written?) I've used the following code successfully, though it ignores issues of character encoding and such. (You can't really convert bytes to a string without a character encoding, if only in the form of an assumption. :-):
function readFromStdIn () {
try {
var size = fs.fstatSync(process.stdin.fd).size;
var rslt = '';
if (size > 0) {
var buf = new Buffer.alloc(size);
fs.readSync(process.stdin.fd, buf, 0, size, 0);
rslt = buf.toString();
}
return rslt;
} catch (e) {
var err = new Error('Could not read from stdin, reason: ' + e.message);
messenger.errorExit(err);
}
}
Hope this helps. I use showdown regularly (among other things, it generates previews for markdown code in my emacs environment) and I greatly appreciate your efforts in developing it and your willingness to share it. Feel free to contact me if you need any further info.
While the command
showdown makehtml -i foo.md > foo.html
works as expected, the command
showdown makehtml < foo.md > foo.html
produces an empty output file and the response
under Ubuntu 16.04 (4.4.0-134-generic) running node 10.10.0, showdown 1.8.6.
The problem seems to lie in the file showdown/src/cli/makehtml.cmd.js, where
readFromStdIn
calls
fs.readSync
:According to the nodejs web site, the
readSync
interface is:fs.readSync(fd, buffer, offset, length, position)
. (Perhaps it's changed since the code was first written?) I've used the following code successfully, though it ignores issues of character encoding and such. (You can't really convert bytes to a string without a character encoding, if only in the form of an assumption. :-):Hope this helps. I use showdown regularly (among other things, it generates previews for markdown code in my emacs environment) and I greatly appreciate your efforts in developing it and your willingness to share it. Feel free to contact me if you need any further info.
-- Ray Ellis ([email protected])
The text was updated successfully, but these errors were encountered: