From bcf7421ea5f840d0036db0aeb744c7a17e0aa81e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 21 Aug 2023 10:48:28 +0200 Subject: [PATCH] Avoid escaping HTML chars inside hugo_stats.json Fixes #11371 --- hugolib/hugo_sites_build.go | 7 ++++++- hugolib/site_test.go | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go index 0c1ec050b..167d19eb5 100644 --- a/hugolib/hugo_sites_build.go +++ b/hugolib/hugo_sites_build.go @@ -492,10 +492,15 @@ func (h *HugoSites) writeBuildStats() error { HTMLElements: *htmlElements, } - js, err := json.MarshalIndent(stats, "", " ") + var buf bytes.Buffer + enc := json.NewEncoder(&buf) + enc.SetEscapeHTML(false) + enc.SetIndent("", " ") + err := enc.Encode(stats) if err != nil { return err } + js := buf.Bytes() filename := filepath.Join(h.Configs.LoadingInfo.BaseConfig.WorkingDir, files.FilenameHugoStatsJSON) diff --git a/hugolib/site_test.go b/hugolib/site_test.go index f4d63943f..57c6bbabe 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -1116,7 +1116,7 @@ minify = %t Some text. -
Foo
+
Foo
FOO @@ -1144,6 +1144,7 @@ Some text. "d", "e", "hover:text-gradient", + "[&>p]:text-red-600", "inline-block", "lowercase", "pb-1",