Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/cmd/root/help_topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ var HelpTopics = []helpTopic{

%[1]sGH_PATH%[1]s: set the path to the gh executable, useful for when gh can not properly determine
its own path such as in the cygwin terminal.

%[1]sGH_MDWIDTH%[1]s: default maximum width for markdown render wrapping. The max width of lines
wrapped on the terminal will be taken as the lesser of the terminal width, this value, or 120 if
not specified. This value is used, for example, with %[1]spr view%[1]s subcommand.
`, "`"),
},
{
Expand Down
14 changes: 11 additions & 3 deletions pkg/markdown/markdown.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package markdown

import (
"os"
"strconv"

"github.com/charmbracelet/glamour"
ghMarkdown "github.com/cli/go-gh/v2/pkg/markdown"
)
Expand All @@ -10,11 +13,16 @@ func WithoutIndentation() glamour.TermRendererOption {
}

// WithWrap is a rendering option that set the character limit for soft
// wrapping the markdown rendering. There is a max limit of 120 characters.
// wrapping the markdown rendering. There is a max limit of 120 characters,
// unless the user overrides with an environment variable.
// If 0 is passed then wrapping is disabled.
func WithWrap(w int) glamour.TermRendererOption {
if w > 120 {
w = 120
width, err := strconv.Atoi(os.Getenv("GH_MDWIDTH"))
if err != nil {
width = 120
}
if w > width {
w = width
}
return ghMarkdown.WithWrap(w)
}
Expand Down