frontmatter

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package frontmatter parses YAML-like frontmatter ("---" ... "---") from Markdown text. It is dependency-free and shared by command, memory, and skill packages — keeping a single implementation rather than three copies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(raw []byte) string

Normalize strips a leading UTF-8 BOM and replaces CRLF with LF, returning clean UTF-8 content suitable for parsing. Use on raw []byte before Parse.

func Parse

func Parse(s string) (map[string]string, string)

Parse separates an optional leading "---"-fenced block of simple "key: value" lines from the body. Returns the parsed keys (lowercased, flattened from any depth) and the remaining body. With no opening/closing fence the whole input is the body; an unclosed opening fence is treated as body (conservatively: it's likely not frontmatter).

For large documents Parse avoids splitting the entire input: it scans for the closing fence with strings.Index, splits only the frontmatter region, and returns the body as a direct substring.

Types

This section is empty.

Jump to

Keyboard shortcuts

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