No description
| errors | ||
| examples/parse | ||
| model | ||
| parser | ||
| .woodpecker.yml | ||
| Cooklang Specification.pdf | ||
| go.mod | ||
| go.sum | ||
| justfile | ||
| plan.md | ||
| README.md | ||
| spec.md | ||
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
.cookfiles into structured Go types. - Canonical metadata mapped to a
Metadatastruct. - 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]anyfor 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