mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
markup/goldmark: Only log Raw HTML omitted WARN on block entering
Updates #12997
This commit is contained in:
parent
62a96cef7f
commit
6cf23bf882
1 changed files with 6 additions and 9 deletions
|
@ -159,15 +159,12 @@ func (r *hugoContextRenderer) renderHTMLBlock(
|
||||||
w util.BufWriter, source []byte, node ast.Node, entering bool,
|
w util.BufWriter, source []byte, node ast.Node, entering bool,
|
||||||
) (ast.WalkStatus, error) {
|
) (ast.WalkStatus, error) {
|
||||||
n := node.(*ast.HTMLBlock)
|
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 entering {
|
||||||
|
var p any
|
||||||
|
ctx, ok := w.(*render.Context)
|
||||||
|
if ok {
|
||||||
|
p, _ = render.GetPageAndPageInner(ctx)
|
||||||
|
}
|
||||||
if r.Unsafe {
|
if r.Unsafe {
|
||||||
l := n.Lines().Len()
|
l := n.Lines().Len()
|
||||||
for i := 0; i < l; i++ {
|
for i := 0; i < l; i++ {
|
||||||
|
@ -178,10 +175,10 @@ func (r *hugoContextRenderer) renderHTMLBlock(
|
||||||
if stripped {
|
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.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)
|
r.Writer.SecureWrite(w, linev)
|
||||||
}
|
}
|
||||||
} else {
|
} 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")
|
_, _ = w.WriteString("<!-- raw HTML omitted -->\n")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue