...
1 package styles
2
3 import (
4 "sort"
5
6 "github.com/alecthomas/chroma"
7 )
8
9
10 var Registry = map[string]*chroma.Style{}
11
12
13 var Fallback = SwapOff
14
15
16 func Register(style *chroma.Style) *chroma.Style {
17 Registry[style.Name] = style
18 return style
19 }
20
21
22 func Names() []string {
23 out := []string{}
24 for name := range Registry {
25 out = append(out, name)
26 }
27 sort.Strings(out)
28 return out
29 }
30
31
32 func Get(name string) *chroma.Style {
33 if style, ok := Registry[name]; ok {
34 return style
35 }
36 return Fallback
37 }
38
View as plain text