5
5
"fmt"
6
6
"os"
7
7
"strings"
8
- "sync"
9
8
10
9
"github.com/alecthomas/chroma/v2"
11
10
chromaStyles "github.com/alecthomas/chroma/v2/styles"
@@ -23,8 +22,6 @@ const (
23
22
chromaStyleTheme = "kyma"
24
23
)
25
24
26
- var chromaMutex = sync.RWMutex {}
27
-
28
25
type Properties struct {
29
26
Title string `yaml:"title"`
30
27
Style StyleConfig `yaml:"style"`
@@ -317,19 +314,9 @@ func ChromaStyle(style ansi.StylePrimitive) string {
317
314
func GetChromaStyle (themeName string ) * chroma.Style {
318
315
customThemeName := chromaStyleTheme + "-" + themeName
319
316
320
- switch themeName {
321
- case "dracula" :
322
- return chromaStyles .Get ("dracula" )
323
- case "tokyo-night" , "tokyonight" :
324
- return chromaStyles .Get ("tokyo-night" )
325
- }
326
-
327
- chromaMutex .RLock ()
328
317
if chromaStyle , ok := chromaStyles .Registry [customThemeName ]; ok {
329
- chromaMutex .RUnlock ()
330
318
return chromaStyle
331
319
}
332
- chromaMutex .RUnlock ()
333
320
334
321
styleConfig := getTheme (themeName )
335
322
style := styleConfig .Style
@@ -370,16 +357,19 @@ func GetChromaStyle(themeName string) *chroma.Style {
370
357
chroma .Background : ChromaStyle (style .CodeBlock .Chroma .Background ),
371
358
})
372
359
373
- chromaMutex .Lock ()
374
-
375
360
if existingStyle , ok := chromaStyles .Registry [customThemeName ]; ok {
376
- chromaMutex .Unlock ()
377
361
return existingStyle
378
362
}
379
363
chromaStyles .Register (newStyle )
380
- chromaMutex .Unlock ()
381
364
return newStyle
382
365
}
383
366
384
- return chromaStyles .Fallback
367
+ switch themeName {
368
+ case "dracula" :
369
+ return chromaStyles .Get ("dracula" )
370
+ case "tokyo-night" , "tokyonight" :
371
+ return chromaStyles .Get ("tokyo-night" )
372
+ default :
373
+ return chromaStyles .Fallback
374
+ }
385
375
}
0 commit comments