diff options
author | Runxi Yu <me@runxiyu.org> | 2025-04-06 09:58:02 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-04-06 09:58:02 +0800 |
commit | 6f5e22e764283262ae8c6519bb030766db0fd35b (patch) | |
tree | c56038bd7b5dc31d5bae5dd6e323688725c5262e /forged/internal/render/chroma.go | |
parent | Fix load ordering issue that causes the forge title to disappear (diff) | |
download | forge-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.go | 3 |
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 { |