From 632ad74fc5948786a53740c2a087a12eb2466908 Mon Sep 17 00:00:00 2001 From: Joe Mooring Date: Tue, 5 Mar 2024 16:06:50 -0800 Subject: [PATCH] tpl/tplimpl: Honor markdown attributes in embedded image render hook Fixes #12203 --- .../_default/_markup/render-image.html | 2 +- tpl/tplimpl/render_hook_integration_test.go | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tpl/tplimpl/embedded/templates/_default/_markup/render-image.html b/tpl/tplimpl/embedded/templates/_default/_markup/render-image.html index c90ababd224..fa78cd00c15 100644 --- a/tpl/tplimpl/embedded/templates/_default/_markup/render-image.html +++ b/tpl/tplimpl/embedded/templates/_default/_markup/render-image.html @@ -5,7 +5,7 @@ {{- $src = .RelPermalink -}} {{- end -}} {{- end -}} -{{- $attributes := dict "alt" .Text "src" $src "title" .Title -}} +{{- $attributes := merge .Attributes (dict "alt" .Text "src" $src "title" .Title) -}} 600`, ) } + +// Issue 12203 +func TestEmbeddedImageRenderHookMarkdownAttributes(t *testing.T) { + t.Parallel() + + files := ` +-- config.toml -- +disableKinds = ['page','rss','section','sitemap','taxonomy','term'] +[markup.goldmark.parser] +wrapStandAloneImageWithinParagraph = false +[markup.goldmark.parser.attribute] +block = false +[markup.goldmark.renderHooks.image] +enableDefault = true +-- content/_index.md -- +![alt](a.jpg) +{.foo #bar} +-- layouts/index.html -- +{{ .Content }} +` + + b := hugolib.Test(t, files) + b.AssertFileContent("public/index.html", `alt`) + + files = strings.Replace(files, "block = false", "block = true", -1) + + b = hugolib.Test(t, files) + b.AssertFileContent("public/index.html", `alt`) +}