From 90e553541eb9d3a4b14d8bfabea1501be0b90172 Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Fri, 3 Oct 2025 22:40:45 +0800 Subject: [PATCH] fix: enable wrapStandAloneImageWithinParagraph by default This fixes invalid HTML where figure tag is inside p tag. However, this does not fix linked images, e.g., `[![alt](image)](url)`. The cleanest way to resolve linked images is using markdown-attributes, but markdown-attributes is not recommended by CommonMark. See: - https://discourse.gohugo.io/t/how-to-do-wrap-img-with-a-inside-figure-with-render-image-html/44843 - https://github.com/gohugoio/hugo/blob/master/markup/goldmark/images/transform.go - https://gohugo.io/content-management/markdown-attributes/ - https://github.com/commonmark/commonmark-spec/wiki/Deployed-Extensions#attributes --- config/_default/markup.toml | 3 +++ exampleSite/config/_default/markup.toml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/config/_default/markup.toml b/config/_default/markup.toml index fccbfcc2..1cd9c5bc 100644 --- a/config/_default/markup.toml +++ b/config/_default/markup.toml @@ -2,6 +2,9 @@ # These settings are required for the theme to function. [goldmark] + [goldmark.parser] + wrapStandAloneImageWithinParagraph = false + [goldmark.renderer] unsafe = true diff --git a/exampleSite/config/_default/markup.toml b/exampleSite/config/_default/markup.toml index fccbfcc2..1cd9c5bc 100644 --- a/exampleSite/config/_default/markup.toml +++ b/exampleSite/config/_default/markup.toml @@ -2,6 +2,9 @@ # These settings are required for the theme to function. [goldmark] + [goldmark.parser] + wrapStandAloneImageWithinParagraph = false + [goldmark.renderer] unsafe = true