Skip to content

Commit

Permalink
Make markdown template function more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
benpate committed Sep 9, 2024
1 parent 6e15836 commit a78bf58
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/templates/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ func FuncMap(icons icon.Provider) template.FuncMap {
return template.HTML(value)
},

"markdown": func(value string) template.HTML {
"markdown": func(value any) template.HTML {

valueBytes := convert.Bytes(value)

// https://github.com/yuin/goldmark#built-in-extensions
var buffer bytes.Buffer
Expand All @@ -192,7 +194,7 @@ func FuncMap(icons icon.Provider) template.FuncMap {
goldmark.WithRendererOptions(),
)

if err := md.Convert([]byte(value), &buffer); err != nil {
if err := md.Convert([]byte(valueBytes), &buffer); err != nil {
derp.Report(derp.Wrap(err, "tools.templates.functions.markdown", "Error converting Markdown to HTML"))
}

Expand Down

0 comments on commit a78bf58

Please sign in to comment.