feat: --preserve-new-lines (#623)

closes #502
This commit is contained in:
Carlos Alexandro Becker 2024-07-09 09:50:10 -03:00 committed by GitHub
commit d89d79a00c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 17 deletions

View file

@ -2,12 +2,13 @@ package ui
// Config contains TUI-specific configuration.
type Config struct {
ShowAllFiles bool
Gopath string `env:"GOPATH"`
HomeDir string `env:"HOME"`
GlamourMaxWidth uint
GlamourStyle string
EnableMouse bool
ShowAllFiles bool
Gopath string `env:"GOPATH"`
HomeDir string `env:"HOME"`
GlamourMaxWidth uint
GlamourStyle string
EnableMouse bool
PreserveNewLines bool
// Which directory should we start from?
WorkingDirectory string

View file

@ -399,10 +399,15 @@ func glamourRender(m pagerModel, markdown string) (string, error) {
width = 0
}
r, err := glamour.NewTermRenderer(
options := []glamour.TermRendererOption{
utils.GlamourStyle(m.common.cfg.GlamourStyle, isCode),
glamour.WithWordWrap(width),
)
}
if m.common.cfg.PreserveNewLines {
options = append(options, glamour.WithPreservedNewLines())
}
r, err := glamour.NewTermRenderer(options...)
if err != nil {
return "", err
}