Scale a recipe, convert its units, and build a shopping list #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A cook pastes a recipe, says how many servings they want and whether they cook in metric or US units, and gets the recipe back scaled and converted. They can add several recipes to a shopping list.
src/recipe.ts, tested intest/recipe.test.ts). A recipe is plain text: a first lineServes N, then one ingredient a line,<quantity> [unit] <name>. A quantity is a whole number, a decimal, a fraction (1/2) or a mixed number (1 1/2). Units:g kg ml l tsp tbsp cup oz lb, or none (2 eggs). A line that does not read is reported with its line number, and the other lines are still read.src/scale.ts, tested intest/scale.test.ts). To M servings, every quantity is multiplied by M/N. Spoons and cups show the nearest quarter or third (1 1/3 cup); grams and millilitres show whole numbers from 10 up and one decimal below.src/convert.ts, tested intest/convert.test.ts). Metric ↔ US: g ↔ oz, kg ↔ lb, ml ↔ tsp/tbsp/cup, l ↔ cup. The unit chosen keeps the number between 1/4 and 1000 (1,500 g shows as 1.5 kg). An ingredient without a unit stays as it is.src/shopping.ts, tested intest/shopping.test.ts). From up to five recipes, the same ingredient (by name, ignoring case and a plurals) with the same unit is added up; the same ingredient in different units is listed once per unit; the list is sorted by name./recipes: its routes insrc/server.ts, its HTML insrc/pages.ts, tested intest/with vitest and ine2e/recipes.spec.tswith Playwright). Paste a recipe, enter the servings, choose Metric or US, and see the result; add it to the list, and see the shopping list. A line that did not read is shown beside its line number. Shortcut has web pages, so this is a page rather than a command.Each part comes with its tests, in the project's own test setup (vitest under
test/, Playwright undere2e/), andCHANGELOG.mdnames the change for the release-notes check./recipeslets a cook paste a plain-text… #5Shipped in cmoriarty/braid-combined-test#5, merged into
compare/groupsas1546fba65f.The OpenSpec change is archived as
2026-10-17-scale-recipes-and-shopping-list.Braid run: http://openspecflow.internal.underthere.xyz/run/run_01M54H8M577MXQ87ARQVWW46BP
/recipeslets a cook paste a plain-text recipe… #6/recipeslets a cook paste a recipe, enter the… #7/recipespage to the existing Shortcut app that reads a… #10/recipeswhere a cook pastes a recipe as… #11