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

View File

@@ -3,11 +3,11 @@ package main
import (
"bytes"
"fmt"
"path/filepath"
"regexp"
"strconv"
"strings"
"github.com/alecthomas/chroma/v2/lexers"
"github.com/alecthomas/chroma/v2/quick"
)
@@ -252,9 +252,9 @@ func highlightedSource(lexer, source string) string {
}
func lexerForPath(path string) string {
ext := strings.TrimPrefix(filepath.Ext(path), ".")
if ext == "" {
return "plaintext"
lexer := lexers.Match(path)
if lexer == nil {
return ""
}
return ext
return lexer.Config().Name
}