Gamend.Content.Frontmatter (gamend_core v1.0.1296)

Copy Markdown View Source

The --- block at the top of a markdown file.

A subset of YAML, on purpose: scalars, flow lists ([a, b]) and block lists (- a lines), and nothing nested. That is what the files in the wild use — title, description, position, keywords: [a, b], authors: [dragos] — and a YAML parser dependency to read four kinds of line would be its own liability, which is the argument the single-line reader here started from. What changed is that a list is a list rather than the string "[a, b]", and a number is a number.

Summary

Functions

Only the body.

A value as an integer, or nil.

A value as a list of strings, however it was written: a flow or block list, a comma-separated string, one string, or nothing.

Only the keys.

The block's keys and the body after it. {%{}, content} when there is none.

Types

meta()

@type meta() :: %{required(String.t()) => value()}

value()

@type value() :: String.t() | integer() | boolean() | nil | [String.t()]

Functions

body(content)

@spec body(String.t()) :: String.t()

Only the body.

integer(int)

@spec integer(value()) :: integer() | nil

A value as an integer, or nil.

list(list)

@spec list(value()) :: [String.t()]

A value as a list of strings, however it was written: a flow or block list, a comma-separated string, one string, or nothing.

meta(content)

@spec meta(String.t()) :: meta()

Only the keys.

parse(content)

@spec parse(String.t()) :: {meta(), String.t()}

The block's keys and the body after it. {%{}, content} when there is none.