Skip to content

Commit

Permalink
Truncate long lines in Glamour output to fix layout
Browse files Browse the repository at this point in the history
In some cases a few characters at the end of very long words like URLs
will now be dropped. This likely needs to be fixed upstream.
  • Loading branch information
meowgorithm committed Sep 22, 2021
1 parent 583b01c commit 22c47ee
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tui/bubbles/repo/bubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/lipgloss"
"github.com/muesli/reflow/truncate"
"github.com/muesli/reflow/wordwrap"
"github.com/muesli/reflow/wrap"
)

Expand Down Expand Up @@ -219,10 +218,15 @@ func (b *Bubble) glamourize(md string) (string, error) {
if err != nil {
return "", err
}
// Enforce a maximum width for cases when glamour lines run long.
// For now, truncate long lines in Glamour that would otherwise break the
// layout when wrapping. This is very likely due to #43 in Reflow, which
// has to do with a bug in the way lines longer than the given width are
// wrapped.
//
// TODO: This should utlimately be implemented as a Glamour option.
mdt = wrap.String(wordwrap.String((mdt), w), w)
// https://github.com/muesli/reflow/issues/43
//
// TODO: solve this upstream in Glamour/Reflow.
mdt = lipgloss.NewStyle().MaxWidth(w).Render(mdt)
return mdt, nil
}

Expand Down

0 comments on commit 22c47ee

Please sign in to comment.