port normalize_whitespace

This commit is contained in:
facundoolano 2024-02-16 15:13:52 -03:00
parent 80a646e92a
commit 008954a98b

View file

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