mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Preserve HTML Text for link render hooks
The context now have two text methods: * Text - rendered * PlainText Fixes #6629
This commit is contained in:
@@ -213,6 +213,37 @@ P3: <p>P3. xml-link: https://www.example.org|</p>
|
||||
|
||||
}
|
||||
|
||||
// https://github.com/gohugoio/hugo/issues/6629
|
||||
func TestRenderLinkWithMarkupInText(t *testing.T) {
|
||||
|
||||
b := newTestSitesBuilder(t)
|
||||
|
||||
b.WithTemplates("index.html", `
|
||||
{{ $p := site.GetPage "p1.md" }}
|
||||
P1: {{ $p.Content }}
|
||||
|
||||
`,
|
||||
"_default/_markup/render-link.html", `html-link: {{ .Destination | safeURL }}|Text: {{ .Text | safeHTML }}|Plain: {{ .PlainText | safeHTML }}`,
|
||||
)
|
||||
|
||||
b.WithContent("p1.md", `---
|
||||
title: "p1"
|
||||
---
|
||||
|
||||
START: [**should be bold**](https://gohugo.io)END
|
||||
|
||||
Some regular **markup**.
|
||||
`)
|
||||
|
||||
b.Build(BuildCfg{})
|
||||
|
||||
b.AssertFileContent("public/index.html", `
|
||||
P1: <p>START: html-link: https://gohugo.io|Text: <strong>should be bold</strong>|Plain: should be boldEND</p>
|
||||
<p>Some regular <strong>markup</strong>.</p>
|
||||
`)
|
||||
|
||||
}
|
||||
|
||||
func TestRenderString(t *testing.T) {
|
||||
|
||||
b := newTestSitesBuilder(t)
|
||||
|
Reference in New Issue
Block a user