frontmatter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package frontmatter provides utilities for parsing and formatting YAML frontmatter in markdown files.

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingFrontmatter = errors.New("missing frontmatter")

ErrMissingFrontmatter is returned by MustParse when no frontmatter is found.

Functions

func Format

func Format(matter any, body string) ([]byte, error)

Format formats content with YAML frontmatter. The matter struct is serialized to YAML and wrapped in "---" delimiters, followed by the body content.

func MustParse

func MustParse[T any](r io.Reader, matter *T) (body []byte, err error)

MustParse is like Parse but returns an error if no frontmatter is found. This is useful for files where frontmatter is required (skills).

func Parse

func Parse[T any](r io.Reader, matter *T) (body []byte, err error)

Parse extracts YAML frontmatter and body content from a reader. If no frontmatter is present, returns empty struct and full content as body. This is useful for files where frontmatter is optional (commands, agents).

func ParseHeader

func ParseHeader(r io.Reader, matter any) error

ParseHeader parses only the frontmatter from the reader. It stops reading after the closing delimiter "---". The body is not consumed or returned. Returns nil if no frontmatter is found (silent success, matter remains empty).

Types

This section is empty.

Jump to

Keyboard shortcuts

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