charmbracelet / freeze

Generate images of code and terminal output 📸
MIT License
3.24k stars 55 forks source link

Piped content boundaries are not correct #50

Closed sattellite closed 6 months ago

sattellite commented 6 months ago

Describe the bug The text extends beyond the borders of the image.

To Reproduce

config.go ```go package config import ( "fmt" "os" "reflect" "strconv" "strings" ) type Config struct { Telegram struct { Token string `env:"TG_TOKEN"` ChatID string `env:"TG_CHAT"` OwnerID string `env:"TG_ADMIN"` } Database struct { DSN string `env:"DB_DSN"` } Log struct { Level string `env:"LOG_LEVEL"` } Debug bool } func Load() (*Config, error) { var c Config err := parseStruct(&c, "") if err != nil { return nil, err } return &c, nil } ```

cat config.go | freeze --language go --theme murphy

Expected behavior I expect the image to be a little wider so that the data inside the tags will fit completely into the image. And also the colored background of the symbols will be in correct place.

Screenshots

Resulted image ![screenshot](https://github.com/charmbracelet/freeze/assets/322910/1d4d01bf-4846-44e6-b743-518d9ad96fe1)

Desktop (please complete the following information):

maaslalani commented 6 months ago

Hey @sattellite, thanks for the issue! I am unable to reproduce. When I run the following:

cat config.go | freeze --language go --theme murphy

I get the following:

freeze

NB: This conversion is using libsvg (rsvg-convert) which is installed on my computer. Let me try again with the normal resvg-go.

sattellite commented 6 months ago

Try to use config.go from my message, please. I can reproduce that behaviour on intel mac and m2 mac. First message from m2 mac.

freeze 0.1.4 installed with go install github.com/charmbracelet/freeze@latest command on both computers.

And in both cases used resvg-go.

screenshot from intel mac ![freeze](https://github.com/charmbracelet/freeze/assets/322910/213472ab-efd4-47e5-9156-14a566085861)
maaslalani commented 6 months ago

Ah you're absolutely correct @sattellite, I am able to reproduce with your code. Thank you, I will fix this issue!

maaslalani commented 6 months ago

@sattellite The issue was tabs in the code were causing miscalculations in the width. This is now fixed on main! Thank you for the report and awesome reproduction instructions!

maaslalani commented 6 months ago

freeze