converter

package
v0.112.6 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: Apache-2.0 Imports: 11 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FeatureRenderHooks = identity.NewPathIdentity("markup", "renderingHooks")
View Source
var NopConverter = new(nopConverter)

Functions

This section is empty.

Types

type AnchorNameSanitizer added in v0.62.2

type AnchorNameSanitizer interface {
	SanitizeAnchorName(s string) string
}

AnchorNameSanitizer tells how a converter sanitizes anchor names.

type Bytes

type Bytes []byte

Bytes holds a byte slice and implements the Result interface.

func (Bytes) Bytes

func (b Bytes) Bytes() []byte

Bytes returns itself

type Converter

type Converter interface {
	Convert(ctx RenderContext) (ResultRender, error)
	Supports(feature identity.Identity) bool
}

Converter wraps the Convert method that converts some markup into another format, e.g. Markdown to HTML.

type DocumentContext

type DocumentContext struct {
	Document     any // May be nil. Usually a page.Page
	DocumentID   string
	DocumentName string
	Filename     string
}

DocumentContext holds contextual information about the document to convert.

type DocumentInfo

type DocumentInfo interface {
	AnchorSuffix() string
}

DocumentInfo holds additional information provided by some converters.

type ParseRenderer added in v0.111.0

type ParseRenderer interface {
	Parse(RenderContext) (ResultParse, error)
	Render(RenderContext, any) (ResultRender, error)
}

ParseRenderer is an optional interface. The Goldmark converter implements this, and this allows us to extract the ToC without having to render the content.

type Provider

type Provider interface {
	New(ctx DocumentContext) (Converter, error)
	Name() string
}

Provider creates converters.

func NewProvider

func NewProvider(name string, create func(ctx DocumentContext) (Converter, error)) Provider

NewProvider creates a new Provider with the given name.

type ProviderConfig

type ProviderConfig struct {
	Conf      config.AllProvider // Site config
	ContentFs afero.Fs
	Logger    loggers.Logger
	Exec      *hexec.Exec
	highlight.Highlighter
}

ProviderConfig configures a new Provider.

func (ProviderConfig) MarkupConfig

func (p ProviderConfig) MarkupConfig() markup_config.Config

type ProviderProvider

type ProviderProvider interface {
	New(cfg ProviderConfig) (Provider, error)
}

ProviderProvider creates converter providers.

type RenderContext

type RenderContext struct {
	// Ctx is the context.Context for the current Page render.
	Ctx context.Context

	// Src is the content to render.
	Src []byte

	// Whether to render TableOfContents.
	RenderTOC bool

	// GerRenderer provides hook renderers on demand.
	GetRenderer hooks.GetRendererFunc
}

RenderContext holds contextual information about the content to render.

type ResultParse added in v0.111.0

type ResultParse interface {
	Doc() any
	TableOfContents() *tableofcontents.Fragments
}

ResultParse represents the minimum returned from Parse.

type ResultRender added in v0.111.0

type ResultRender interface {
	Bytes() []byte
}

ResultRender represents the minimum returned from Convert and Render.

type TableOfContentsProvider

type TableOfContentsProvider interface {
	TableOfContents() *tableofcontents.Fragments
}

TableOfContentsProvider provides the content as a ToC structure.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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