diff --git a/README.md b/README.md index fb46171..f41b777 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,11 @@ -pongo2-addons -============= +# pongo2-addons -Official filter and tag addons for pongo2 +Official filter and tag add-ons for [pongo2](https://github.com/flosch/pongo2). Uses 3rd-party-libraries. + +## Filters + + - **markdown** (parses markdown text and outputs HTML; **hint**: use the **safe**-filter to make the output not being escaped) + +## Tags + +(nothing yet) \ No newline at end of file diff --git a/filter_markdown.go b/filter_markdown.go new file mode 100644 index 0000000..6d40363 --- /dev/null +++ b/filter_markdown.go @@ -0,0 +1,15 @@ +package pongo2addons + +import ( + "github.com/flosch/pongo2" + + "github.com/russross/blackfriday" +) + +func init() { + pongo2.RegisterFilter("markdown", filterMarkdown) +} + +func filterMarkdown(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, error) { + return pongo2.AsValue(string(blackfriday.MarkdownCommon([]byte(in.String())))), nil +}