}
func (l configLoader) normalizeCfg(cfg config.Provider) error {
- if b, ok := cfg.Get("minifyOutput").(bool); ok && b {
- cfg.Set("minify.minifyOutput", true)
- } else if b, ok := cfg.Get("minify").(bool); ok && b {
- cfg.Set("minify", maps.Params{"minifyOutput": true})
+ if b, ok := cfg.Get("minifyOutput").(bool); ok {
+ hugo.Deprecate("site config minifyOutput", "Use minify.minifyOutput instead.", "v0.150.0")
+ if b {
+ cfg.Set("minify.minifyOutput", true)
+ }
+ } else if b, ok := cfg.Get("minify").(bool); ok {
+ hugo.Deprecate("site config minify", "Use minify.minifyOutput instead.", "v0.150.0")
+ if b {
+ cfg.Set("minify", maps.Params{"minifyOutput": true})
+ }
}
return nil
- Aliases:
- docker
- dockerfile
+ - containerfile
Name: Docker
- Aliases:
- dtd
- gdscript3
- gd3
Name: GDScript3
+ - Aliases:
+ - gemtext
+ - gmi
+ - gmni
+ - gemini
+ Name: Gemtext
- Aliases:
- genshi
- kid
- Aliases:
- llvm
Name: LLVM
+ - Aliases: null
+ Name: lox
- Aliases:
- lua
- luau
- nsi
- nsh
Name: NSIS
+ - Aliases:
+ - nu
+ Name: Nu
- Aliases:
- objective-c
- objectivec
tdewolff:
css:
inline: false
- keepCSS2: true
+ keepCSS2: false
precision: 0
+ version: 0
html:
keepComments: false
keepConditionalComments: false
- - '{{ slice "a" "b" "c" "d" "e" "f" | complement (slice "b" "c") (slice
"d" "e") }}'
- '[a f]'
+ D:
+ Aliases: null
+ Args: null
+ Description: ""
+ Examples: null
Delimit:
Aliases:
- delimit
github.com/spf13/cobra v1.9.1
github.com/spf13/fsync v0.10.1
github.com/spf13/pflag v1.0.7
- github.com/tdewolff/minify/v2 v2.24.0
+ github.com/tdewolff/minify/v2 v2.24.2
github.com/tdewolff/parse/v2 v2.8.3
github.com/tetratelabs/wazero v1.9.0
github.com/yuin/goldmark v1.7.13
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
-github.com/tdewolff/minify/v2 v2.24.0 h1:m6j8VXvgUtmkavubzHbaNTXi9tw3hjIMZbdc57SRdvI=
-github.com/tdewolff/minify/v2 v2.24.0/go.mod h1:uqtSu3w0+anqk4ofcsuLPZ8tV8yAZL1r/ILWYYl2j3c=
+github.com/tdewolff/minify/v2 v2.24.1 h1:9ZLg8Bnb4a7RxJtOi7WCpHrfHdNZBBzS7vNRQ4NwLW4=
+github.com/tdewolff/minify/v2 v2.24.1/go.mod h1:1JrCtoZXaDbqioQZfk3Jdmr0GPJKiU7c1Apmb+7tCeE=
+github.com/tdewolff/minify/v2 v2.24.2 h1:vnY3nTulEAbCAAlxTxPPDkzG24rsq31SOzp63yT+7mo=
+github.com/tdewolff/minify/v2 v2.24.2/go.mod h1:1JrCtoZXaDbqioQZfk3Jdmr0GPJKiU7c1Apmb+7tCeE=
github.com/tdewolff/parse/v2 v2.8.3 h1:5VbvtJ83cfb289A1HzRA9sf02iT8YyUwN84ezjkdY1I=
github.com/tdewolff/parse/v2 v2.8.3/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLBLd6dlIXYqo=
github.com/tdewolff/test v1.0.11 h1:FdLbwQVHxqG16SlkGveC0JVyrJN62COWTRyUFzfbtBE=
package minifiers
import (
+ "fmt"
+
+ "github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/common/maps"
"github.com/spf13/cast"
KeepWhitespace: false,
},
CSS: css.Minifier{
- Precision: 0,
- KeepCSS2: true,
+ Precision: 0, // 0 means no trimming
+ Version: 0, // 0 means the latest CSS version
},
JS: js.Minifier{
Version: 2022,
JSON: json.Minifier{},
SVG: svg.Minifier{
KeepComments: false,
- Precision: 0,
+ Precision: 0, // 0 means no trimming
},
XML: xml.Minifier{
KeepWhitespace: false,
m := maps.ToStringMap(v)
- // Handle upstream renames.
+ // Handle deprecations.
if td, found := m["tdewolff"]; found {
tdm := maps.ToStringMap(td)
+ // Decimals was renamed to Precision in tdewolff/minify v2.7.0.
+ // https://github.com/tdewolff/minify/commit/2fed4401348ce36bd6c20e77335a463e69d94386
for _, key := range []string{"css", "svg"} {
if v, found := tdm[key]; found {
vm := maps.ToStringMap(v)
- ko := "decimal"
+ ko := "decimals"
kn := "precision"
if vv, found := vm[ko]; found {
+ hugo.Deprecate(
+ fmt.Sprintf("site config key minify.tdewolff.%s.%s", key, ko),
+ fmt.Sprintf("Use config key minify.tdewolff.%s.%s instead.", key, kn),
+ "v0.150.0",
+ )
if _, found = vm[kn]; !found {
vvi := cast.ToInt(vv)
if vvi > 0 {
}
}
- // keepConditionalComments was renamed to keepSpecialComments
+ // KeepConditionalComments was renamed to KeepSpecialComments in tdewolff/minify v2.20.13.
+ // https://github.com/tdewolff/minify/commit/342cbc1974162db0ad3327f7a42a623b2cd3ebbc
if v, found := tdm["html"]; found {
vm := maps.ToStringMap(v)
ko := "keepconditionalcomments"
kn := "keepspecialcomments"
if vv, found := vm[ko]; found {
- // Set keepspecialcomments, if not already set
+ hugo.Deprecate(
+ fmt.Sprintf("site config key minify.tdewolff.html.%s", ko),
+ fmt.Sprintf("Use config key minify.tdewolff.html.%s instead.", kn),
+ "v0.150.0",
+ )
if _, found := vm[kn]; !found {
vm[kn] = cast.ToBool(vv)
}
- // Remove the old key to prevent deprecation warnings
delete(vm, ko)
}
}
+ // KeepCSS2 was deprecated in favor of Version in tdewolff/minify v2.24.1.
+ // https://github.com/tdewolff/minify/commit/57e3ebe0e6914b82c9ab0849a14f86bc29cd2ebf
+ if v, found := tdm["css"]; found {
+ vm := maps.ToStringMap(v)
+ ko := "keepcss2"
+ kn := "version"
+ if vv, found := vm[ko]; found {
+ hugo.Deprecate(
+ fmt.Sprintf("site config key minify.tdewolff.css.%s", ko),
+ fmt.Sprintf("Use config key minify.tdewolff.css.%s instead.", kn),
+ "v0.150.0",
+ )
+ if _, found := vm[kn]; !found {
+ if cast.ToBool(vv) {
+ vm[kn] = 2
+ }
+ }
+ delete(vm, ko)
+ }
+ }
}
err = mapstructure.WeakDecode(m, &conf)
-
if err != nil {
return
}
c.Assert(conf.Tdewolff.HTML.KeepWhitespace, qt.Equals, false)
// default value
c.Assert(conf.Tdewolff.HTML.KeepEndTags, qt.Equals, true)
- c.Assert(conf.Tdewolff.CSS.KeepCSS2, qt.Equals, true)
+ c.Assert(conf.Tdewolff.CSS.Version, qt.Equals, 0)
// `enable` flags
c.Assert(conf.DisableHTML, qt.Equals, false)
c.Assert(conf.DisableXML, qt.Equals, true)
}
-func TestConfigLegacy(t *testing.T) {
+func TestConfigDeprecations(t *testing.T) {
c := qt.New(t)
+
+ // Test default values of deprecated root keys.
v := config.New()
+ v.Set("minify", false)
+ conf := testconfig.GetTestConfigs(nil, v).Base.Minify
+ c.Assert(conf.MinifyOutput, qt.Equals, false)
- // This was a bool < Hugo v0.58.
+ v = config.New()
+ v.Set("minifyoutput", false)
+ conf = testconfig.GetTestConfigs(nil, v).Base.Minify
+ c.Assert(conf.MinifyOutput, qt.Equals, false)
+
+ // Test non-default values of deprecated root keys.
+ v = config.New()
v.Set("minify", true)
+ conf = testconfig.GetTestConfigs(nil, v).Base.Minify
+ c.Assert(conf.MinifyOutput, qt.Equals, true)
- conf := testconfig.GetTestConfigs(nil, v).Base.Minify
+ v = config.New()
+ v.Set("minifyoutput", true)
+ conf = testconfig.GetTestConfigs(nil, v).Base.Minify
c.Assert(conf.MinifyOutput, qt.Equals, true)
}
-func TestConfigNewCommentOptions(t *testing.T) {
+func TestConfigUpstreamDeprecations(t *testing.T) {
c := qt.New(t)
- v := config.New()
- // setting the old options should automatically set the new options
+ // Test default values of deprecated keys.
+ v := config.New()
v.Set("minify", map[string]any{
"tdewolff": map[string]any{
+ "css": map[string]any{
+ "decimals": 0,
+ "keepcss2": true,
+ },
"html": map[string]any{
- "keepConditionalComments": false,
+ "keepconditionalcomments": true,
},
"svg": map[string]any{
- "decimal": "5",
+ "decimals": 0,
},
},
})
conf := testconfig.GetTestConfigs(nil, v).Base.Minify
- c.Assert(conf.Tdewolff.HTML.KeepSpecialComments, qt.Equals, false)
- c.Assert(conf.Tdewolff.SVG.Precision, qt.Equals, 5)
+ c.Assert(conf.Tdewolff.CSS.Precision, qt.Equals, 0)
+ c.Assert(conf.Tdewolff.CSS.Version, qt.Equals, 2)
+ c.Assert(conf.Tdewolff.HTML.KeepSpecialComments, qt.Equals, true)
+ c.Assert(conf.Tdewolff.SVG.Precision, qt.Equals, 0)
- // the new values should win, regardless of the contents of the old values
+ // Test non-default values of deprecated keys.
v = config.New()
v.Set("minify", map[string]any{
"tdewolff": map[string]any{
+ "css": map[string]any{
+ "decimals": 6,
+ "keepcss2": false,
+ },
"html": map[string]any{
- "keepConditionalComments": false,
- "keepSpecialComments": true,
+ "keepconditionalcomments": false,
},
"svg": map[string]any{
- "decimal": "5",
- "precision": "10",
+ "decimals": 7,
},
},
})
conf = testconfig.GetTestConfigs(nil, v).Base.Minify
- c.Assert(conf.Tdewolff.HTML.KeepSpecialComments, qt.Equals, true)
- c.Assert(conf.Tdewolff.SVG.Precision, qt.Equals, 10)
+ c.Assert(conf.Tdewolff.CSS.Precision, qt.Equals, 6)
+ c.Assert(conf.Tdewolff.CSS.Version, qt.Equals, 0)
+ c.Assert(conf.Tdewolff.HTML.KeepSpecialComments, qt.Equals, false)
+ c.Assert(conf.Tdewolff.SVG.Precision, qt.Equals, 7)
}
"github.com/gohugoio/hugo/minifiers"
"github.com/gohugoio/hugo/output"
"github.com/spf13/afero"
- "github.com/tdewolff/minify/v2/html"
)
func TestNew(t *testing.T) {
c.Assert(b.String(), qt.Equals, test.expectedMinString)
}
}
-
-// Renamed to Precision in v2.7.0. Check that we support both.
-func TestDecodeConfigDecimalIsNowPrecision(t *testing.T) {
- c := qt.New(t)
- v := config.New()
- v.Set("minify", map[string]any{
- "disablexml": true,
- "tdewolff": map[string]any{
- "css": map[string]any{
- "decimal": 3,
- },
- "svg": map[string]any{
- "decimal": 3,
- },
- },
- })
-
- conf := testconfig.GetTestConfigs(nil, v).Base.Minify
-
- c.Assert(conf.Tdewolff.CSS.Precision, qt.Equals, 3)
-}
-
-// Issue 9456
-func TestDecodeConfigKeepWhitespace(t *testing.T) {
- c := qt.New(t)
- v := config.New()
- v.Set("minify", map[string]any{
- "tdewolff": map[string]any{
- "html": map[string]any{
- "keepEndTags": false,
- },
- },
- })
-
- conf := testconfig.GetTestConfigs(nil, v).Base.Minify
-
- c.Assert(conf.Tdewolff.HTML, qt.DeepEquals,
- html.Minifier{
- KeepComments: false,
- KeepSpecialComments: true,
- KeepDefaultAttrVals: true,
- KeepDocumentTags: true,
- KeepEndTags: false,
- KeepQuotes: false,
- KeepWhitespace: false,
- },
- )
-}