Repository: gohugoio/hugo (language: go)

Issue:
Hugo Stats generates encoded class names
Hi, I am using the latest version of hugo v0.117.0_extended with tailwind CSS. when I use tailwind arbitrary classes like `[&>p]:text-red-600`, then hugo_stats.json generates class like `[\u0026\u003ep]:text-red-600`. and obviously it does not work. I need exact same class name that I write to generate tailwind CSS styles. hope you will resolve this issue soon. thanks



Discussion / hints:
It's not uncommon to encode (and then decode) these entities when writing JSON, but I think there is a `SetEscapeHTML` option that we probably should set to `false`.



Fix patch:
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
index 0c1ec050b04..167d19eb591 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)
 


Test patch:
diff --git a/hugolib/site_test.go b/hugolib/site_test.go
index f4d63943f6b..57c6bbabef1 100644
--- a/hugolib/site_test.go
+++ b/hugolib/site_test.go
@@ -1116,7 +1116,7 @@ minify = %t
 
 Some text.
 
-<div class="c d e" id="el2">Foo</div>
+<div class="c d e [&>p]:text-red-600" id="el2">Foo</div>
 
 <span class=z>FOO</span>
 
@@ -1144,6 +1144,7 @@ Some text.
               "d",
               "e",
               "hover:text-gradient",
+			  "[&>p]:text-red-600",
               "inline-block",
               "lowercase",
               "pb-1",