forked from tangled.org/core
this repo has no description

appview: unify sanitization for `markdown` filter

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li d985a991 bbb4d612

verified
Changed files
+4 -3
appview
pages
+4 -3
appview/pages/funcmap.go
···
"github.com/dustin/go-humanize"
"github.com/go-enry/go-enry/v2"
-
"github.com/microcosm-cc/bluemonday"
"tangled.sh/tangled.sh/core/appview/filetree"
"tangled.sh/tangled.sh/core/appview/pages/markup"
)
···
},
"markdown": func(text string) template.HTML {
-
rctx := &markup.RenderContext{RendererType: markup.RendererTypeDefault}
-
return template.HTML(bluemonday.UGCPolicy().Sanitize(rctx.RenderMarkdown(text)))
+
p.rctx.RendererType = markup.RendererTypeDefault
+
htmlString := p.rctx.RenderMarkdown(text)
+
sanitized := p.rctx.SanitizeDefault(htmlString)
+
return template.HTML(sanitized)
},
"isNil": func(t any) bool {
// returns false for other "zero" values