markdown

package
v1.27.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package markdown parses and serializes inGitDB Markdown record files — YAML frontmatter delimited by "---" lines followed by a body. The body is preserved byte-for-byte across round-trips; the writer canonicalizes frontmatter key order to columns_order with alphabetical fallback for columns absent from columns_order, as required by the markdown-records feature spec.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(content []byte) (frontmatter map[string]any, body []byte, err error)

Parse splits a Markdown record into frontmatter and body.

When the file's first line is exactly "---" and a matching closing "---" appears on its own line later, the text between is parsed as a YAML mapping and returned as frontmatter; everything after the closing delimiter (including the newline that terminates the closing line) is returned as body, byte-for-byte.

When the file does not begin with "---", frontmatter is nil and the entire content is returned as body.

A leading "---" with no matching closing delimiter is a malformed frontmatter block and returns an error.

func Serialize

func Serialize(frontmatter map[string]any, columnsOrder []string, body []byte) ([]byte, error)

Serialize emits a Markdown record: an opening "---" line, the frontmatter keys in canonical order (columns_order first, then alphabetical for any keys not in columns_order), a closing "---" line, and the body bytes verbatim.

When frontmatter is empty (or nil), the output still includes the two "---" lines so the file remains a valid frontmatter document.

Types

This section is empty.

Jump to

Keyboard shortcuts

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