buildkite / terminal-to-html

Converts arbitrary shell output (with ANSI) into beautifully rendered HTML
http://buildkite.github.io/terminal-to-html
MIT License
649 stars 45 forks source link

`docker pull` output get's chopped in half #39

Closed keithpitt closed 7 years ago

keithpitt commented 7 years ago

Attached is a sample log output from a docker pull command.

sample.txt

When you run cat sample.txt you see this:

❯ cat /Users/keithpitt/Downloads/sample.txt                                                                                                                    
+ docker push 061442450191.dkr.ecr.eu-central-1.amazonaws.com/lol/thingy:9a5a7e9
The push refers to a repository [061442450191.dkr.ecr.eu-central-1.amazonaws.com/lol/thingy]
07e62ecb726a: Layer already exists
331743f747fb: Layer already exists
2543649889c9: Layer already exists
10f91d26a1a9: Layer already exists
4dd2f6cdfbcf: Layer already exists
d75290d8c3ab: Layer already exists
a4c405a1d61b: Layer already exists
d79093d63949: Layer already exists
87cbe568afdd: Layer already exists
787c930753b4: Layer already exists
9f17712cba0b: Layer already exists
223c0d04a137: Layer already exists
fe4c16cbf7a4: Layer already exists
9a5a7e9: digest: sha256:e0271b89d75b4bf43d89eda0de850770f8f0a026fc7d7e967124cbad3d41f5d3 size: 3052

When you run it through terminal, you get:

❯ cat sample.txt | godep go run cmd/terminal-to-html/*.go
223c0d04a137: Layer already exists
fe4c16cbf7a4: Layer already exists
9a5a7e9: digest: sha256:e0271b89d75b4bf43d89eda0de850770f8f0a026fc7d7e967124cbad3d41f5d3 size: 3052%

Something weird is going on, and I believe I've tracked it down to our up handling. Specifically our A instruction here:

screen shot 2017-02-27 at 10 56 43 am

Now during my testing, if I added this 1 line:

screen shot 2017-02-27 at 10 57 09 am

The problem went away. I don't think the adding of the character is fixing the issue, but when we append a ton of other internal other stuff takes place:

screen shot 2017-02-27 at 10 58 30 am

I spent half a day on this on Friday, and got sucked into a wormhole. The hard thing is not knowing what the correct behaviour is in a shell. So I'll need to pair with someone this week (probably @sj26) and get it fixed up.

lox commented 7 years ago

Thanks @keithpitt!

mipearson commented 7 years ago

@keithpitt I'm tempted to have a go at this - do you have a failing automated test case already?

keithpitt commented 7 years ago

@mipearson oh hai! I wasn't expecting you to have a crack, but I'll make a PR with a failing test case now.

mipearson commented 7 years ago

No promises, but I really really really miss hacking on Go, so if I get some time I'll have a crack.

keithpitt commented 7 years ago

@mipearson added a failing test case here: https://github.com/buildkite/terminal/pull/40