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,15 +18,14 @@ import (
"bytes"
"github.com/gohugoio/hugo-goldmark-extensions/extras"
"github.com/gohugoio/hugo-goldmark-extensions/passthrough"
"github.com/gohugoio/hugo/markup/goldmark/hugocontext"
"github.com/yuin/goldmark/util"
"github.com/gohugoio/hugo/markup/goldmark/codeblocks"
"github.com/gohugoio/hugo/markup/goldmark/goldmark_config"
"github.com/gohugoio/hugo/markup/goldmark/hugocontext"
"github.com/gohugoio/hugo/markup/goldmark/images"
"github.com/gohugoio/hugo/markup/goldmark/internal/extensions/attributes"
"github.com/gohugoio/hugo/markup/goldmark/internal/render"
"github.com/gohugoio/hugo/markup/goldmark/passthrough"
"github.com/yuin/goldmark/util"
"github.com/yuin/goldmark"
emoji "github.com/yuin/goldmark-emoji"
@@ -177,32 +176,7 @@ func newMarkdown(pcfg converter.ProviderConfig) goldmark.Markdown {
}
if cfg.Extensions.Passthrough.Enable {
configuredInlines := cfg.Extensions.Passthrough.Delimiters.Inline
configuredBlocks := cfg.Extensions.Passthrough.Delimiters.Block
inlineDelimiters := make([]passthrough.Delimiters, len(configuredInlines))
blockDelimiters := make([]passthrough.Delimiters, len(configuredBlocks))
for i, d := range configuredInlines {
inlineDelimiters[i] = passthrough.Delimiters{
Open: d[0],
Close: d[1],
}
}
for i, d := range configuredBlocks {
blockDelimiters[i] = passthrough.Delimiters{
Open: d[0],
Close: d[1],
}
}
extensions = append(extensions, passthrough.New(
passthrough.Config{
InlineDelimiters: inlineDelimiters,
BlockDelimiters: blockDelimiters,
},
))
extensions = append(extensions, passthrough.New(cfg.Extensions.Passthrough))
}
if pcfg.Conf.EnableEmoji() {