diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-08-21 10:48:28 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2023-08-21 13:17:21 +0200 |
commit | bcf7421ea5f840d0036db0aeb744c7a17e0aa81e (patch) | |
tree | 91d1aa6b7b216303594992ced9e71aeffd802a1e /hugolib | |
parent | b6538532f45bf833226da7277994c1a96d26a56c (diff) |
Avoid escaping HTML chars inside hugo_stats.json
Fixes #11371
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/hugo_sites_build.go | 7 | ||||
-rw-r--r-- | 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. -<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", |