Support escaped and non-escaped markdown conversion

This commit is contained in:
Gabriel Garrido 2024-05-19 15:31:23 +02:00
parent b8a7f64e71
commit 4c0f5ac95d

View file

@ -257,10 +257,16 @@ func downloadAttachment(dir string, id string, url string) (string, error) {
} }
func resolveTemplate(templateFile string) (*template.Template, error) { func resolveTemplate(templateFile string) (*template.Template, error) {
converter := md.NewConverter("", true, nil) converter := md.NewConverter("", true, &md.Options{
EscapeMode: "disabled",
})
converterEscaped := md.NewConverter("", true, &md.Options{
EscapeMode: "basic",
})
funcs := sprig.FuncMap() funcs := sprig.FuncMap()
funcs["toMarkdown"] = converter.ConvertString funcs["toMarkdown"] = converter.ConvertString
funcs["toMarkdownEscaped"] = converterEscaped.ConvertString
if templateFile == "" { if templateFile == "" {
tmpl, err := template.New("post.tmpl").Funcs(funcs).ParseFS(templates, "templates/*.tmpl") tmpl, err := template.New("post.tmpl").Funcs(funcs).ParseFS(templates, "templates/*.tmpl")