Add custom theming

This commit is contained in:
2026-07-28 20:09:40 +02:00
parent a0098a3946
commit ef32aa473e
14 changed files with 687 additions and 147 deletions

38
highlight_lexer_test.go Normal file
View File

@@ -0,0 +1,38 @@
package main
import (
"testing"
"github.com/alecthomas/chroma/v2/lexers"
)
func TestLexerForPathUsesCompleteFilename(t *testing.T) {
tests := []struct {
path string
want string
}{
{"Dockerfile", "Docker"},
{"Makefile", "Makefile"},
{"src/component.tsx", "TypeScript"},
{"scripts/check.py", "Python"},
{".github/workflows/test.yml", "YAML"},
}
for _, test := range tests {
t.Run(test.path, func(t *testing.T) {
got := lexerForPath(test.path)
lexer := lexers.Get(got)
if lexer == nil {
t.Fatalf("lexerForPath(%q) = %q, which is not registered", test.path, got)
}
if lexer.Config().Name != test.want {
t.Fatalf("lexerForPath(%q) selected %q, want %q", test.path, lexer.Config().Name, test.want)
}
})
}
}
func TestLexerForUnknownPathAllowsContentAnalysis(t *testing.T) {
if got := lexerForPath("LICENSE.unknown-extension"); got != "" {
t.Fatalf("unknown path selected %q instead of allowing content analysis", got)
}
}