Skip to content

Commit

Permalink
docs(examples): fix glamour example (#1204)
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm authored Dec 16, 2024
1 parent 39f9fae commit 2060f93
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion examples/glamour/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,20 @@ func newExample() (*example, error) {
BorderForeground(lipgloss.Color("62")).
PaddingRight(2)

// We need to adjust the width of the glamour render from our main width
// to account for a few things:
//
// * The viewport border width
// * The viewport padding
// * The viewport margins
// * The gutter glamour applies to the left side of the content
//
const glamourGutter = 2
glamourRenderWidth := width - vp.Style.GetHorizontalFrameSize() - glamourGutter

renderer, err := glamour.NewTermRenderer(
glamour.WithAutoStyle(),
glamour.WithWordWrap(width),
glamour.WithWordWrap(glamourRenderWidth),
)
if err != nil {
return nil, err
Expand Down

0 comments on commit 2060f93

Please sign in to comment.