summaryrefslogtreecommitdiffstats
path: root/markup/goldmark/integration_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-02-16 13:44:09 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-02-16 17:46:30 +0100
commitb2a827c52c91d9219306b5c996074d2e1ced5342 (patch)
tree014c859f5a0ea31ea41d4a64d13398a974f2b4a1 /markup/goldmark/integration_test.go
parent77c7059ff832870c3920e87a87969b815e429a8a (diff)
markup/goldmark: Fix mangling of headers/links in render hooks
```bash name old time/op new time/op delta SiteWithRenderHooks-10 11.9ms ± 1% 11.9ms ± 1% ~ (p=0.486 n=4+4) name old alloc/op new alloc/op delta SiteWithRenderHooks-10 11.2MB ± 0% 11.3MB ± 0% +0.16% (p=0.029 n=4+4) name old allocs/op new allocs/op delta SiteWithRenderHooks-10 145k ± 0% 145k ± 0% +0.14% (p=0.029 n=4+4) ``` Fixes #9504
Diffstat (limited to 'markup/goldmark/integration_test.go')
-rw-r--r--markup/goldmark/integration_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/markup/goldmark/integration_test.go b/markup/goldmark/integration_test.go
index fd90a6824..0f47f4ada 100644
--- a/markup/goldmark/integration_test.go
+++ b/markup/goldmark/integration_test.go
@@ -61,6 +61,42 @@ foo
`)
}
+// Issue 9504
+func TestLinkInTitle(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- config.toml --
+-- content/p1.md --
+---
+title: "p1"
+---
+## Hello [Test](https://example.com)
+-- layouts/_default/single.html --
+{{ .Content }}
+-- layouts/_default/_markup/render-heading.html --
+<h{{ .Level }} id="{{ .Anchor | safeURL }}">
+ {{ .Text | safeHTML }}
+ <a class="anchor" href="#{{ .Anchor | safeURL }}">#</a>
+</h{{ .Level }}>
+-- layouts/_default/_markup/render-link.html --
+<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text | safeHTML }}</a>
+
+`
+
+ b := hugolib.NewIntegrationTestBuilder(
+ hugolib.IntegrationTestConfig{
+ T: t,
+ TxtarString: files,
+ NeedsOsFS: false,
+ },
+ ).Build()
+
+ b.AssertFileContent("public/p1/index.html",
+ "<h2 id=\"hello-testhttpsexamplecom\">\n Hello <a href=\"https://example.com\">Test</a>\n\n <a class=\"anchor\" href=\"#hello-testhttpsexamplecom\">#</a>\n</h2>",
+ )
+}
+
func BenchmarkSiteWithRenderHooks(b *testing.B) {
files := `
-- config.toml --