diff --git a/tpl/debug/debug.go b/tpl/debug/debug.go index 11c925c75..d07a2804e 100644 --- a/tpl/debug/debug.go +++ b/tpl/debug/debug.go @@ -16,6 +16,8 @@ package debug import ( "github.com/sanity-io/litter" + "github.com/spf13/cast" + "github.com/yuin/goldmark/util" "github.com/gohugoio/hugo/deps" ) @@ -41,3 +43,9 @@ type Namespace struct { func (ns *Namespace) Dump(val any) string { return litter.Sdump(val) } + +// VisualizeSpaces returns a string with spaces replaced by a visible string. +func (ns *Namespace) VisualizeSpaces(val any) string { + s := cast.ToString(val) + return string(util.VisualizeSpaces([]byte(s))) +}