Table formatting breaks if output is piped
Describe the bug
Table formatting breaks when stdout is piped to a file or a program. glow seems to detect if stdout is connected to a tty, and leaves out some table formatting if it's not.
I would like to pipe glow output to tools like grep and fzf and still have the correct table formatting.
Setup Please complete the following information along with version numbers, if applicable.
- OS [e.g. Ubuntu, macOS]: Ubuntu 22.04
- Shell [e.g. zsh, fish]: zsh
- Terminal Emulator [e.g. kitty, iterm]: kitty
- Terminal Multiplexer [e.g. tmux]: Bug reproduces both with and without tmux
- Locale [e.g. en_US.UTF-8, zh_CN.UTF-8, etc.]: en_US.UTF-8
To Reproduce Steps to reproduce the behavior:
$ glow test.md
FIRST COLUMN │ SECOND COLUMN
───────────────┼────────────────
Foo │ Bar
│ Baz
$ glow test.md | cat
FIRST COLUMN │ SECOND COLUMN
───────────────┼────────────────
Foo │ Bar
│ Baz
$ socat - EXEC:'glow test.md',pty,setsid,ctty | cat
FIRST COLUMN │ SECOND COLUMN
───────────────┼────────────────
Foo │ Bar
│ Baz
Source Code Please include source code if needed to reproduce the behavior.
| First column | Second column |
|--------------|---------------|
| Foo | Bar |
| | Baz |
Expected behavior Table formatting should be maintained regardless of TTY presence.
Screenshots
Additional context N/A
PS.: After reading main.go it turns out that this bug can be mitigated with explicit style option (e.g. -s dark)
OTOH, it can be reproduced without piping, by selecting the "notty" style
$ glow -s notty test.md
FIRST COLUMN │ SECOND COLUMN
───────────────┼────────────────
Foo │ Bar
│ Baz
yeah, I think this is on purpose since the output is not a TTY...
imho not a bug.
If output like this is on purpose, what would be the use case? (Genuine question). OTOH, what use case would break if the tables were correctly formatted even when not directly output to a TTY?
FIRST COLUMN │ SECOND COLUMN
───────────────┼────────────────
Foo │ Bar
│ Baz