aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/content_render_hooks_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-12-18 17:23:09 +0100
committerBjørn Erik Pedersen <[email protected]>2019-12-18 22:55:19 +0100
commit00954c5d1fda0b18cd1b847ee580d5f4caa76c70 (patch)
treeef0c4000f73f4c1cbe5527a52270006bac01d2d1 /hugolib/content_render_hooks_test.go
parent1b785a7a6d3c264e39e4976c59b618c0ac1ba5f9 (diff)
downloadhugo-00954c5d1fda0b18cd1b847ee580d5f4caa76c70.tar.gz
hugo-00954c5d1fda0b18cd1b847ee580d5f4caa76c70.zip
Preserve HTML Text for link render hooks
The context now have two text methods: * Text - rendered * PlainText Fixes #6629
Diffstat (limited to 'hugolib/content_render_hooks_test.go')
-rw-r--r--hugolib/content_render_hooks_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/hugolib/content_render_hooks_test.go b/hugolib/content_render_hooks_test.go
index aa697220d..deccbff48 100644
--- a/hugolib/content_render_hooks_test.go
+++ b/hugolib/content_render_hooks_test.go
@@ -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)