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 ¶
- func Edit(old []byte, body string, set func(Fields)) ([]byte, error)
- func Split(data []byte) (front, body []byte, ok bool)
- func Strict(data []byte, v any) error
- type Fields
- func (f Fields) Bool(key string, b bool)
- func (f Fields) Flag(key string, v, def bool)
- func (f Fields) Float(key string, x float64)
- func (f Fields) Int(key string, n int)
- func (f Fields) List(key string, values []string)
- func (f Fields) Map(key string, m map[string]any)
- func (f Fields) String(key, value string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Edit ¶
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 ¶
Split is a Markdown file's front matter (without its --- lines) and body; ok is false when it has none. The front matter opens with a --- line and ends at the next line that is only --- (trailing spaces and a CR allowed), never at a --- inside a value; a leading BOM and blank lines are skipped.
Types ¶
type Fields ¶
type Fields struct {
// contains filtered or unexported fields
}
Fields is a front matter mapping, edited in place.
func (Fields) List ¶
List sets key to values, written on one line, or removes it when there are none.