transform

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Identifier

type Identifier interface {
	// Key is is mostly for internal use and should be considered opaque.
	// This value may change between Hugo versions.
	Key() string
}

type Markdown

type Markdown interface {
	RenderString(ctx context.Context, args ...any) (goTemplate.HTML, error)

	markdown.Highlighter
}

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace provides template functions for the "transform" namespace.

func New

func New(md Markdown) *Namespace

New returns a new instance of the transform-namespaced template functions.

func (*Namespace) Emojify

func (ns *Namespace) Emojify(s any) (template.HTML, error)

Emojify returns a copy of s with all emoji codes replaced with actual emojis.

See http://www.emoji-cheat-sheet.com/

func (*Namespace) HTMLEscape

func (ns *Namespace) HTMLEscape(s any) (string, error)

HTMLEscape returns a copy of s with reserved HTML characters escaped.

func (*Namespace) HTMLUnescape

func (ns *Namespace) HTMLUnescape(s any) (string, error)

HTMLUnescape returns a copy of s with HTML escape requences converted to plain text.

func (*Namespace) Highlight

func (ns *Namespace) Highlight(s any, lang string, opts ...any) (template.HTML, error)

Highlight returns a copy of s as an HTML string with syntax highlighting applied.

func (*Namespace) Markdownify

func (ns *Namespace) Markdownify(ctx context.Context, s any) (template.HTML, error)

Markdownify renders s from Markdown to HTML.

func (*Namespace) Plainify

func (ns *Namespace) Plainify(s any) (string, error)

Plainify returns a copy of s with all HTML tags removed.

func (*Namespace) Remarshal

func (ns *Namespace) Remarshal(format string, data any) (string, error)

Remarshal is used in the Hugo documentation to convert configuration examples from YAML to JSON, TOML (and possibly the other way around). The is primarily a helper for the Hugo docs site. It is not a general purpose YAML to TOML converter etc., and may change without notice if it serves a purpose in the docs. Format is one of json, yaml or toml.

func (*Namespace) Reset

func (ns *Namespace) Reset()

For internal use.

func (*Namespace) Unmarshal

func (ns *Namespace) Unmarshal(args ...any) (any, error)

Unmarshal unmarshals the data given, which can be either a string, json.RawMessage or a Resource. Supported formats are JSON, TOML, YAML, and CSV. You can optionally provide an options map as the first argument.

func (*Namespace) XMLEscape

func (ns *Namespace) XMLEscape(s any) (string, error)

XMLEscape returns the given string, removing disallowed characters then escaping the result to its XML equivalent.

type ReadSeekCloserResource

type ReadSeekCloserResource interface {
	MediaType() media.Type
	io.ReadSeekCloserProvider
}

ReadSeekCloserResource is a Resource that supports loading its content.

type UnmarshableResource

type UnmarshableResource interface {
	ReadSeekCloserResource
	Identifier
}

UnmarshableResource represents a Resource that can be unmarshaled to some other format.

Jump to

Keyboard shortcuts

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