Skip to content

Commit 90f04d4

Browse files
jessemillarmislav
authored andcommitted
Enable custom color themes with the GLAMOUR_STYLE environment variable
1 parent 78124a9 commit 90f04d4

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ require (
66
github.com/AlecAivazis/survey/v2 v2.0.7
77
github.com/MakeNowJust/heredoc v1.0.0
88
github.com/briandowns/spinner v1.11.1
9-
github.com/charmbracelet/glamour v0.1.1-0.20200527150725-d3564681b966
9+
github.com/charmbracelet/glamour v0.2.1-0.20200724174618-1246d13c1684
1010
github.com/google/go-cmp v0.4.1
1111
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
1212
github.com/hashicorp/go-version v1.2.0
1313
github.com/henvic/httpretty v0.0.5
1414
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
1515
github.com/mattn/go-colorable v0.1.6
1616
github.com/mattn/go-isatty v0.0.12
17-
github.com/mattn/go-runewidth v0.0.9 // indirect
1817
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
1918
github.com/mitchellh/go-homedir v1.1.0
2019
github.com/shurcooL/githubv4 v0.0.0-20200627185320-e003124d66e4

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce
2525
github.com/briandowns/spinner v1.11.1 h1:OixPqDEcX3juo5AjQZAnFPbeUA0jvkp2qzB5gOZJ/L0=
2626
github.com/briandowns/spinner v1.11.1/go.mod h1:QOuQk7x+EaDASo80FEXwlwiA+j/PPIcX3FScO+3/ZPQ=
2727
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
28-
github.com/charmbracelet/glamour v0.1.1-0.20200527150725-d3564681b966 h1:UCm+1X58J8Q1E6PrkoQ/jQSIkie+9Ka2QjVe9osXd/4=
29-
github.com/charmbracelet/glamour v0.1.1-0.20200527150725-d3564681b966/go.mod h1:ECr5vYu2tKCePqAbZNUh94HiZDPMtbc9ggAy4n585JU=
28+
github.com/charmbracelet/glamour v0.2.1-0.20200724174618-1246d13c1684 h1:YMyvXRstOQc7n6eneHfudVMbARSCmZ7EZGjtTkkeB3A=
29+
github.com/charmbracelet/glamour v0.2.1-0.20200724174618-1246d13c1684/go.mod h1:UA27Kwj3QHialP74iU6C+Gpc8Y7IOAKupeKMLLBURWM=
3030
github.com/cli/shurcooL-graphql v0.0.0-20200707151639-0f7232a2bf7e h1:aq/1jlmtZoS6nlSp3yLOTZQ50G+dzHdeRNENgE/iBew=
3131
github.com/cli/shurcooL-graphql v0.0.0-20200707151639-0f7232a2bf7e/go.mod h1:it23pLwxmz6OyM6I5O0ATIXQS1S190Nas26L5Kahp4U=
3232
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
@@ -124,8 +124,8 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk
124124
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
125125
github.com/muesli/reflow v0.1.0 h1:oQdpLfO56lr5pgLvqD0TcjW85rDjSYSBVdiG1Ch1ddM=
126126
github.com/muesli/reflow v0.1.0/go.mod h1:I9bWAt7QTg/que/qmUCJBGlj7wEq8OAFBjPNjc6xK4I=
127-
github.com/muesli/termenv v0.5.2 h1:N1Y1dHRtx6OizOgaIQXd8SkJl4T/cCOV+YyWXiuLUEA=
128-
github.com/muesli/termenv v0.5.2/go.mod h1:O1/I6sw+6KcrgAmcs6uiUVr7Lui+DNVbHTzt9Lm/PlI=
127+
github.com/muesli/termenv v0.6.0 h1:zxvzTBmo4ZcxhNGGWeMz+Tttm51eF5bmPjfy4MCRYlk=
128+
github.com/muesli/termenv v0.6.0/go.mod h1:SohX91w6swWA4AYU+QmPx+aSgXhWO0juiyID9UZmbpA=
129129
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
130130
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
131131
github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8=
@@ -182,8 +182,8 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1
182182
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
183183
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
184184
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
185-
github.com/yuin/goldmark v1.1.30 h1:j4d4Lw3zqZelDhBksEo3BnWg9xhXRQGJPPSL6OApZjI=
186-
github.com/yuin/goldmark v1.1.30/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
185+
github.com/yuin/goldmark v1.2.0 h1:WOOcyaJPlzb8fZ8TloxFe8QZkhOOJx87leDa9MIT9dc=
186+
github.com/yuin/goldmark v1.2.0/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
187187
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
188188
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
189189
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=

utils/utils.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ func OpenInBrowser(url string) error {
2323
}
2424

2525
func RenderMarkdown(text string) (string, error) {
26-
style := "notty"
27-
// TODO: make color an input parameter
28-
if isColorEnabled() {
29-
style = "auto"
30-
}
31-
3226
// Glamour rendering preserves carriage return characters in code blocks, but
3327
// we need to ensure that no such characters are present in the output.
3428
text = strings.ReplaceAll(text, "\r\n", "\n")
3529

30+
renderStyle := glamour.WithStandardStyle("notty")
31+
// TODO: make color an input parameter
32+
if isColorEnabled() {
33+
renderStyle = glamour.WithEnvironmentConfig()
34+
}
35+
3636
tr, err := glamour.NewTermRenderer(
37-
glamour.WithStandardStyle(style),
37+
renderStyle,
3838
// glamour.WithBaseURL(""), // TODO: make configurable
3939
// glamour.WithWordWrap(80), // TODO: make configurable
4040
)

0 commit comments

Comments
 (0)