Render stdin text as Gemtext (#205)#242
Conversation
Signed-off-by: David Jimenez <dvejmz@sgfault.com>
Signed-off-by: David Jimenez <dvejmz@sgfault.com>
| stat, _ := os.Stdin.Stat() | ||
| return (stat.Mode() & os.ModeCharDevice) != 0 |
There was a problem hiding this comment.
Is this check portable across OSes? Where did you find this?
There was a problem hiding this comment.
This check leverages the Go standard library so I'd have thought it would be. I haven't tested this outside of my Fedora Linux installation so I wouldn't be able to say for sure though.
I got the idea from here. This article explains the approach in a bit more detail.
There was a problem hiding this comment.
Seems good. This answer mentions the same solution working on macOS too. And I guess pipes don't really apply to Windows.
Signed-off-by: David Jimenez <dvejmz@sgfault.com>
amfora.go
Outdated
| } | ||
|
|
||
| stdinText := stdinTextBuilder.String() | ||
| if len(strings.TrimSpace(stdinText)) > 0 { |
There was a problem hiding this comment.
I don't think this check is necessary. Nothing wrong with displaying some spaces or just nothing at all. Would be useful if part of some longer pipeline, where returning nothing is possible but not certain. Much better to get an empty page than be confused by the new tab page.
Other than this I think we're good to go!
Signed-off-by: David Jimenez <dvejmz@sgfault.com>
|
Thanks for adding this! |
This allows
amforato accept content via stdin and render it as Gemtext. The main use case this fulfils is the rendering of Gemtext files via stdin (see #205) but plaintext is also handled.