Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
minifiers: Make keepWhitespace = true default for HTML
- Loading branch information
There are no files selected for viewing
|
|
@@ -456,6 +456,10 @@ func TestResourceChainPostProcess(t *testing.T) { |
|
|
rnd := rand.New(rand.NewSource(time.Now().UnixNano())) |
|
|
|
|
|
b := newTestSitesBuilder(t) |
|
|
b.WithConfigFile("toml", `[minify] |
|
|
[minify.tdewolff] |
|
|
[minify.tdewolff.html] |
|
|
keepWhitespace = false`) |
|
|
b.WithContent("page1.md", "---\ntitle: Page1\n---") |
|
|
b.WithContent("page2.md", "---\ntitle: Page2\n---") |
|
|
|
|
|
@@ -562,6 +566,11 @@ T6: {{ $bundle1.Permalink }} |
|
|
}}, |
|
|
|
|
|
{"minify", func() bool { return true }, func(b *sitesBuilder) { |
|
|
b.WithConfigFile("toml", `[minify] |
|
|
[minify.tdewolff] |
|
|
[minify.tdewolff.html] |
|
|
keepWhitespace = false |
|
|
`) |
|
|
b.WithTemplates("home.html", ` |
|
|
Min CSS: {{ ( resources.Get "css/styles1.css" | minify ).Content }} |
|
|
Min JS: {{ ( resources.Get "js/script1.js" | resources.Minify ).Content | safeJS }} |
|
|
|
|
|
@@ -35,7 +35,7 @@ var defaultTdewolffConfig = tdewolffConfig{ |
|
|
KeepConditionalComments: true, |
|
|
KeepEndTags: true, |
|
|
KeepDefaultAttrVals: true, |
|
|
KeepWhitespace: false, |
|
|
KeepWhitespace: true, |
|
|
}, |
|
|
CSS: css.Minifier{ |
|
|
Precision: 0, |
|
|
|
|
|
@@ -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}, |
|
|
) |
|
|
|
|
|
} |
|
|
@@ -38,5 +38,5 @@ func TestTransform(t *testing.T) { |
|
|
c.Assert(transformed.RelPermalink(), qt.Equals, "/hugo.min.html") |
|
|
content, err := transformed.(resource.ContentProvider).Content() |
|
|
c.Assert(err, qt.IsNil) |
|
|
c.Assert(content, qt.Equals, "<h1>Hugo Rocks!</h1>") |
|
|
c.Assert(content, qt.Equals, "<h1> Hugo Rocks! </h1>") |
|
|
} |