From 945ed13ce34866b6464073de953a664237643665 Mon Sep 17 00:00:00 2001 From: Andy Feller Date: Tue, 25 Feb 2025 08:22:24 -0500 Subject: [PATCH 1/3] Add multiple term renderer option support `WithOptions(...TermRendererOption) TermRendererOption` function is a solution for users who follow the `WithXXX() TermRendererOption` pattern but need to apply multiple options but are not directly responsible for rendering. --- glamour.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/glamour.go b/glamour.go index 6e1e7e40..6299c49b 100644 --- a/glamour.go +++ b/glamour.go @@ -215,6 +215,18 @@ func WithChromaFormatter(formatter string) TermRendererOption { } } +// WithOptions sets multiple TermRenderer options within a single TermRendererOption. +func WithOptions(options ...TermRendererOption) TermRendererOption { + return func(tr *TermRenderer) error { + for _, o := range options { + if err := o(tr); err != nil { + return err + } + } + return nil + } +} + func (tr *TermRenderer) Read(b []byte) (int, error) { return tr.renderBuf.Read(b) } From 4e3175a72623581de3aa61d2fe4672122f210f4d Mon Sep 17 00:00:00 2001 From: Andy Feller Date: Tue, 25 Feb 2025 08:39:26 -0500 Subject: [PATCH 2/3] Update module name to use as a fork --- examples/artichokes/main.go | 2 +- examples/custom_renderer/main.go | 2 +- examples/helloworld/main.go | 2 +- examples/stdin-stdout-custom-styles/main.go | 2 +- examples/stdin-stdout/main.go | 2 +- glamour.go | 4 ++-- glamour_test.go | 2 +- go.mod | 2 +- internal/generate-style-json/main.go | 4 ++-- styles/dracula.go | 2 +- styles/styles.go | 2 +- styles/tokyo-night.go | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/examples/artichokes/main.go b/examples/artichokes/main.go index 231f154e..614f632b 100644 --- a/examples/artichokes/main.go +++ b/examples/artichokes/main.go @@ -6,7 +6,7 @@ import ( "log" "os" - "github.com/charmbracelet/glamour" + "github.com/cli/glamour" "github.com/muesli/termenv" ) diff --git a/examples/custom_renderer/main.go b/examples/custom_renderer/main.go index e92b0ae5..09a09f55 100644 --- a/examples/custom_renderer/main.go +++ b/examples/custom_renderer/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "github.com/charmbracelet/glamour" + "github.com/cli/glamour" ) func main() { diff --git a/examples/helloworld/main.go b/examples/helloworld/main.go index 53282da3..c4e1d0c8 100644 --- a/examples/helloworld/main.go +++ b/examples/helloworld/main.go @@ -3,7 +3,7 @@ package main import ( "fmt" - "github.com/charmbracelet/glamour" + "github.com/cli/glamour" ) func main() { diff --git a/examples/stdin-stdout-custom-styles/main.go b/examples/stdin-stdout-custom-styles/main.go index 7633cf39..7296a2a3 100644 --- a/examples/stdin-stdout-custom-styles/main.go +++ b/examples/stdin-stdout-custom-styles/main.go @@ -14,7 +14,7 @@ import ( "io" "os" - "github.com/charmbracelet/glamour" + "github.com/cli/glamour" ) const defaultWidth = 80 diff --git a/examples/stdin-stdout/main.go b/examples/stdin-stdout/main.go index 83e0dcfe..47acbb3a 100644 --- a/examples/stdin-stdout/main.go +++ b/examples/stdin-stdout/main.go @@ -14,7 +14,7 @@ import ( "io" "os" - "github.com/charmbracelet/glamour" + "github.com/cli/glamour" ) const defaultWidth = 80 diff --git a/glamour.go b/glamour.go index 6299c49b..07b53d3b 100644 --- a/glamour.go +++ b/glamour.go @@ -15,8 +15,8 @@ import ( "github.com/yuin/goldmark/util" "golang.org/x/term" - "github.com/charmbracelet/glamour/ansi" - styles "github.com/charmbracelet/glamour/styles" + "github.com/cli/glamour/ansi" + styles "github.com/cli/glamour/styles" ) const ( diff --git a/glamour_test.go b/glamour_test.go index 4114998f..70c6e011 100644 --- a/glamour_test.go +++ b/glamour_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - styles "github.com/charmbracelet/glamour/styles" "github.com/charmbracelet/x/exp/golden" + styles "github.com/cli/glamour/styles" ) const markdown = "testdata/readme.markdown.in" diff --git a/go.mod b/go.mod index 89af5a9c..5a631997 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/charmbracelet/glamour +module github.com/cli/glamour go 1.21 diff --git a/internal/generate-style-json/main.go b/internal/generate-style-json/main.go index ee2adb81..6a90c7ef 100644 --- a/internal/generate-style-json/main.go +++ b/internal/generate-style-json/main.go @@ -6,8 +6,8 @@ import ( "os" "path/filepath" - "github.com/charmbracelet/glamour/ansi" - styles "github.com/charmbracelet/glamour/styles" + "github.com/cli/glamour/ansi" + styles "github.com/cli/glamour/styles" ) func writeStyleJSON(filename string, styleConfig *ansi.StyleConfig) error { diff --git a/styles/dracula.go b/styles/dracula.go index 12eaf9d4..73c9c2e1 100644 --- a/styles/dracula.go +++ b/styles/dracula.go @@ -1,6 +1,6 @@ package styles -import "github.com/charmbracelet/glamour/ansi" +import "github.com/cli/glamour/ansi" // DraculaStyleConfig is the dracula style. var DraculaStyleConfig = ansi.StyleConfig{ diff --git a/styles/styles.go b/styles/styles.go index 422c7cfe..d29be6ed 100644 --- a/styles/styles.go +++ b/styles/styles.go @@ -3,7 +3,7 @@ package styles //go:generate go run ../internal/generate-style-json import ( - "github.com/charmbracelet/glamour/ansi" + "github.com/cli/glamour/ansi" ) const ( diff --git a/styles/tokyo-night.go b/styles/tokyo-night.go index 5cb966e2..17bd16cb 100644 --- a/styles/tokyo-night.go +++ b/styles/tokyo-night.go @@ -1,6 +1,6 @@ package styles -import "github.com/charmbracelet/glamour/ansi" +import "github.com/cli/glamour/ansi" // TokyoNightStyle is the tokyo night style. var TokyoNightStyleConfig = ansi.StyleConfig{ From b1d96ed4a7e1556dade6e8bc41dfc16d9e1bb92d Mon Sep 17 00:00:00 2001 From: Andy Feller Date: Tue, 25 Feb 2025 08:45:31 -0500 Subject: [PATCH 3/3] Ensure README is clear about nature of fork This is a temporary fork to allow the GitHub CLI to experiment with deeper integration with charmbracelet/glamour; it is not meant to be long lived. This commit is meant to give clear understanding as we want to collaborate with the Charm team to improve Glamour. --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index db440e94..8082c29a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,10 @@ -# Glamour +# Why is this forked? + +This is hard forked from github.com/charmbracelet/glamour to allow the `gh` maintainers to enhance the use of `glamour` in `gh`, while providing the flexibility for us to share modifications and extensions. It is not intended to be a long-term maintained fork and you should not rely on it. + +Once we determine how to address concerns for the project, we will decide what to do next based on how our needs align with the preferences of the maintainers of charmbracelet/glamour. + +## Original README with minor tweaks to indicate upstream/fork relationship

Glamour Title Treatment