Module yaml

Module yaml 

Source
Expand description

A strict YAML subset for OKF front matter.

The engine both writes and reads this front matter, so it needs exactly the shape it emits — block mappings, block sequences of scalars, and scalars — and nothing else. Implementing that subset directly (rather than pulling a general YAML parser) keeps the canonical format dependency-free and lets parse failures name the offending line.

Supported:

key: scalar          # comments, after a value or on their own line
nested:
  key: value
list:
  - item
  - item
empty_list: []
quoted: "a: value with punctuation"
nothing: null

Not supported (and rejected with a diagnostic): flow mappings, anchors, aliases, multi-line scalars, tabs for indentation, and documents whose root is not a mapping.

Structs§

YamlError
A YAML-subset parse failure, with the line it occurred on.

Enums§

Yaml
A parsed YAML-subset value.

Functions§

emit
Render a value as YAML-subset text. The root must be a mapping.
map
Build a mapping from an ordered list of entries, dropping None values.
parse
Parse a YAML-subset document. The root must be a mapping.
seq_of_strings
Build a sequence of strings.