summaryrefslogtreecommitdiffstats
path: root/markup
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-02-26 10:15:04 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2025-02-26 11:44:25 +0100
commit521911a576af0091c9d07bb546e474bf98341b7f (patch)
tree3e0a83144027a62f8239d63614485da61cd77f7a /markup
parentb7ae24b9c2e4a9a99207110b439132afe5299908 (diff)
downloadhugo-521911a576af0091c9d07bb546e474bf98341b7f.tar.gz
hugo-521911a576af0091c9d07bb546e474bf98341b7f.zip
all: Run modernize -fix ./...
Diffstat (limited to 'markup')
-rw-r--r--markup/goldmark/codeblocks/render.go2
-rw-r--r--markup/goldmark/hugocontext/hugocontext.go4
-rw-r--r--markup/goldmark/passthrough/passthrough.go2
-rw-r--r--markup/rst/convert.go5
-rw-r--r--markup/tableofcontents/tableofcontents.go2
-rw-r--r--markup/tableofcontents/tableofcontents_test.go2
6 files changed, 7 insertions, 10 deletions
diff --git a/markup/goldmark/codeblocks/render.go b/markup/goldmark/codeblocks/render.go
index 4164f0e0a..c29632b90 100644
--- a/markup/goldmark/codeblocks/render.go
+++ b/markup/goldmark/codeblocks/render.go
@@ -77,7 +77,7 @@ func (r *htmlRenderer) renderCodeBlock(w util.BufWriter, src []byte, node ast.No
var buff bytes.Buffer
l := n.Lines().Len()
- for i := 0; i < l; i++ {
+ for i := range l {
line := n.Lines().At(i)
buff.Write(line.Value(src))
}
diff --git a/markup/goldmark/hugocontext/hugocontext.go b/markup/goldmark/hugocontext/hugocontext.go
index e68acb8c3..7a556083c 100644
--- a/markup/goldmark/hugocontext/hugocontext.go
+++ b/markup/goldmark/hugocontext/hugocontext.go
@@ -182,7 +182,7 @@ func (r *hugoContextRenderer) renderHTMLBlock(
if entering {
if r.Unsafe {
l := n.Lines().Len()
- for i := 0; i < l; i++ {
+ for i := range l {
line := n.Lines().At(i)
linev := line.Value(source)
var stripped bool
@@ -226,7 +226,7 @@ func (r *hugoContextRenderer) renderRawHTML(
n := node.(*ast.RawHTML)
l := n.Segments.Len()
if r.Unsafe {
- for i := 0; i < l; i++ {
+ for i := range l {
segment := n.Segments.At(i)
_, _ = w.Write(segment.Value(source))
}
diff --git a/markup/goldmark/passthrough/passthrough.go b/markup/goldmark/passthrough/passthrough.go
index 4d72e7c80..c56842f3d 100644
--- a/markup/goldmark/passthrough/passthrough.go
+++ b/markup/goldmark/passthrough/passthrough.go
@@ -110,7 +110,7 @@ func (r *htmlRenderer) renderPassthroughBlock(w util.BufWriter, src []byte, node
case (*passthrough.PassthroughBlock):
l := nn.Lines().Len()
var buff bytes.Buffer
- for i := 0; i < l; i++ {
+ for i := range l {
line := nn.Lines().At(i)
buff.Write(line.Value(src))
}
diff --git a/markup/rst/convert.go b/markup/rst/convert.go
index 398f5eb0c..5bb0adb15 100644
--- a/markup/rst/convert.go
+++ b/markup/rst/convert.go
@@ -100,10 +100,7 @@ func (c *rstConverter) getRstContent(src []byte, ctx converter.DocumentContext)
bodyEnd := bytes.Index(result, []byte("\n</body>"))
if bodyEnd < 0 || bodyEnd >= len(result) {
- bodyEnd = len(result) - 1
- if bodyEnd < 0 {
- bodyEnd = 0
- }
+ bodyEnd = max(len(result)-1, 0)
}
return result[bodyStart+7 : bodyEnd], err
diff --git a/markup/tableofcontents/tableofcontents.go b/markup/tableofcontents/tableofcontents.go
index 741179d96..6c40c9a59 100644
--- a/markup/tableofcontents/tableofcontents.go
+++ b/markup/tableofcontents/tableofcontents.go
@@ -250,7 +250,7 @@ func (b *tocBuilder) writeHeading(level, indent int, h *Heading) {
}
func (b *tocBuilder) indent(n int) {
- for i := 0; i < n; i++ {
+ for range n {
b.s.WriteString(" ")
}
}
diff --git a/markup/tableofcontents/tableofcontents_test.go b/markup/tableofcontents/tableofcontents_test.go
index 9ec7ec293..b07d9e3ad 100644
--- a/markup/tableofcontents/tableofcontents_test.go
+++ b/markup/tableofcontents/tableofcontents_test.go
@@ -196,7 +196,7 @@ func TestTocMisc(t *testing.T) {
func BenchmarkToc(b *testing.B) {
newTocs := func(n int) []*Fragments {
var tocs []*Fragments
- for i := 0; i < n; i++ {
+ for range n {
tocs = append(tocs, newTestToc())
}
return tocs