package transform
import "github.com/gohugoio/hugo/tpl/transform"
Package transform provides template functions for transforming content.
Index ¶
- type Namespace
- func New(deps *deps.Deps) *Namespace
- func (ns *Namespace) CanHighlight(language string) bool
- func (ns *Namespace) Emojify(s any) (template.HTML, error)
- func (ns *Namespace) HTMLEscape(s any) (string, error)
- func (ns *Namespace) HTMLUnescape(s any) (string, error)
- func (ns *Namespace) Highlight(s any, lang string, opts ...any) (template.HTML, error)
- func (ns *Namespace) HighlightCodeBlock(ctx hooks.CodeblockContext, opts ...any) (highlight.HighlightResult, error)
- func (ns *Namespace) Markdownify(ctx context.Context, s any) (template.HTML, error)
- func (ns *Namespace) Plainify(s any) (template.HTML, error)
- func (ns *Namespace) Remarshal(format string, data any) (string, error)
- func (ns *Namespace) Reset()
- func (ns *Namespace) ToMath(ctx context.Context, args ...any) (template.HTML, error)
- func (ns *Namespace) Unmarshal(args ...any) (any, error)
- func (ns *Namespace) XMLEscape(s any) (string, error)
Types ¶
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace provides template functions for the "transform" namespace.
func New ¶
New returns a new instance of the transform-namespaced template functions.
func (*Namespace) CanHighlight ¶
CanHighlight returns whether the given code language is supported by the Chroma highlighter.
func (*Namespace) Emojify ¶
Emojify returns a copy of s with all emoji codes replaced with actual emojis.
See http://www.emoji-cheat-sheet.com/
func (*Namespace) HTMLEscape ¶
HTMLEscape returns a copy of s with reserved HTML characters escaped.
func (*Namespace) HTMLUnescape ¶
HTMLUnescape returns a copy of s with HTML escape requences converted to plain text.
func (*Namespace) Highlight ¶
Highlight returns a copy of s as an HTML string with syntax highlighting applied.
func (*Namespace) HighlightCodeBlock ¶
func (ns *Namespace) HighlightCodeBlock(ctx hooks.CodeblockContext, opts ...any) (highlight.HighlightResult, error)
HighlightCodeBlock highlights a code block on the form received in the codeblock render hooks.
func (*Namespace) Markdownify ¶
Markdownify renders s from Markdown to HTML.
func (*Namespace) Plainify ¶
Plainify returns a copy of s with all HTML tags removed.
func (*Namespace) Remarshal ¶
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) ToMath ¶
ToMath converts a LaTeX string to math in the given format, default MathML. This uses KaTeX to render the math, see https://katex.org/.
func (*Namespace) Unmarshal ¶
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 ¶
XMLEscape returns the given string, removing disallowed characters then escaping the result to its XML equivalent.
Source Files ¶
init.go remarshal.go transform.go unmarshal.go
- Version
- v0.144.2 (latest)
- Published
- Feb 19, 2025
- Platform
- linux/amd64
- Imports
- 28 packages
- Last checked
- 8 hours ago –
Tools for package owners.