diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-07-19 12:32:47 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-07-20 00:35:20 +0300 |
commit | c19f65f956739ab76c38222d48a3e461525e31af (patch) | |
tree | 7587764e36609cf423eebd6a7bb1449bfffde980 /minifiers | |
parent | 022c4795510306e08a4aba31504ca382d41c7fac (diff) |
minifiers: Make keepWhitespace = true default for HTML
Fixes #8771
Diffstat (limited to 'minifiers')
-rw-r--r-- | minifiers/config.go | 2 | ||||
-rw-r--r-- | minifiers/minifiers_test.go | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/minifiers/config.go b/minifiers/config.go index 675e5d2b8..e56617a06 100644 --- a/minifiers/config.go +++ b/minifiers/config.go @@ -35,7 +35,7 @@ var defaultTdewolffConfig = tdewolffConfig{ KeepConditionalComments: true, KeepEndTags: true, KeepDefaultAttrVals: true, - KeepWhitespace: false, + KeepWhitespace: true, }, CSS: css.Minifier{ Precision: 0, 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}, + ) + +} |