markdown-filter added.
This commit is contained in:
parent
6b7c130f31
commit
b4eefc9d85
13
README.md
13
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)
|
15
filter_markdown.go
Normal file
15
filter_markdown.go
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user