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 }