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
This commit is contained in:
ZhenShuo Leo
2025-10-03 22:40:45 +08:00
parent c7ed2261a3
commit 90e553541e
2 changed files with 6 additions and 0 deletions

View File

@@ -2,6 +2,9 @@
# These settings are required for the theme to function. # These settings are required for the theme to function.
[goldmark] [goldmark]
[goldmark.parser]
wrapStandAloneImageWithinParagraph = false
[goldmark.renderer] [goldmark.renderer]
unsafe = true unsafe = true

View File

@@ -2,6 +2,9 @@
# These settings are required for the theme to function. # These settings are required for the theme to function.
[goldmark] [goldmark]
[goldmark.parser]
wrapStandAloneImageWithinParagraph = false
[goldmark.renderer] [goldmark.renderer]
unsafe = true unsafe = true