Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: stdin won t work for me #353

Closed
mh-cbon opened this issue Mar 6, 2017 · 7 comments
Closed

cli: stdin won t work for me #353

mh-cbon opened this issue Mar 6, 2017 · 7 comments
Assignees

Comments

@mh-cbon
Copy link
Contributor

mh-cbon commented Mar 6, 2017

Hi,

When i run this command, the output is empty,

cat README.md | showdown makehtml
Enabling option ghCodeBlocks
Enabling option encodeEmails
...
Reading data from stdin...
Parsing markdown...
Writing data to stdout...


DONE!

Where the README has content, see https://github.com/mh-cbon/emd/blob/master/README.md

Node -v 7.7.1 (also tested another older 7.x, broken too), i had to fallback to another tool, mdown

@tivie
Copy link
Member

tivie commented Mar 6, 2017

that is strange... what version of showdown are you using?

I've tested this on: showdown 1.6.4 on node 6.10-win-64x and it's working fine:

2017-03-06

@tivie
Copy link
Member

tivie commented Mar 6, 2017

Tested on:

  • Windows 10
  • node 7.7.1
  • showdown 1.6.4

And it's still working fine:

2017-03-06 4

@tivie
Copy link
Member

tivie commented Mar 6, 2017

you can also try running this command instead:

showdown makehtml -i README.md

and check if it works

@tivie tivie self-assigned this Mar 6, 2017
@mh-cbon
Copy link
Contributor Author

mh-cbon commented Mar 6, 2017

indeed : x

$ showdown -v
1.6.4
[mh-cbon@pc15-home ~] $ node -v
v7.7.1

see

showdown makehtml -i README.md | wc -l
Enabling option ghCodeBlocks
Enabling option encodeEmails
...
Reading data from file...
Parsing markdown...
Writing data to stdout...


DONE!
138

and

$ cat README.md | showdown makehtml | wc -l
Enabling option ghCodeBlocks
Enabling option encodeEmails
...
Reading data from stdin...
Parsing markdown...
Writing data to stdout...


DONE!
0

@tivie
Copy link
Member

tivie commented Mar 6, 2017

it seems showdown is able to find the README.d file but it is unable to read from it.

Can you try doing this:

echo "# foobar" | showdown makehtml

@mh-cbon
Copy link
Contributor Author

mh-cbon commented Mar 6, 2017

echo "# foobar" | showdown makehtml
Enabling option ghCodeBlocks
Enabling option encodeEmails
...
Reading data from stdin...
Parsing markdown...
Writing data to stdout...


DONE!

Digging the source, looks likes the problem is here, size is 0.

  function readFromStdIn () {
    try {
      var size = fs.fstatSync(process.stdin.fd).size;
console.log(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);
    }
  }

IMHO, i d refactor makehtml.run to copy the stdin stream to memory, rather than sync reading the fdesc.
http://stackoverflow.com/a/13411244/4466350

@tivie
Copy link
Member

tivie commented Mar 9, 2017

I've been testing this and could not reproduce the issue.
And it's really bothering me!

mh-cbon added a commit to mh-cbon/showdown that referenced this issue Mar 13, 2017
@tivie tivie closed this as completed in 1967652 Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants