mark2web/helper/template_filters.go
Sebastian Frank 8f1345d4aa
All checks were successful
continuous-integration/drone/push Build is passing
fnRequest, pongo2-addons added
2019-02-27 15:58:10 +01:00

18 lines
452 B
Go

package helper
import (
"github.com/flosch/pongo2"
_ "github.com/flosch/pongo2-addons"
"gopkg.in/russross/blackfriday.v2"
)
func init() {
pongo2.ReplaceFilter("markdown", MarkdownFilter)
}
// MarkdownFilter is a pongo2 filter, which converts markdown to html
func MarkdownFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) {
html := blackfriday.Run([]byte(in.String()))
return pongo2.AsSafeValue(string(html)), nil
}