@@ -3,6 +3,7 @@ package issues
33import (
44 "bytes"
55 "fmt"
6+ "os"
67 "regexp"
78 "strings"
89
@@ -24,8 +25,16 @@ type Printer struct {
2425func NewPrinter () (* Printer , error ) {
2526 terminal := term .FromEnv ()
2627 termWidth , _ , _ := terminal .Size ()
28+ opts := []glamour.TermRendererOption {
29+ glamour .WithWordWrap (termWidth ),
30+ }
31+ if ! terminal .IsColorEnabled () {
32+ opts = append (opts , glamour .WithStyles (glamour .NoTTYStyleConfig ))
33+ } else {
34+ opts = append (opts , glamour .WithStylePath (getEnvironmentStyle ()))
35+ }
2736
28- renderer , err := glamour .NewTermRenderer (glamour . WithWordWrap ( termWidth ), glamour . WithEnvironmentConfig () )
37+ renderer , err := glamour .NewTermRenderer (opts ... )
2938 if err != nil {
3039 return nil , fmt .Errorf ("while creating glamour renderer: %w" , err )
3140 }
@@ -98,3 +107,12 @@ func (p *Printer) PrintMissingOwnersFile(missingFiles []string, org string) erro
98107
99108 return nil
100109}
110+
111+ func getEnvironmentStyle () string {
112+ glamourStyle := os .Getenv ("GLAMOUR_STYLE" )
113+ if glamourStyle == "" {
114+ glamourStyle = glamour .AutoStyle
115+ }
116+
117+ return glamourStyle
118+ }
0 commit comments