diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-11-04 09:27:17 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-11-04 10:13:53 +0100 |
commit | 6cf23bf8824758b0d2c4d855f0241e72aef77206 (patch) | |
tree | 5610ec1cda8023a28bdff612c59dcb4cd921dc9e | |
parent | 62a96cef7fbe496271e8cca0f234193f6106a771 (diff) | |
download | hugo-6cf23bf8824758b0d2c4d855f0241e72aef77206.tar.gz hugo-6cf23bf8824758b0d2c4d855f0241e72aef77206.zip |
markup/goldmark: Only log Raw HTML omitted WARN on block entering
Updates #12997
-rw-r--r-- | markup/goldmark/hugocontext/hugocontext.go | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/markup/goldmark/hugocontext/hugocontext.go b/markup/goldmark/hugocontext/hugocontext.go index 912e9eb3c..4971456be 100644 --- a/markup/goldmark/hugocontext/hugocontext.go +++ b/markup/goldmark/hugocontext/hugocontext.go @@ -159,15 +159,12 @@ func (r *hugoContextRenderer) renderHTMLBlock( w util.BufWriter, source []byte, node ast.Node, entering bool, ) (ast.WalkStatus, error) { n := node.(*ast.HTMLBlock) - var p any - ctx, ok := w.(*render.Context) - if ok { - p, _ = render.GetPageAndPageInner(ctx) - } - if !r.Unsafe { - r.logger.Warnidf(constants.WarnGoldmarkRawHTML, "Raw HTML omitted from %q; see https://gohugo.io/getting-started/configuration-markup/#rendererunsafe", p) - } if entering { + var p any + ctx, ok := w.(*render.Context) + if ok { + p, _ = render.GetPageAndPageInner(ctx) + } if r.Unsafe { l := n.Lines().Len() for i := 0; i < l; i++ { @@ -178,10 +175,10 @@ func (r *hugoContextRenderer) renderHTMLBlock( if stripped { r.logger.Warnidf(constants.WarnRenderShortcodesInHTML, ".RenderShortcodes detected inside HTML block in %q; this may not be what you intended, see https://gohugo.io/methods/page/rendershortcodes/#limitations", p) } - r.Writer.SecureWrite(w, linev) } } else { + r.logger.Warnidf(constants.WarnGoldmarkRawHTML, "Raw HTML omitted from %q; see https://gohugo.io/getting-started/configuration-markup/#rendererunsafe", p) _, _ = w.WriteString("<!-- raw HTML omitted -->\n") } } else { |