aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2020-12-02 13:23:25 +0100
committerBjørn Erik Pedersen <[email protected]>2020-12-03 13:12:58 +0100
commitd90e37e0c6e812f9913bf256c9c81aa05b7a08aa (patch)
tree7b1b14464eefec1188ca2eed53c64e4823453cc9 /transform
parent32471b57bde51c55a15dbf1db75d6e5f7232c347 (diff)
downloadhugo-d90e37e0c6e812f9913bf256c9c81aa05b7a08aa.tar.gz
hugo-d90e37e0c6e812f9913bf256c9c81aa05b7a08aa.zip
all: Format code with gofumpt
See https://github.com/mvdan/gofumpt
Diffstat (limited to 'transform')
-rw-r--r--transform/livereloadinject/livereloadinject.go11
-rw-r--r--transform/livereloadinject/livereloadinject_test.go1
-rw-r--r--transform/metainject/hugogenerator.go7
-rw-r--r--transform/metainject/hugogenerator_test.go1
-rw-r--r--transform/urlreplacers/absurlreplacer.go9
-rw-r--r--transform/urlreplacers/absurlreplacer_test.go5
6 files changed, 15 insertions, 19 deletions
diff --git a/transform/livereloadinject/livereloadinject.go b/transform/livereloadinject/livereloadinject.go
index cc80d046e..32ed55f63 100644
--- a/transform/livereloadinject/livereloadinject.go
+++ b/transform/livereloadinject/livereloadinject.go
@@ -30,19 +30,18 @@ type tag struct {
}
var tags = []tag{
- tag{markup: []byte("<head>"), appendScript: true},
- tag{markup: []byte("<HEAD>"), appendScript: true},
- tag{markup: []byte("</body>")},
- tag{markup: []byte("</BODY>")},
+ {markup: []byte("<head>"), appendScript: true},
+ {markup: []byte("<HEAD>"), appendScript: true},
+ {markup: []byte("</body>")},
+ {markup: []byte("</BODY>")},
}
// New creates a function that can be used
// to inject a script tag for the livereload JavaScript in a HTML document.
func New(baseURL url.URL) transform.Transformer {
-
return func(ft transform.FromTo) error {
b := ft.From().Bytes()
- var idx = -1
+ idx := -1
var match tag
// We used to insert the livereload script right before the closing body.
// This does not work when combined with tools such as Turbolinks.
diff --git a/transform/livereloadinject/livereloadinject_test.go b/transform/livereloadinject/livereloadinject_test.go
index 50fbb8b92..b2ec4483a 100644
--- a/transform/livereloadinject/livereloadinject_test.go
+++ b/transform/livereloadinject/livereloadinject_test.go
@@ -61,5 +61,4 @@ func TestLiveReloadInject(t *testing.T) {
c.Run("No match", func(c *qt.C) {
c.Assert(apply("<h1>No match</h1>"), qt.Equals, "<h1>No match</h1>")
})
-
}
diff --git a/transform/metainject/hugogenerator.go b/transform/metainject/hugogenerator.go
index 5f3a8f63b..20f05145b 100644
--- a/transform/metainject/hugogenerator.go
+++ b/transform/metainject/hugogenerator.go
@@ -23,8 +23,10 @@ import (
"github.com/gohugoio/hugo/transform"
)
-var metaTagsCheck = regexp.MustCompile(`(?i)<meta\s+name=['|"]?generator['|"]?`)
-var hugoGeneratorTag = fmt.Sprintf(`<meta name="generator" content="Hugo %s" />`, hugo.CurrentVersion)
+var (
+ metaTagsCheck = regexp.MustCompile(`(?i)<meta\s+name=['|"]?generator['|"]?`)
+ hugoGeneratorTag = fmt.Sprintf(`<meta name="generator" content="Hugo %s" />`, hugo.CurrentVersion)
+)
// HugoGenerator injects a meta generator tag for Hugo if none present.
func HugoGenerator(ft transform.FromTo) error {
@@ -51,5 +53,4 @@ func HugoGenerator(ft transform.FromTo) error {
}
return nil
-
}
diff --git a/transform/metainject/hugogenerator_test.go b/transform/metainject/hugogenerator_test.go
index ffb4c1425..1d6d7c4b9 100644
--- a/transform/metainject/hugogenerator_test.go
+++ b/transform/metainject/hugogenerator_test.go
@@ -57,5 +57,4 @@ func TestHugoGeneratorInject(t *testing.T) {
t.Errorf("[%d] Expected \n%q got \n%q", i, this.expect, out.String())
}
}
-
}
diff --git a/transform/urlreplacers/absurlreplacer.go b/transform/urlreplacers/absurlreplacer.go
index 7bac716fb..a875e6fa8 100644
--- a/transform/urlreplacers/absurlreplacer.go
+++ b/transform/urlreplacers/absurlreplacer.go
@@ -131,7 +131,6 @@ func (l *absurllexer) posAfterURL(q []byte) int {
return bytes.IndexFunc(l.content[l.pos:], func(r rune) bool {
return r == '>' || unicode.IsSpace(r)
})
-
}
// handle URLs in srcset.
@@ -188,7 +187,6 @@ func checkCandidateSrcset(l *absurllexer) {
l.pos += len(section)
l.start = l.pos
-
}
// main loop
@@ -231,12 +229,12 @@ func (l *absurllexer) replace() {
}
func doReplace(path string, ct transform.FromTo, quotes [][]byte) {
-
lexer := &absurllexer{
content: ct.From().Bytes(),
w: ct.To(),
path: []byte(path),
- quotes: quotes}
+ quotes: quotes,
+ }
lexer.replace()
}
@@ -249,7 +247,8 @@ type absURLReplacer struct {
func newAbsURLReplacer() *absURLReplacer {
return &absURLReplacer{
htmlQuotes: [][]byte{[]byte("\""), []byte("'")},
- xmlQuotes: [][]byte{[]byte("&#34;"), []byte("&#39;")}}
+ xmlQuotes: [][]byte{[]byte("&#34;"), []byte("&#39;")},
+ }
}
func (au *absURLReplacer) replaceInHTML(path string, ct transform.FromTo) {
diff --git a/transform/urlreplacers/absurlreplacer_test.go b/transform/urlreplacers/absurlreplacer_test.go
index 8e8fdc561..f4aa8b8ae 100644
--- a/transform/urlreplacers/absurlreplacer_test.go
+++ b/transform/urlreplacers/absurlreplacer_test.go
@@ -116,7 +116,8 @@ var (
srcsetXMLTests = []test{
{srcsetXMLBasic, srcsetXMLBasicCorrect},
{srcsetXMLSingleQuote, srcsetXMLSingleQuoteCorrect},
- {srcsetXMLVariations, srcsetXMLVariationsCorrect}}
+ {srcsetXMLVariations, srcsetXMLVariationsCorrect},
+ }
relurlTests = []test{{relPathVariations, relPathVariationsCorrect}}
)
@@ -152,7 +153,6 @@ func TestAbsURL(t *testing.T) {
tr := transform.New(NewAbsURLTransformer(testBaseURL))
apply(t.Errorf, tr, absURLTests)
-
}
func TestAbsURLUnqoted(t *testing.T) {
@@ -174,7 +174,6 @@ func TestRelativeURL(t *testing.T) {
tr := transform.New(NewAbsURLTransformer(helpers.GetDottedRelativePath(filepath.FromSlash("/post/sub/"))))
applyWithPath(t.Errorf, tr, relurlTests)
-
}
func TestAbsURLSrcSet(t *testing.T) {