gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
76.02k stars 7.54k forks source link

Empty paragraphs added with .RenderShortcodes #13051

Closed jmooring closed 5 days ago

jmooring commented 6 days ago

Reference: https://discourse.gohugo.io/t/52431

The test below passes with v0.124.1, and fails with v0.125.0 and later.

func TestFoo(t *testing.T) {
    t.Parallel()

    files := `
-- hugo.toml --
disableKinds = ['section','rss','sitemap','taxonomy','term']
-- layouts/_default/home.html --
{{ .Content }}
-- layouts/_default/single.html --
{{ .Content }}
-- layouts/shortcodes/include.html --
 {{ with site.GetPage (.Get 0) }}
  {{ .RenderShortcodes }}
{{ end }}
-- content/_index.md --
---
title: home
---

a

{{% include "/snippet" %}}

b

-- content/snippet.md --
---
title: snippet
build:
  render: never
  list: never
---

_emphasized_

`

    b := hugolib.Test(t, files)
    b.AssertFileContentEquals("public/index.html",
        "<p>a</p>\n<p><em>emphasized</em></p>\n<p>b</p>\n",
    )
}

got:

"<p>a</p>\n<p></p>\n<p><em>emphasized</em>\n</p>\n<p>b</p>\n"
           -------                        --

want:

"<p>a</p>\n<p><em>emphasized</em></p>\n<p>b</p>\n"