Skip to content

Proposal 0025: alternatives for ingredients, cookware, steps and sections - #162

Draft
dubadub wants to merge 3 commits into
mainfrom
proposal/0025-alternatives
Draft

dubadub wants to merge 3 commits into
mainfrom
proposal/0025-alternatives

Conversation

@dubadub

@dubadub dubadub commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Adds a way to write "or" that applications can read: options for one ingredient or cookware slot, and labels that tie steps, notes and sections to a named decision.

Rendered proposal

Summary

  • Options. A | between components makes them options for one slot, and the first is the default: @butter{50%g}|@ghee{40%g}, #blender{}|#food processor{}. The sigil is repeated on every option. Timers can be options of each other when the later ones carry a label: ~{40%minutes}|~{12%minutes}?air-fryer.
  • Shorter forms. A later option can take the first one's amount (|@cod, |@crème fraîche{}) or its name (|{300%g}). Round brackets hold several components that replace one: @egg{1}|(@ground flax{1%tbsp} + @water{3%tbsp}). [reason] after an option says when to pick it.
  • Labels. ?label ties an option, a single component or timer, a step (?air-fryer: Cook at …), a note or a section (= Pastry ?homemade) to a named decision, so one decision can change several places at once.
  • Choices and toggles. A choice is declared, by ?choice=option in the text or by choices in front matter, and never inferred from position. Any other label is a toggle, off by default.
  • Metadata. Front matter describes the default path. choices names decisions, orders and describes their options, and lets an option replace time, servings or yield.
  • Two parts. Part 1 (options) can be accepted and implemented without Part 2 (labels and choices).

Motivation

A recipe that says @butter{} or @ghee{} puts both on the shopping list. One that says "or ghee" loses the second from the list, from pantry matching and from search. Cookware has the same problem. Bigger choices (oven or air fryer, home-made or bought pastry, same-day yeast or overnight sourdough) have no form at all, so people keep two files or write both versions in prose, and the lists, the timers and the total time are wrong for at least one of them.

0018 left optional steps and sections for a future proposal. Meanwhile implementations have their own forms: tmlmt's parser (inline and grouped alternatives, variants), Gram (@milk{100ml}|@water{95ml}), and the front-matter variables proposed in #149.

Addresses discussions #68, #75 and #122.

Things worth a reviewer's attention

  • The repeated sigil. @butter{}|@ghee{}, not @butter{}|ghee{}. Each option is a complete component, so an application that predates this proposal still highlights and lists it. The sigil after the pipe is also what tells it apart from the cooklang-rs alias pipe (@white wine|wine{}). tmlmt's parser writes the sigil once.
  • Empty braces mean "the same amount" in a later option. @double cream{300%ml}|@crème fraîche{} is 300 ml of either. Everywhere else {} means no amount.
  • ? after a component. 0018 turned down a suffix marker, @thyme{}?, because of sentences like Did you add the @salt{}?. A label needs a name glued to the ?, so that sentence stays text.
  • Choices are declared, not positional. The reasoning is in "Alternatives considered".
  • Old applications reading new files show every option and put every option on the lists. Nothing is reported as an error. The proposal asks applications that write recipes to wait for the ones that read them.
  • Diet and allergen claims. Front matter is about the default path. A claim about another path may be shown only when it is computed from that path's ingredients.
  • Out of scope: how a selection is written in a .shopping-list or .menu file or on a recipe reference. Until that is defined, a reference means the default path.
  • Open questions in the proposal: a name with no braces straight before a label or an amount option (@cod?mild, @water|{300%g}), a labelled section with no name, the opposite of a toggle, and the shape of the canonical tests.
  • Relation to Proposal 0021: alternative units and dual quantities #157 and Proposal: add named component variables #149. The pipe in Proposal 0021: alternative units and dual quantities #157 is inside the braces and does not meet this one. Proposal: add named component variables #149 takes a different route to ingredient choices; its split of one total between steps and its cookware identities are not covered here.

This PR contains the proposal only; README, EBNF, conventions and test updates follow once it is accepted.

- a pipe between components makes them options for one slot, and the
  first is the default; the sigil is repeated on every option
- a later option can take the first one's amount or its name; round
  brackets hold several components that replace one; a reason in square
  brackets follows an option
- `?label` ties an option, a single component, a step (`?label:`), a
  note or a section (`= Name ?label`) to a named decision
- choices are declared, by `?choice=option` or in front matter, never by
  position; any other label is a toggle, off by default
- front-matter `choices` names decisions, orders and describes their
  options and lets an option replace `time`, `servings` or `yield`
- two parts: options on a component can be accepted without labels
- addresses discussions #68, #75 and #122
dubadub added a commit that referenced this pull request Nov 14, 2026
- the three examples of a pipe between components now write the sigil
  on every option, the form proposed in 0025 (#162)
- no change to what this proposal defines: its pipe is inside the braces
@dubadub
dubadub marked this pull request as draft November 14, 2026 20:05
- a timer takes a label like an ingredient or a cookware item, and is
  then a timer only when the label is active
- timers are still not options: a pipe between two timers is text, with
  a canonical case and a diagnostic for it
- timers as options added to the open questions
- a pipe between two timers makes a timer group, the first is the
  default: 40 minutes, or 12 when the air-fryer label is active
- each timer option is written in full, and every one after the first
  needs a label
- a timer is not an option beside an ingredient or a cookware item
- "timers as options" leaves the open questions
@Plommonsorbet

Copy link
Copy Markdown

I want this. Substitutes cannot be expressed today at all: written as a note the substitute is absent from the ingredient list, the shopping list and pantry matching, and written as a second ingredient the shopping list asks for both. That is the case for the feature, and I do not think anything else in the open proposals is as clearly missing.

I agree it is heavy, and if it does go ahead I think part 1 is where the value is, which the proposal already allows for. My only hesitation is timing. Once something is in the spec it cannot be taken back out, and for a feature this size I would want an implementation first, so the spec does not formalise something that turns out not to be buildable, or not reasonable to build. YAML is the cautionary case, a spec with corners almost no parser implements. Same point I made on #148. There is also structural work in the cooklang-rs parser that should come first, so I would rather spend my effort there before digging into this properly. I will write that up on its own rather than argue it in pieces across proposals, so take this as a note on sequencing and not as an objection.

@dubadub

dubadub commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

The proposal has five open questions. Here they are in one place, each with what the draft says today and the other way it could go. The numbers match the "Open questions" section of the proposal. Views on any of them are welcome.

1. A selection outside the recipe. A shopping list, a menu and a reference from another recipe all need a way to say "the sourdough path of Country Loaf". The draft leaves this out: a reference with no selection means the default path. The nearest precedent is the selection lines that 0018 added to .shopping-list files. Ideas for the form are welcome.

2. A name with no braces straight before a label or an amount option.

  • @cod?mild reads as the ingredient cod with the label mild, and ~rest?slow as a timer with a label. A stricter rule would require braces before a label, @cod{}?mild, and leave @cod?mild as text.
  • @water|{300%g} can be read as water followed by an amount option. Today the name runs to the brace, and the ingredient is called water|. Written @water{}|{300%g}, it reads one way only.

Should braces be required in both places?

3. A labelled section with no name. = ?sourdough reads as an unnamed section with a label. It could be an error instead.

4. The opposite of a toggle. There is no "not". A step that is in the recipe only when a toggle is off has to be written as a choice with two options, ?milk=dairy: and ?milk=oat:. Is that enough for the recipes people write?

5. Canonical tests. The tests need a shape for a group, for a label and for choices. The draft defines the syntax and its meaning and leaves the parsed model out. What should the tests assert?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants