frontmatter

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package frontmatter reads and edits the YAML front matter of Markdown files (SKILL.md, rules) the way Studio's forms do: the fields a form edits are set, or removed when empty, and every other field is kept, in its order.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Edit

func Edit(old []byte, body string, set func(Fields)) ([]byte, error)

Edit is old (nil: a new file) with its front matter changed by set and body as its body: front matter, a blank line, then body.

func Split

func Split(data []byte) (front, body []byte, ok bool)

Split is a Markdown file's front matter (without its --- lines) and body; ok is false when it has none.

Types

type Fields

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

Fields is a front matter mapping, edited in place.

func (Fields) Bool

func (f Fields) Bool(key string, b bool)

Bool sets key to true, or removes it when b is false.

func (Fields) Flag

func (f Fields) Flag(key string, v, def bool)

Flag sets key to v, or removes it when v is def (what a missing key means).

func (Fields) Float added in v0.8.0

func (f Fields) Float(key string, x float64)

Float sets key to x, or removes it when x is 0.

func (Fields) Int

func (f Fields) Int(key string, n int)

Int sets key to n, or removes it when n is 0.

func (Fields) List

func (f Fields) List(key string, values []string)

List sets key to values, written on one line, or removes it when there are none.

func (Fields) Map

func (f Fields) Map(key string, m map[string]any)

Map sets key to m, in its keys' sorted order, or removes it when m is empty.

func (Fields) String

func (f Fields) String(key, value string)

String sets key to value, or removes it when value is "".

Jump to

Keyboard shortcuts

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