From c19f65f956739ab76c38222d48a3e461525e31af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 19 Jul 2021 11:32:47 +0200 Subject: minifiers: Make keepWhitespace = true default for HTML Fixes #8771 --- minifiers/minifiers_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'minifiers/minifiers_test.go') diff --git a/minifiers/minifiers_test.go b/minifiers/minifiers_test.go index 37e017420..81edba510 100644 --- a/minifiers/minifiers_test.go +++ b/minifiers/minifiers_test.go @@ -23,6 +23,7 @@ import ( "github.com/gohugoio/hugo/config" "github.com/gohugoio/hugo/media" "github.com/gohugoio/hugo/output" + "github.com/tdewolff/minify/v2/html" ) func TestNew(t *testing.T) { @@ -189,3 +190,31 @@ func TestDecodeConfigDecimalIsNowPrecision(t *testing.T) { c.Assert(conf.Tdewolff.CSS.Precision, qt.Equals, 3) } + +// Issue 8771 +func TestDecodeConfigKeepWhitespace(t *testing.T) { + c := qt.New(t) + v := config.New() + v.Set("minify", map[string]interface{}{ + "tdewolff": map[string]interface{}{ + "html": map[string]interface{}{ + "keepEndTags": false, + }, + }, + }) + + conf, err := decodeConfig(v) + + c.Assert(err, qt.IsNil) + c.Assert(conf.Tdewolff.HTML, qt.DeepEquals, + html.Minifier{ + KeepComments: false, + KeepConditionalComments: true, + KeepDefaultAttrVals: true, + KeepDocumentTags: true, + KeepEndTags: false, + KeepQuotes: false, + KeepWhitespace: true}, + ) + +} -- cgit v1.2.3