imagerender

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForPage

func ForPage(lookup ImageLookupFunc) util.PrioritizedValue

ForPage creates a NodeRendererFunc priority pair for use in goldmark options. Priority 50 overrides the default image renderer (priority 1000).

Types

type Extension

type Extension struct {
	Lookup   ImageLookupFunc // legacy: creates a new Renderer with this lookup
	Renderer *Renderer       // preferred: reuse an existing Renderer (lookup swappable at runtime)
}

Extension registers the custom image renderer with Goldmark.

func (*Extension) Extend

func (e *Extension) Extend(m goldmark.Markdown)

Extend implements goldmark.Extender.

type ImageLookupFunc

type ImageLookupFunc func(imageName string, opts asset.ImageOptions) *asset.ProcessedImage

ImageLookupFunc looks up processed image data for a page's bundle-relative image. opts carries per-image overrides parsed from Goldmark attributes.

type Renderer

type Renderer struct {
	html.Config
	Lookup    ImageLookupFunc
	HasImages bool // set true when at least one image is rendered
}

Renderer replaces the default Goldmark image renderer for bundle-relative images. External/absolute URLs pass through with standard <img> rendering. The Lookup field can be swapped at runtime without rebuilding the Goldmark instance.

func NewRenderer

func NewRenderer(lookup ImageLookupFunc) *Renderer

NewRenderer creates a Goldmark image node renderer. If lookup is nil, all images render as standard <img> tags. The Lookup can be changed later via direct field assignment.

func (*Renderer) RegisterFuncs

func (r *Renderer) RegisterFuncs(reg gmrenderer.NodeRendererFuncRegisterer)

RegisterFuncs registers the renderer for ast.KindImage.

func (*Renderer) String

func (r *Renderer) String() string

String implements fmt.Stringer for debugging.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL