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

@@ -78,6 +78,19 @@ type CodeblockContext interface {
Ordinal() int
}
// PassThroughContext is the context passed to a passthrough render hook.
type PassthroughContext interface {
AttributesProvider
text.Positioner
PageProvider
// Currently one of "inline" or "block".
Type() string
// Zero-based ordinal for all passthrough elements in the document.
Ordinal() int
}
type AttributesOptionsSliceProvider interface {
AttributesSlice() []attributes.Attribute
OptionsSlice() []attributes.Attribute
@@ -91,6 +104,10 @@ type CodeBlockRenderer interface {
RenderCodeblock(cctx context.Context, w hugio.FlexiWriter, ctx CodeblockContext) error
}
type PassthroughRenderer interface {
RenderPassthrough(cctx context.Context, w io.Writer, ctx PassthroughContext) error
}
type IsDefaultCodeBlockRendererProvider interface {
IsDefaultCodeBlockRenderer() bool
}
@@ -143,6 +160,7 @@ const (
ImageRendererType
HeadingRendererType
CodeBlockRendererType
PassthroughRendererType
)
type GetRendererFunc func(t RendererType, id any) any