aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go.mod1
-rw-r--r--go.sum2
-rw-r--r--render_readme.go15
3 files changed, 18 insertions, 0 deletions
diff --git a/go.mod b/go.mod
index ad8f9fd..14fe392 100644
--- a/go.mod
+++ b/go.mod
@@ -7,6 +7,7 @@ require (
github.com/go-git/go-git/v5 v5.13.2
github.com/jackc/pgx/v5 v5.7.2
github.com/microcosm-cc/bluemonday v1.0.27
+ github.com/niklasfasching/go-org v1.7.0
github.com/yuin/goldmark v1.7.8
go.lindenii.runxiyu.org/lindenii-common v0.0.0-20250211153243-8946fae17bd0
)
diff --git a/go.sum b/go.sum
index 1a4b5e8..a02be3f 100644
--- a/go.sum
+++ b/go.sum
@@ -69,6 +69,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
+github.com/niklasfasching/go-org v1.7.0 h1:vyMdcMWWTe/XmANk19F4k8XGBYg0GQ/gJGMimOjGMek=
+github.com/niklasfasching/go-org v1.7.0/go.mod h1:WuVm4d45oePiE0eX25GqTDQIt/qPW1T9DGkRscqLW5o=
github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4=
diff --git a/render_readme.go b/render_readme.go
index 32a3a7d..497b3ec 100644
--- a/render_readme.go
+++ b/render_readme.go
@@ -4,9 +4,11 @@ import (
"bytes"
"html"
"html/template"
+ "strings"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/microcosm-cc/bluemonday"
+ "github.com/niklasfasching/go-org/org"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/extension"
)
@@ -38,6 +40,19 @@ func render_readme_at_tree(tree *object.Tree) (readme_filename string, readme_co
return "README.md", template.HTML(bluemonday.UGCPolicy().SanitizeBytes(readme_rendered_unsafe.Bytes()))
}
+ readme_file, err = tree.File("README.org")
+ if err == nil {
+ readme_file_contents, err := readme_file.Contents()
+ if err != nil {
+ return "Error fetching README", string_escape_html("Unable to fetch contents of README: " + err.Error())
+ }
+ org_html, err := org.New().Parse(strings.NewReader(readme_file_contents), readme_filename).Write(org.NewHTMLWriter())
+ if err != nil {
+ return "Error fetching README", string_escape_html("Unable to render README: " + err.Error())
+ }
+ return "README.org", template.HTML(bluemonday.UGCPolicy().Sanitize(org_html))
+ }
+
return "", ""
}