Skip to content

Commit d3e3248

Browse files
committed
Unexport glamour color code function
This isn't really needed beyond this package, so unexporting it to avoid unintended use cases.
1 parent 84d9618 commit d3e3248

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

pkg/x/markdown/accessibility.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const (
3131
brightWhite
3232
)
3333

34-
func (a glamourStyleColor) Code() *string {
34+
func (a glamourStyleColor) code() *string {
3535
s := strconv.Itoa(int(a))
3636
return &s
3737
}
@@ -51,25 +51,25 @@ func accessibleDarkStyleConfig() ansi.StyleConfig {
5151
cfg := styles.DarkStyleConfig
5252

5353
// Text color
54-
cfg.Document.StylePrimitive.Color = white.Code()
54+
cfg.Document.StylePrimitive.Color = white.code()
5555

5656
// Link colors
57-
cfg.Link.Color = brightCyan.Code()
57+
cfg.Link.Color = brightCyan.code()
5858

5959
// Heading colors
60-
cfg.Heading.StylePrimitive.Color = brightMagenta.Code()
61-
cfg.H1.StylePrimitive.Color = brightWhite.Code()
62-
cfg.H1.StylePrimitive.BackgroundColor = brightBlue.Code()
60+
cfg.Heading.StylePrimitive.Color = brightMagenta.code()
61+
cfg.H1.StylePrimitive.Color = brightWhite.code()
62+
cfg.H1.StylePrimitive.BackgroundColor = brightBlue.code()
6363

6464
// Code colors
65-
cfg.Code.BackgroundColor = brightWhite.Code()
66-
cfg.Code.Color = red.Code()
65+
cfg.Code.BackgroundColor = brightWhite.code()
66+
cfg.Code.Color = red.code()
6767

6868
// Image colors
69-
cfg.Image.Color = brightMagenta.Code()
69+
cfg.Image.Color = brightMagenta.code()
7070

7171
// Horizontal rule colors
72-
cfg.HorizontalRule.Color = white.Code()
72+
cfg.HorizontalRule.Color = white.code()
7373

7474
return cfg
7575
}
@@ -78,25 +78,25 @@ func accessibleLightStyleConfig() ansi.StyleConfig {
7878
cfg := styles.LightStyleConfig
7979

8080
// Text color
81-
cfg.Document.StylePrimitive.Color = black.Code()
81+
cfg.Document.StylePrimitive.Color = black.code()
8282

8383
// Link colors
84-
cfg.Link.Color = brightBlue.Code()
84+
cfg.Link.Color = brightBlue.code()
8585

8686
// Heading colors
87-
cfg.Heading.StylePrimitive.Color = magenta.Code()
88-
cfg.H1.StylePrimitive.Color = brightWhite.Code()
89-
cfg.H1.StylePrimitive.BackgroundColor = blue.Code()
87+
cfg.Heading.StylePrimitive.Color = magenta.code()
88+
cfg.H1.StylePrimitive.Color = brightWhite.code()
89+
cfg.H1.StylePrimitive.BackgroundColor = blue.code()
9090

9191
// Code colors
92-
cfg.Code.BackgroundColor = brightWhite.Code()
93-
cfg.Code.Color = red.Code()
92+
cfg.Code.BackgroundColor = brightWhite.code()
93+
cfg.Code.Color = red.code()
9494

9595
// Image colors
96-
cfg.Image.Color = magenta.Code()
96+
cfg.Image.Color = magenta.code()
9797

9898
// Horizontal rule colors
99-
cfg.HorizontalRule.Color = white.Code()
99+
cfg.HorizontalRule.Color = white.code()
100100

101101
return cfg
102102
}

pkg/x/markdown/accessibility_test.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestGlamourStyleColors(t *testing.T) {
9898
}
9999
for _, tt := range tests {
100100
t.Run(tt.name, func(t *testing.T) {
101-
assert.Equal(t, tt.want, *tt.c.Code())
101+
assert.Equal(t, tt.want, *tt.c.code())
102102
})
103103
}
104104
}
@@ -134,31 +134,31 @@ func TestAccessibleStyleConfig(t *testing.T) {
134134

135135
func Test_accessibleDarkStyleConfig(t *testing.T) {
136136
cfg := accessibleDarkStyleConfig()
137-
assert.Equal(t, white.Code(), cfg.Document.StylePrimitive.Color)
138-
assert.Equal(t, brightCyan.Code(), cfg.Link.Color)
139-
assert.Equal(t, brightMagenta.Code(), cfg.Heading.StylePrimitive.Color)
140-
assert.Equal(t, brightWhite.Code(), cfg.H1.StylePrimitive.Color)
141-
assert.Equal(t, brightBlue.Code(), cfg.H1.StylePrimitive.BackgroundColor)
142-
assert.Equal(t, brightWhite.Code(), cfg.Code.BackgroundColor)
143-
assert.Equal(t, red.Code(), cfg.Code.Color)
144-
assert.Equal(t, brightMagenta.Code(), cfg.Image.Color)
145-
assert.Equal(t, white.Code(), cfg.HorizontalRule.Color)
137+
assert.Equal(t, white.code(), cfg.Document.StylePrimitive.Color)
138+
assert.Equal(t, brightCyan.code(), cfg.Link.Color)
139+
assert.Equal(t, brightMagenta.code(), cfg.Heading.StylePrimitive.Color)
140+
assert.Equal(t, brightWhite.code(), cfg.H1.StylePrimitive.Color)
141+
assert.Equal(t, brightBlue.code(), cfg.H1.StylePrimitive.BackgroundColor)
142+
assert.Equal(t, brightWhite.code(), cfg.Code.BackgroundColor)
143+
assert.Equal(t, red.code(), cfg.Code.Color)
144+
assert.Equal(t, brightMagenta.code(), cfg.Image.Color)
145+
assert.Equal(t, white.code(), cfg.HorizontalRule.Color)
146146

147147
// Test that we haven't changed the original style
148148
assert.Equal(t, styles.DarkStyleConfig.H2, cfg.H2)
149149
}
150150

151151
func Test_accessibleLightStyleConfig(t *testing.T) {
152152
cfg := accessibleLightStyleConfig()
153-
assert.Equal(t, black.Code(), cfg.Document.StylePrimitive.Color)
154-
assert.Equal(t, brightBlue.Code(), cfg.Link.Color)
155-
assert.Equal(t, magenta.Code(), cfg.Heading.StylePrimitive.Color)
156-
assert.Equal(t, brightWhite.Code(), cfg.H1.StylePrimitive.Color)
157-
assert.Equal(t, blue.Code(), cfg.H1.StylePrimitive.BackgroundColor)
158-
assert.Equal(t, brightWhite.Code(), cfg.Code.BackgroundColor)
159-
assert.Equal(t, red.Code(), cfg.Code.Color)
160-
assert.Equal(t, magenta.Code(), cfg.Image.Color)
161-
assert.Equal(t, white.Code(), cfg.HorizontalRule.Color)
153+
assert.Equal(t, black.code(), cfg.Document.StylePrimitive.Color)
154+
assert.Equal(t, brightBlue.code(), cfg.Link.Color)
155+
assert.Equal(t, magenta.code(), cfg.Heading.StylePrimitive.Color)
156+
assert.Equal(t, brightWhite.code(), cfg.H1.StylePrimitive.Color)
157+
assert.Equal(t, blue.code(), cfg.H1.StylePrimitive.BackgroundColor)
158+
assert.Equal(t, brightWhite.code(), cfg.Code.BackgroundColor)
159+
assert.Equal(t, red.code(), cfg.Code.Color)
160+
assert.Equal(t, magenta.code(), cfg.Image.Color)
161+
assert.Equal(t, white.code(), cfg.HorizontalRule.Color)
162162

163163
// Test that we haven't changed the original style
164164
assert.Equal(t, styles.LightStyleConfig.H2, cfg.H2)

0 commit comments

Comments
 (0)