aboutsummaryrefslogtreecommitdiff
path: root/forged/internal/render/chroma.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-06 09:58:02 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-06 09:58:02 +0800
commit6f5e22e764283262ae8c6519bb030766db0fd35b (patch)
treec56038bd7b5dc31d5bae5dd6e323688725c5262e /forged/internal/render/chroma.go
parentFix load ordering issue that causes the forge title to disappear (diff)
downloadforge-6f5e22e764283262ae8c6519bb030766db0fd35b.tar.gz
forge-6f5e22e764283262ae8c6519bb030766db0fd35b.tar.zst
forge-6f5e22e764283262ae8c6519bb030766db0fd35b.zip
Add more documentation comments
Diffstat (limited to 'forged/internal/render/chroma.go')
-rw-r--r--forged/internal/render/chroma.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/forged/internal/render/chroma.go b/forged/internal/render/chroma.go
index c1a1869..64bfde0 100644
--- a/forged/internal/render/chroma.go
+++ b/forged/internal/render/chroma.go
@@ -12,6 +12,9 @@ import (
chromaStyles "github.com/alecthomas/chroma/v2/styles"
)
+// Highlight returns HTML with syntax highlighting for the given file content,
+// using Chroma. The lexer is selected based on the filename.
+// If tokenization or formatting fails, a fallback <pre> block is returned with the error.
func Highlight(filename, content string) template.HTML {
lexer := chromaLexers.Match(filename)
if lexer == nil {