Add render hooks for inline and block passthrough snippets

Fixes #11927
This commit is contained in:
Bjørn Erik Pedersen
2024-08-05 11:00:47 +02:00
parent 1781b18427
commit c6227f1d85
10 changed files with 328 additions and 34 deletions

View File

@@ -18,6 +18,7 @@ import (
"math/bits"
"github.com/gohugoio/hugo/markup/converter"
"github.com/yuin/goldmark/ast"
)
type BufWriter struct {
@@ -40,9 +41,19 @@ func (b *BufWriter) Flush() error {
type Context struct {
*BufWriter
ContextData
positions []int
pids []uint64
ContextData
ordinals map[ast.NodeKind]int
}
func (ctx *Context) GetAndIncrementOrdinal(kind ast.NodeKind) int {
if ctx.ordinals == nil {
ctx.ordinals = make(map[ast.NodeKind]int)
}
i := ctx.ordinals[kind]
ctx.ordinals[kind]++
return i
}
func (ctx *Context) PushPos(n int) {