Fix auto generated header ids so they don't contain e.g. hyperlink destinations (note)

This makes the header ids match the newly added dt ids.

Also make sure newlines are preserved in hooks' `.PlainText`.

Fixes #13405
Fixes #13410
This commit is contained in:
Bjørn Erik Pedersen
2025-02-16 21:52:46 +01:00
parent a2ca95629a
commit 24cc25552f
6 changed files with 59 additions and 14 deletions

View File

@@ -350,3 +350,31 @@ Image: ![alt-"<>&](/destination-"<> 'title-"<>&')
})
}
}
// Issue 13410.
func TestRenderHooksMultilineTitlePlainText(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
-- content/p1.md --
---
title: "p1"
---
First line.
Second line.
----------------
-- layouts/_default/_markup/render-heading.html --
Plain text: {{ .PlainText }}|Text: {{ .Text }}|
-- layouts/_default/single.html --
Content: {{ .Content}}|
}
`
b := Test(t, files)
b.AssertFileContent("public/p1/index.html",
"Content: Plain text: First line.\nSecond line.|",
"|Text: First line.\nSecond line.||\n",
)
}