diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-02-26 12:52:06 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-02-26 21:54:36 +0100 |
commit | 928a89696273b1a5defa0e85115c9bd0e167cbf0 (patch) | |
tree | 3c9eb330385a01e230036dc018817cb50e65cbef /markup/converter | |
parent | 2e54c009331dc8c6260d16a55d4a13cfff55054d (diff) |
markup/goldmark: Add Position to CodeblockContext
But note that this is not particulary fast and the recommendad usage is error logging only.
Updates #9574
Diffstat (limited to 'markup/converter')
-rw-r--r-- | markup/converter/converter.go | 6 | ||||
-rw-r--r-- | markup/converter/hooks/hooks.go | 14 |
2 files changed, 19 insertions, 1 deletions
diff --git a/markup/converter/converter.go b/markup/converter/converter.go index 30addfec6..dac0a6b73 100644 --- a/markup/converter/converter.go +++ b/markup/converter/converter.go @@ -128,9 +128,13 @@ type DocumentContext struct { // RenderContext holds contextual information about the content to render. type RenderContext struct { - Src []byte + // Src is the content to render. + Src []byte + + // Whether to render TableOfContents. RenderTOC bool + // GerRenderer provides hook renderers on demand. GetRenderer hooks.GetRendererFunc } diff --git a/markup/converter/hooks/hooks.go b/markup/converter/hooks/hooks.go index 987cb1dc3..a570113ff 100644 --- a/markup/converter/hooks/hooks.go +++ b/markup/converter/hooks/hooks.go @@ -17,6 +17,7 @@ import ( "io" "github.com/gohugoio/hugo/common/hugio" + "github.com/gohugoio/hugo/common/text" "github.com/gohugoio/hugo/identity" "github.com/gohugoio/hugo/markup/internal/attributes" ) @@ -37,6 +38,7 @@ type LinkContext interface { type CodeblockContext interface { AttributesProvider + text.Positioner Options() map[string]interface{} Lang() string Code() string @@ -59,6 +61,10 @@ type CodeBlockRenderer interface { identity.Provider } +type IsDefaultCodeBlockRendererProvider interface { + IsDefaultCodeBlockRenderer() bool +} + // HeadingContext contains accessors to all attributes that a HeadingRenderer // can use to render a heading. type HeadingContext interface { @@ -84,6 +90,14 @@ type HeadingRenderer interface { identity.Provider } +// ElementPositionRevolver provides a way to resolve the start Position +// of a markdown element in the original source document. +// This may be both slow and aproximate, so should only be +// used for error logging. +type ElementPositionRevolver interface { + ResolvePosition(ctx interface{}) text.Position +} + type RendererType int const ( |