From 928a89696273b1a5defa0e85115c9bd0e167cbf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 26 Feb 2022 12:52:06 +0100 Subject: markup/goldmark: Add Position to CodeblockContext But note that this is not particulary fast and the recommendad usage is error logging only. Updates #9574 --- hugolib/site.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'hugolib/site.go') diff --git a/hugolib/site.go b/hugolib/site.go index d78a4e10c..ebda29f46 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -1778,7 +1778,8 @@ var infoOnMissingLayout = map[string]bool{ type hookRendererTemplate struct { templateHandler tpl.TemplateHandler identity.SearchProvider - templ tpl.Template + templ tpl.Template + resolvePosition func(ctx interface{}) text.Position } func (hr hookRendererTemplate) RenderLink(w io.Writer, ctx hooks.LinkContext) error { @@ -1793,6 +1794,10 @@ func (hr hookRendererTemplate) RenderCodeblock(w hugio.FlexiWriter, ctx hooks.Co return hr.templateHandler.Execute(hr.templ, w, ctx) } +func (hr hookRendererTemplate) ResolvePosition(ctx interface{}) text.Position { + return hr.resolvePosition(ctx) +} + func (s *Site) renderForTemplate(name, outputFormat string, d interface{}, w io.Writer, templ tpl.Template) (err error) { if templ == nil { s.logMissingLayout(name, "", "", outputFormat) -- cgit v1.2.3