diff --git a/go.mod b/go.mod index d5ad019fe..b917cc3cf 100644 --- a/go.mod +++ b/go.mod @@ -61,7 +61,7 @@ require ( github.com/spf13/cobra v1.9.1 github.com/spf13/viper v1.20.1 github.com/stretchr/testify v1.10.0 - github.com/tdewolff/minify/v2 v2.22.4 + github.com/tdewolff/minify/v2 v2.23.0 github.com/technologize/otel-go-contrib v1.1.1 github.com/temoto/robotstxt v1.1.2 github.com/tetratelabs/wazero v1.9.0 @@ -197,7 +197,7 @@ require ( github.com/spf13/cast v1.7.1 // indirect github.com/spf13/pflag v1.0.6 // indirect github.com/subosito/gotenv v1.6.0 // indirect - github.com/tdewolff/parse/v2 v2.7.21 // indirect + github.com/tdewolff/parse/v2 v2.7.22 // indirect github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect github.com/toqueteos/webbrowser v1.2.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect diff --git a/go.sum b/go.sum index f90bcac9e..38a6321c5 100644 --- a/go.sum +++ b/go.sum @@ -406,10 +406,10 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -github.com/tdewolff/minify/v2 v2.22.4 h1:0/8K2fheOuYr5B4e5oCE1hGBVX6DQHLP0EGzdsDlYeg= -github.com/tdewolff/minify/v2 v2.22.4/go.mod h1:K/R8TT7aivpcU8QCNUU1UdR6etfnFPr7L11TO/X7shk= -github.com/tdewolff/parse/v2 v2.7.21 h1:OCuPFtGr4mXdnfKikQlUb0n654ROJANhBqCk+wioJ/A= -github.com/tdewolff/parse/v2 v2.7.21/go.mod h1:I7TXO37t3aSG9SlPUBefAhgIF8nt7yYUwVGgETIoBcA= +github.com/tdewolff/minify/v2 v2.23.0 h1:ZdVmMkGYApnUpmOL/H/PCEk6qg6OFHzVDXgk07z9TW0= +github.com/tdewolff/minify/v2 v2.23.0/go.mod h1:ll/rxPfOGIgN9G4JXg+3jMtPTPEnEJB3nGtEG08sHl8= +github.com/tdewolff/parse/v2 v2.7.22 h1:ROVbrjtp5RoXi22YSZaOks5DaOcXBJ3PZO5hyyQ9Bbs= +github.com/tdewolff/parse/v2 v2.7.22/go.mod h1:I7TXO37t3aSG9SlPUBefAhgIF8nt7yYUwVGgETIoBcA= github.com/tdewolff/test v1.0.11 h1:FdLbwQVHxqG16SlkGveC0JVyrJN62COWTRyUFzfbtBE= github.com/tdewolff/test v1.0.11/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8= github.com/technologize/otel-go-contrib v1.1.1 h1:wZH9aSPNWZWIkEh3vfaKfMb15AJ80jJ1aVj/4GZdqIw= diff --git a/vendor/github.com/tdewolff/minify/v2/Makefile b/vendor/github.com/tdewolff/minify/v2/Makefile index 9eede2839..1fdc76ca8 100644 --- a/vendor/github.com/tdewolff/minify/v2/Makefile +++ b/vendor/github.com/tdewolff/minify/v2/Makefile @@ -49,6 +49,7 @@ release: fi; \ rm -rf dist/$$t; \ done + ./publish.sh clean: echo "Cleaning dist/" diff --git a/vendor/github.com/tdewolff/minify/v2/html/html.go b/vendor/github.com/tdewolff/minify/v2/html/html.go index ce5e96dc3..45643c5d8 100644 --- a/vendor/github.com/tdewolff/minify/v2/html/html.go +++ b/vendor/github.com/tdewolff/minify/v2/html/html.go @@ -145,11 +145,11 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st w.Write(t.Data) } omitSpace = false + case html.TemplateToken: + w.Write(t.Data) + omitSpace = false case html.TextToken: - if t.HasTemplate { - w.Write(t.Data) - omitSpace = parse.IsWhitespace(t.Data[len(t.Data)-1]) - } else if rawTagHash != 0 { + if rawTagHash != 0 && !t.HasTemplate { if rawTagHash == Style || rawTagHash == Script || rawTagHash == Iframe { var mimetype []byte var params map[string]string @@ -196,7 +196,7 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st t.Data = t.Data[:len(t.Data)-1] omitSpace = false break - } else if next.TokenType == html.TextToken && !parse.IsAllWhitespace(next.Data) { + } else if next.TokenType == html.TextToken && !parse.IsAllWhitespace(next.Data) || next.TokenType == html.TemplateToken { // stop looking when text encountered break } else if next.TokenType == html.StartTagToken || next.TokenType == html.EndTagToken || next.TokenType == html.SvgToken || next.TokenType == html.MathToken { @@ -215,7 +215,6 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st i++ } } - w.Write(t.Data) } case html.StartTagToken, html.EndTagToken: diff --git a/vendor/github.com/tdewolff/minify/v2/publish.sh b/vendor/github.com/tdewolff/minify/v2/publish.sh new file mode 100644 index 000000000..0e56de5f6 --- /dev/null +++ b/vendor/github.com/tdewolff/minify/v2/publish.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +VERSION=`git describe --tags --abbrev=0 | cut -c 2-` + +cd dist +echo "" +echo "Downloading v$VERSION.tar.gz..." +wget -q --show-progress https://github.com/tdewolff/minify/archive/v$VERSION.tar.gz +SHA256=`sha256sum v$VERSION.tar.gz` +SHA256=( $SHA256 ) + +echo "" +echo "Releasing for AUR..." +cd /home/taco/dev/aur/minify +sed -i "s/^pkgver=.*$/pkgver=$VERSION/" PKGBUILD +sed -i "s/^sha256sums=.*$/sha256sums=('$SHA256')/" PKGBUILD +./build.sh +git commit -am "Update to v$VERSION" +git push +cd - + +echo "" +echo "Releasing for Homebrew..." +cd /home/taco/dev/brew/homebrew-tap/Formula +sed -i "s,^ url \".*\"$, url \"https://github.com/tdewolff/minify/archive/v$VERSION.tar.gz\"," minify.rb +sed -i "s/^ sha256 \".*\"$/ sha256 \"$SHA256\"/" minify.rb +git commit -am "Update to v$VERSION" +git push +cd - + +#echo "" +#echo "Releasing Python bindings..." +#cd ../bindings/py +#make publish +#cd - diff --git a/vendor/github.com/tdewolff/parse/v2/html/lex.go b/vendor/github.com/tdewolff/parse/v2/html/lex.go index 8774ea264..8e2719504 100644 --- a/vendor/github.com/tdewolff/parse/v2/html/lex.go +++ b/vendor/github.com/tdewolff/parse/v2/html/lex.go @@ -23,6 +23,7 @@ const ( TextToken SvgToken MathToken + TemplateToken ) // String returns the string representation of a TokenType. @@ -185,18 +186,19 @@ func (l *Lexer) Next() (TokenType, []byte) { } else if c == '!' { l.r.Move(2) return l.readMarkup() - } else if 0 < len(l.tmplBegin) && l.at(l.tmplBegin...) { - l.r.Move(len(l.tmplBegin)) - l.moveTemplate() - l.hasTmpl = true } else if c == '?' { l.r.Move(1) return CommentToken, l.shiftBogusComment() } } else if 0 < len(l.tmplBegin) && l.at(l.tmplBegin...) { + if 0 < l.r.Pos() { + l.text = l.r.Shift() + return TextToken, l.text + } l.r.Move(len(l.tmplBegin)) l.moveTemplate() l.hasTmpl = true + return TemplateToken, l.r.Shift() } else if c == 0 && l.r.Err() != nil { if 0 < l.r.Pos() { l.text = l.r.Shift() diff --git a/vendor/modules.txt b/vendor/modules.txt index 5ef9f2a05..76943afdc 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -807,11 +807,11 @@ github.com/stretchr/testify/suite # github.com/subosito/gotenv v1.6.0 ## explicit; go 1.18 github.com/subosito/gotenv -# github.com/tdewolff/minify/v2 v2.22.4 -## explicit; go 1.23.0 +# github.com/tdewolff/minify/v2 v2.23.0 +## explicit; go 1.18.0 github.com/tdewolff/minify/v2 github.com/tdewolff/minify/v2/html -# github.com/tdewolff/parse/v2 v2.7.21 +# github.com/tdewolff/parse/v2 v2.7.22 ## explicit; go 1.13 github.com/tdewolff/parse/v2 github.com/tdewolff/parse/v2/buffer