summaryrefslogtreecommitdiff
path: root/src/gmi/tpl.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmi/tpl.go')
-rw-r--r--src/gmi/tpl.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gmi/tpl.go b/src/gmi/tpl.go
index 7f41993..9e0bc64 100644
--- a/src/gmi/tpl.go
+++ b/src/gmi/tpl.go
@@ -16,6 +16,7 @@ import (
"git.sr.ht/~adnano/go-gemini"
"github.com/mediocregopher/blog.mediocregopher.com/srv/post"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx"
+ gmnhg "github.com/tdemin/gmnhg"
)
//go:embed tpl
@@ -120,7 +121,19 @@ func (r renderer) PostBody(p post.StoredPost) (string, error) {
return "", fmt.Errorf("preprocessing post body: %w", err)
}
- return buf.String(), nil
+ bodyBytes := buf.Bytes()
+
+ if p.Format == post.FormatMarkdown {
+
+ gemtextBodyBytes, err := gmnhg.RenderMarkdown(bodyBytes, 0)
+ if err != nil {
+ return "", fmt.Errorf("converting from markdown: %w", err)
+ }
+
+ bodyBytes = gemtextBodyBytes
+ }
+
+ return string(bodyBytes), nil
}
func (r renderer) GetQueryValue(key, def string) string {