No description
Find a file
2026-03-17 22:01:57 +00:00
errors Add comments to full recipe test 2026-02-01 22:08:33 +01:00
examples/parse Add documentation updates and example usage 2026-02-01 18:41:36 +01:00
model Add comments to full recipe test 2026-02-01 22:08:33 +01:00
parser Fix parser bug 2026-02-22 10:51:39 +01:00
.woodpecker.yml Add CI 2026-03-17 22:01:57 +00:00
Cooklang Specification.pdf Initial commit 2026-02-01 18:17:17 +01:00
go.mod Add core models, parser scaffold, and tests 2026-02-01 18:22:40 +01:00
go.sum Add core models, parser scaffold, and tests 2026-02-01 18:22:40 +01:00
justfile Add comments to full recipe test 2026-02-01 22:08:33 +01:00
plan.md Add documentation updates and example usage 2026-02-01 18:41:36 +01:00
README.md Add documentation updates and example usage 2026-02-01 18:41:36 +01:00
spec.md Initial commit 2026-02-01 18:17:17 +01:00

cooklang-go

A Golang parser for the Cooklang specification. This library parses .cook recipe files and returns a structured Recipe representation with typed fields for deterministic parts of the spec and flexible containers for user-defined metadata.

Features

  • Parses Cooklang .cook files into structured Go types.
  • Canonical metadata mapped to a Metadata struct.
  • Non-canonical frontmatter stored as map[string]any.
  • Structured extraction of ingredients, cookware, timers, and steps.
  • Designed to minimize dependencies (testing uses testify).

Status

This project is under active development. See plan.md for the implementation roadmap and spec.md for the technical specification.

Installation

go get git.ctrlz.es/mgdelacroix/cooklang-go

Usage

package main

import (
    "fmt"
    "log"

    "git.ctrlz.es/mgdelacroix/cooklang-go/parser"
)

func main() {
    input := `
>> title: Pancakes
Mix @flour{200%g} with @milk{300%ml} in a #bowl.
Cook for ~time{5%min}.
`

    recipe, err := parser.ParseString(input)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(recipe.Metadata.Title)
    fmt.Println(len(recipe.Ingredients))
}

Data Model Overview

The parser returns a Recipe struct with:

  • Metadata: canonical metadata fields.
  • Frontmatter: map[string]any for non-canonical metadata.
  • Steps: ordered list of parsed steps.
  • Ingredients, Cookware, Timers: structured extracted items.

Examples

See examples/ for runnable usage samples.

Testing

Tests use the testify library.

go test ./...

License

TBD