aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/content_render_hooks_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2021-02-22 11:27:14 +0100
committerBjørn Erik Pedersen <[email protected]>2021-02-23 18:08:39 +0100
commitcd0c5d7ef32cbd570af00c50ce760452381df64e (patch)
tree13dcde7bb470d2ea96e7b0ab11377d1b2baa9cf1 /hugolib/content_render_hooks_test.go
parente7e194435b4c566f47d644f2e60c096ea1866254 (diff)
downloadhugo-cd0c5d7ef32cbd570af00c50ce760452381df64e.tar.gz
hugo-cd0c5d7ef32cbd570af00c50ce760452381df64e.zip
Allow markdown attribute lists to be used in title render hooks
Fixes #8270
Diffstat (limited to 'hugolib/content_render_hooks_test.go')
-rw-r--r--hugolib/content_render_hooks_test.go18
1 files changed, 16 insertions, 2 deletions
diff --git a/hugolib/content_render_hooks_test.go b/hugolib/content_render_hooks_test.go
index 197581bb6..218ad918b 100644
--- a/hugolib/content_render_hooks_test.go
+++ b/hugolib/content_render_hooks_test.go
@@ -60,6 +60,16 @@ func TestRenderHooks(t *testing.T) {
config := `
baseURL="https://example.org"
workingDir="/mywork"
+
+[markup]
+[markup.goldmark]
+[markup.goldmark.parser]
+autoHeadingID = true
+autoHeadingIDType = "github"
+[markup.goldmark.parser.attribute]
+block = true
+title = true
+
`
b := newTestSitesBuilder(t).WithWorkingDir("/mywork").WithConfigFile("toml", config).Running()
b.WithTemplatesAdded("_default/single.html", `{{ .Content }}`)
@@ -85,7 +95,7 @@ Inner Block: {{ .Inner | .Page.RenderString (dict "display" "block" ) }}
b.WithTemplatesAdded("_default/_markup/render-link.html", `{{ with .Page }}{{ .Title }}{{ end }}|{{ .Destination | safeURL }}|Title: {{ .Title | safeHTML }}|Text: {{ .Text | safeHTML }}|END`)
b.WithTemplatesAdded("docs/_markup/render-link.html", `Link docs section: {{ .Text | safeHTML }}|END`)
b.WithTemplatesAdded("_default/_markup/render-image.html", `IMAGE: {{ .Page.Title }}||{{ .Destination | safeURL }}|Title: {{ .Title | safeHTML }}|Text: {{ .Text | safeHTML }}|END`)
- b.WithTemplatesAdded("_default/_markup/render-heading.html", `HEADING: {{ .Page.Title }}||Level: {{ .Level }}|Anchor: {{ .Anchor | safeURL }}|Text: {{ .Text | safeHTML }}|END`)
+ b.WithTemplatesAdded("_default/_markup/render-heading.html", `HEADING: {{ .Page.Title }}||Level: {{ .Level }}|Anchor: {{ .Anchor | safeURL }}|Text: {{ .Text | safeHTML }}|Attributes: {{ .Attributes }}|END`)
b.WithTemplatesAdded("docs/_markup/render-heading.html", `Docs Level: {{ .Level }}|END`)
b.WithContent("customview/p1.md", `---
@@ -108,6 +118,10 @@ Image:
![Drag Racing](/images/Dragster.jpg "image title")
+Attributes:
+
+## Some Heading {.text-serif #a-heading title="Hovered"}
+
`, "blog/p2.md", `---
title: Cool Page2
@@ -238,7 +252,7 @@ SHORT3|
// We may add type template support later, keep this for then. b.AssertFileContent("public/docs/docs1/index.html", `DOCS EDITED: https://www.google.com|</p>`)
b.AssertFileContent("public/blog/p4/index.html", `IMAGE EDITED: /images/Dragster.jpg|`)
b.AssertFileContent("public/blog/p6/index.html", "<p>Inner Link: EDITED: https://www.gohugo.io|</p>")
- b.AssertFileContent("public/blog/p7/index.html", "HEADING: With Headings||Level: 1|Anchor: heading-level-1|Text: Heading Level 1|END<p>some text</p>\nHEADING: With Headings||Level: 2|Anchor: heading-level-2|Text: Heading Level 2|ENDHEADING: With Headings||Level: 3|Anchor: heading-level-3|Text: Heading Level 3|END")
+ b.AssertFileContent("public/blog/p7/index.html", "HEADING: With Headings||Level: 1|Anchor: heading-level-1|Text: Heading Level 1|Attributes: map[id:heading-level-1]|END<p>some text</p>\nHEADING: With Headings||Level: 2|Anchor: heading-level-2|Text: Heading Level 2|Attributes: map[id:heading-level-2]|ENDHEADING: With Headings||Level: 3|Anchor: heading-level-3|Text: Heading Level 3|Attributes: map[id:heading-level-3]|END")
// https://github.com/gohugoio/hugo/issues/7349
b.AssertFileContent("public/docs/p8/index.html", "Docs Level: 1")