markup/goldmark: Add warning (using Warnidf) on Goldmark <!-- raw HTML omitted -->

Fixes #12997
This commit is contained in:
Bjørn Erik Pedersen
2024-11-03 13:37:11 +01:00
parent 30d9aea860
commit 62a96cef7f
3 changed files with 34 additions and 5 deletions

View File

@@ -159,6 +159,14 @@ 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 {
if r.Unsafe {
l := n.Lines().Len()
@@ -168,11 +176,6 @@ func (r *hugoContextRenderer) renderHTMLBlock(
var stripped bool
linev, stripped = r.stripHugoCtx(linev)
if stripped {
var p any
ctx, ok := w.(*render.Context)
if ok {
p, _ = render.GetPageAndPageInner(ctx)
}
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)
}