mirror of
https://github.com/facundoolano/jorge.git
synced 2025-01-13 20:03:26 +01:00
add markdownify filter
This commit is contained in:
parent
ed258fddc4
commit
0906b1ef45
1 changed files with 14 additions and 1 deletions
|
@ -1,14 +1,17 @@
|
|||
package templates
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"encoding/xml"
|
||||
"time"
|
||||
|
||||
"github.com/osteele/liquid"
|
||||
"github.com/osteele/liquid/evaluator"
|
||||
"github.com/osteele/liquid/expressions"
|
||||
"time"
|
||||
"github.com/yuin/goldmark"
|
||||
)
|
||||
|
||||
// a lot of the filters and tags available at jekyll aren't default liquid manually adding them here
|
||||
|
@ -23,6 +26,16 @@ func loadJekyllFilters(e *liquid.Engine) {
|
|||
e.RegisterFilter("where_exp", whereExpFilter)
|
||||
e.RegisterFilter("xml_escape", xml.Marshal)
|
||||
|
||||
e.RegisterFilter("markdownify", func(s string) string {
|
||||
// using goldmark here instead of balckfriday, to avoid an extra dependencie
|
||||
var buf bytes.Buffer
|
||||
err := goldmark.Convert([]byte(s), &buf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return buf.String()
|
||||
})
|
||||
|
||||
e.RegisterFilter("absolute_url", func(s string) string {
|
||||
// FIXME implement after adding a config struct, using the url
|
||||
// return utils.URLJoin(c.AbsoluteURL, c.BaseURL, s)
|
||||
|
|
Loading…
Reference in a new issue