Help us shape the future of Go! Take the 2026 Go Developer Survey

frontmatter

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package frontmatter separates a leading "---"-delimited YAML block from the markdown body that follows it.

It exists so that every file in the family carrying a YAML header — a SKILL.md, a merge run's source-verification record, anything later — agrees on where the header ends. A second implementation would differ on the awkward inputs (an empty block, a missing closing delimiter, CRLF line endings), and two tools would then disagree about what a document's header is.

Unmarshalling is deliberately left to the caller: one reads the block into a map to enumerate its keys, another into a typed struct. Wrapping the YAML library here would serve neither and would only add a layer to see through.

Split is pure; nothing in this package touches the filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Split

func Split(text string) (block, body string)

Split separates a leading "---"-delimited YAML block from the markdown body.

The opening delimiter must be the document's first line; a document that does not begin with one has no frontmatter, and body is the whole document. The block ends at the next line beginning with the delimiter, and body is everything after that line.

CRLF line endings are normalized to LF before anything else, so a header written on Windows is found. That normalization lives here rather than in each caller precisely because a caller that forgets it does not get an error — it gets an empty block, and then reports the fields as missing from a file where they are plainly present.

An unterminated block is not frontmatter: the opening delimiter is left in body rather than consumed, so the one rule a caller needs is that an empty block means body holds the entire document.

Ensures: body never contains the block or its delimiters; it is pure.

Types

This section is empty.

Jump to

Keyboard shortcuts

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