Home

ugit @main - refs - log -
-
https://git.jolheiser.com/ugit.git
The code powering this h*ckin' site
tree log patch
feat: custom lexer registry Signed-off-by: jolheiser <git@jolheiser.com>
Signature
-----BEGIN SSH SIGNATURE----- U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgBTEvCQk6VqUAdN2RuH6bj1dNkY oOpbPWj+jw4ua1B1cAAAADZ2l0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5 AAAAQBuGox801o5i7Izov55rKidmjFrA7UssuZCE7jQfH1CxdbvWjGsvZZnp5KfXFnxg9i /iJth50AUqYoLJ3EVQKA8= -----END SSH SIGNATURE-----
jolheiser <git@jolheiser.com>
3 months ago
1 changed files, 8 additions(+), 0 deletions(-)
M internal/html/markup/chroma.go -> internal/html/markup/chroma.go
diff --git a/internal/html/markup/chroma.go b/internal/html/markup/chroma.go
index c1d83f315181e3cb9190f783ca8b025474f1365a..57efa7227eb001dd5eae7c56d5bd8853190d2055 100644
--- a/internal/html/markup/chroma.go
+++ b/internal/html/markup/chroma.go
@@ -2,6 +2,7 @@ package markup
 
 import (
 	"io"
+	"path/filepath"
 
 	"github.com/alecthomas/chroma/v2"
 	"github.com/alecthomas/chroma/v2/formatters/html"
@@ -26,10 +27,17 @@ )
 
 type code struct{}
 
+var customReg = map[string]string{
+	".hujson": "json",
+}
+
 func setup(source []byte, fileName string) (chroma.Iterator, *chroma.Style, error) {
 	lexer := lexers.Match(fileName)
 	if lexer == nil {
 		lexer = lexers.Fallback
+		if name, ok := customReg[filepath.Ext(fileName)]; ok {
+			lexer = lexers.Get(name)
+		}
 	}
 	lexer = chroma.Coalesce(lexer)