Add custom theming
This commit is contained in:
10
highlight.go
10
highlight.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user