frontmatter

package
v0.6.6 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 2 Imported by: 0 modules, 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 is abcd's shared markdown-frontmatter line scanner. It is deliberately a line scanner, not a YAML parser: it reads only the top-level keys of the leading `---`…`---` block, first key wins, and pulls in zero dependencies. It exists so its consumers (internal/core/spec, internal/core/intent, and record-lint's top-level frontmatter checks) share ONE copy of this primitive rather than each keeping a private replica.

It is transport-agnostic: no stdout, no os.Exit, no filesystem access — the caller supplies the file's lines and decides what the fields mean.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fields

func Fields(lines []string) map[string]Field

Fields returns the top-level keys of the leading frontmatter block (the block between the first two `---` lines). Nested keys and list items are ignored, and the first occurrence of a key wins. An input whose first line is not `---` (or is empty) yields no fields. An unclosed block — a leading `---` with no closing `---` — is treated as no frontmatter (an empty map), so body prose is never harvested as fields.

func IsNull

func IsNull(v string) bool

IsNull treats an empty value and the YAML nulls ""/"null"/"~" as null.

func TrimBOM

func TrimBOM(s string) string

TrimBOM removes a single leading UTF-8 byte-order mark from s. The mark only ever appears as the file's very first bytes, so callers apply this to the first line before testing it for the opening `---`: a BOM sits invisibly ahead of the delimiter and, untrimmed, makes a well-formed record read as having no frontmatter — every frontmatter-keyed gate then passes it silently.

Types

type Field

type Field struct {
	Value string
	Line  int
}

Field is a frontmatter key's value and its 1-based source line.

Jump to

Keyboard shortcuts

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