markdown-filter added.

This commit is contained in:
Florian Schlachter 2014-07-20 00:42:24 +02:00
parent 6b7c130f31
commit b4eefc9d85
2 changed files with 25 additions and 3 deletions

View File

@ -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)

15
filter_markdown.go Normal file
View File

@ -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
}