From 00954c5d1fda0b18cd1b847ee580d5f4caa76c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 18 Dec 2019 17:23:09 +0100 Subject: Preserve HTML Text for link render hooks The context now have two text methods: * Text - rendered * PlainText Fixes #6629 --- hugolib/content_render_hooks_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'hugolib/content_render_hooks_test.go') 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:

P3. xml-link: https://www.example.org|

} +// 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:

START: html-link: https://gohugo.io|Text: should be bold|Plain: should be boldEND

+

Some regular markup.

+`) + +} + func TestRenderString(t *testing.T) { b := newTestSitesBuilder(t) -- cgit v1.2.3