~erock/pico

fbf32b273cea338fe982463ad297b66055e18c64 — Eric Bower a month ago 907e5e8
fix(prose): init html policy once
1 files changed, 7 insertions(+), 2 deletions(-)

M prose/parser.go
M prose/parser.go => prose/parser.go +7 -2
@@ 30,7 30,13 @@ type ParsedText struct {
	*MetaData
}

var policy = bluemonday.UGCPolicy()
func HtmlPolicy() *bluemonday.Policy {
	policy := bluemonday.UGCPolicy()
	policy.AllowStyling()
	return policy
}

var policy = HtmlPolicy()

func toString(obj interface{}) string {
	if obj == nil {


@@ 127,7 133,6 @@ func ParseText(text string) (*ParsedText, error) {
		return &parsed, err
	}

	policy.AllowStyling()
	parsed.Html = policy.Sanitize(buf.String())
	metaData := meta.Get(context)
	parsed.MetaData.Title = toString(metaData["title"])