aboutsummaryrefslogtreecommitdiff
path: root/readme_to_html.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-31 16:59:18 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-31 16:59:18 +0800
commit655b6b211ae6df0186abd740f248939f7ddeaec1 (patch)
treeec5cdbbc52222f62c8fbb0bcf2a1aa7a9f6eb8b6 /readme_to_html.go
parentCorrect table headers in MR indices (diff)
downloadforge-655b6b211ae6df0186abd740f248939f7ddeaec1.tar.gz
forge-655b6b211ae6df0186abd740f248939f7ddeaec1.tar.zst
forge-655b6b211ae6df0186abd740f248939f7ddeaec1.zip
Add descriptive comments to most Go functions
Diffstat (limited to 'readme_to_html.go')
-rw-r--r--readme_to_html.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/readme_to_html.go b/readme_to_html.go
index 22f23a1..6d7bbbc 100644
--- a/readme_to_html.go
+++ b/readme_to_html.go
@@ -18,6 +18,8 @@ import (
var markdownConverter = goldmark.New(goldmark.WithExtensions(extension.GFM))
+// renderReadmeAtTree looks for README files in the supplied Git tree and
+// returns its filename and rendered (and sanitized) HTML.
func renderReadmeAtTree(tree *object.Tree) (readmeFilename string, readmeRenderedSafeHTML template.HTML) {
var readmeRenderedUnsafe bytes.Buffer
var readmeFile *object.File
@@ -60,6 +62,7 @@ func renderReadmeAtTree(tree *object.Tree) (readmeFilename string, readmeRendere
return "", ""
}
+// escapeHTML just escapes a string and wraps it in [template.HTML].
func escapeHTML(s string) template.HTML {
return template.HTML(html.EscapeString(s)) //#nosec G203
}