mirror of
https://github.com/facundoolano/jorge.git
synced 2024-12-25 21:58:28 +01:00
port normalize_whitespace
This commit is contained in:
parent
80a646e92a
commit
008954a98b
1 changed files with 6 additions and 0 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"log"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"regexp"
|
||||
|
||||
"encoding/xml"
|
||||
"time"
|
||||
|
@ -29,6 +30,11 @@ func loadJekyllFilters(e *liquid.Engine, siteUrl string) {
|
|||
e.RegisterFilter("where_exp", whereExpFilter)
|
||||
e.RegisterFilter("xml_escape", xml.Marshal)
|
||||
|
||||
e.RegisterFilter("normalize_whitespace", func(s string) string {
|
||||
wsPattern := regexp.MustCompile(`(?s:[\s\n]+)`)
|
||||
return wsPattern.ReplaceAllString(s, " ")
|
||||
})
|
||||
|
||||
e.RegisterFilter("markdownify", func(s string) string {
|
||||
// using goldmark here instead of balckfriday, to avoid an extra dependencie
|
||||
var buf bytes.Buffer
|
||||
|
|
Loading…
Reference in a new issue