Avoid escaping HTML chars inside hugo_stats.json

Fixes #11371
This commit is contained in:
Bjørn Erik Pedersen 2023-08-21 10:48:28 +02:00
parent b6538532f4
commit bcf7421ea5
2 changed files with 8 additions and 2 deletions

View file

@ -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)

View file

@ -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",