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

Table formatting breaks if output is piped #545

Open
patrislav1 opened this issue Nov 28, 2023 · 1 comment
Open

Table formatting breaks if output is piped #545

patrislav1 opened this issue Nov 28, 2023 · 1 comment

Comments

@patrislav1
Copy link

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
image

Additional context
N/A

@patrislav1
Copy link
Author

patrislav1 commented Nov 28, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant