notesy::yaml

Reading and writing YAML, and a note's front matter. Needs nothing.

rustuse notesy::{editor, log, yaml};

pub fn ready() {
    let config = yaml::parse("title: Launch plan\ntags: [launch, q3]\nowner:\n  name: Ana\n")?;
    log::info(`${config.title}: ${config.tags.len()} tags`);
    log::info(yaml::text(#{ due: "2026-09-30", done: false })?);
}
Function What it does
yaml::parse(text) Ok(value): its first document, as objects, lists, text, numbers, true and false, with null (and ~) as None. Err(why) for text that isn't YAML.
yaml::text(value) Ok(text): the value written as YAML (without the --- a document can start with).
yaml::front_matter(text) Ok(#{ properties, body }): a note's front matter (the YAML between the --- lines at its very top) read as an object, empty when it has none, and the text after it. Err(why) for front matter that isn't key: value YAML.

A plain scalar reads as what it looks like: 3 is a number, true is true, 2026-09-30 is text. A quoted one is always text: "42". Anchors and aliases (&base, *base) work; an alias counts all it stands for, and a document holds at most 100,000 values and nests at most 64 deep, so a few lines can't unfold into more. At most 1 MB of text.

#Front matter, read for you

A note notesy hands a script is a Note, its front matter read for it: note.properties(), note.property("due"), and note.body() for the text after it. notes::properties(path) reads any note's without the rest.

Every page