fix: 1.5 pre-release audit #193

Merged
abiwab merged 11 commits from fix/pre-release-audit-1.5 into dev/1.5 2026-11-19 20:17:14 +01:00
44 changed files with 2512 additions and 144 deletions

View file

@ -1,6 +1,7 @@
---
"@gram-lang/parser": minor
"@gram-lang/kitchen": minor
"@gram-lang/i18n": minor
"@gram-lang/modules": minor
"@gram-lang/analyzer": minor
"@gram-lang/renderer": minor
@ -9,7 +10,7 @@
**Parser & Kitchen**: An ingredient's quantity can be written as a sum, the way American recipes measure: `@flour{1 cup + 1 tbsp}`, `@sugar{1 cup - 2 tbsp}`, `@butter{1 cup + 20 g}`:
- Any number of terms, added with `+` or taken away with `-`, each with its unit; a term can be a fraction or a range (`{1 cup + 1-2 tbsp}`). It works for an ingredient, a composite parent (`<@oranges{1 lb + 4 oz}`) and a reference (`&dough{1 kg + 200 g}`, which also sets how much of a `@use` base is made). These sums used to be a syntax error.
- A sum counts exactly as its terms written one after the other: one kind of amount adds up into one total, exactly (`1 cup + 1 tbsp` is 17 tbsp, a range by its bounds), and is usable with `gram scale --target`; a volume and a weight (`1 cup + 20 g`) stay two lines of the shopping list. Scaling multiplies each term. A step shows a sum as written; a section lists each mention as written (`100 g + 100 g`, two portions to weigh); a scaled amount and the shopping list are written the way a cook measures (`2 cup + 2 tbsp`, never `2 1/8 cup` or `34 tbsp`; `2.4 kg` in a step, `1.5 kg` to buy), for any amount, not only sums, in the views as in `gram shop` and `gram scale`; the renderer's new `formatUsageQuantity` writes an amount this way for other tools.
- A sum counts exactly as its terms written one after the other: one kind of amount adds up into one total, exactly (`1 cup + 1 tbsp` is 17 tbsp, a range by its bounds), and is usable with `gram scale --target`; a volume and a weight (`1 cup + 20 g`) stay two lines of the shopping list. Scaling multiplies each term. A step shows a sum as written; a section lists each mention as written (`100 g + 100 g`, two portions to weigh); a scaled amount and the shopping list are written the way a cook measures (`2 cup + 2 tbsp`, never `2 1/8 cup` or `34 tbsp`; `2.4 kg` in a step, `1.5 kg` to buy), for any amount, not only sums, in the views as in `gram shop` and `gram scale`; the renderer's new `formatUsageQuantity` writes an amount this way for other tools, and `@gram-lang/i18n` exports the arithmetic behind it (`termsTotal`, `mergeTerms`, `formatTerms` and the `Term` type).
- Gram never guesses: a term without a unit, a percentage, a multiplication, a range taken away, a subtraction from another kind of amount or a sum that comes to nothing raises the new `INVALID_QUANTITY` warning, with the result to write when it can tell (`{100 g + 10%}` suggests `{110 g}`), and the sum is not counted. The new `OZ_AFTER_VOLUME` note says that `oz` is a weight in `{1 cup + 2 oz}`, and `INVALID_UNIT` now asks for two quantities written side by side (`{1 kg 200 g}`) to be written as a sum.
- In the compiled JSON, a sum keeps its terms in a new `parts` field (`minus: true` on a term taken away), and its total in `qty` / `unit` as before; a sum of several kinds of amount keeps its text in `unit`, like a quantity written in words. A warning that a tool can act on carries a new `data` field (its reason and suggestion).
- Masses and nutrition weigh a sum by its parts: `@flour{1 cup + 20 g}` weighs its cup (with the flour's density) plus its 20 g, a term taken away weighs against the total, and a sum with a part Gram cannot weigh gets no mass rather than a partial one. `gram diff` shows amounts as the shopping list writes them (`1 cup + 1 tbsp → 1 cup + 3 tbsp`, `202-203 g`), from the new `fromText` / `toText` fields of an ingredient change.

View file

@ -8,4 +8,4 @@
- Quick Fixes for the quantity warnings: two quantities written side by side (`{1 cup 5 tbsp}`) become a sum (`{1 cup + 5 tbsp}`), a sum with a percentage takes the result Gram suggests (`{100 g + 10%}` → `{110 g}`), and `oz` after a volume becomes `fl oz`.
- Hovering an ingredient written as a sum shows what it adds up to (`= 17 tbsp`), or the kinds of amount it keeps apart (a volume and a weight), and its weight when the ingredient database can tell.
- Unit completion works in each term of a sum, once its number is typed (`{1 cup + 2`).
- `gram format` and format on save put one space around the `+` and `-` of a sum in an ingredient's braces (`{1 cup-2 tbsp}` → `{1 cup - 2 tbsp}`), never in a range (`{1-2 cups}`), a timer or a temperature, and remove trailing zeros term by term (`{1.50 cup + 2.0 tbsp}` → `{1.5 cup + 2 tbsp}`). The count of these fixes is reported in the new `quantityOperatorSpacing` field.
- `gram format` and format on save put one space around the `+` and `-` of a sum in an ingredient's braces (`{1 cup-2 tbsp}` → `{1 cup - 2 tbsp}`), never in a range (`{1-2 cups}`), a timer or a temperature, and remove trailing zeros from every number of a quantity, with its unit glued or spaced, in a range, a sum, a ratio or a timer (`{1.50-2.50 cup + 2.0 tbsp}` → `{1.5-2.5 cup + 2 tbsp}`, `{1.50 kg}` → `{1.5 kg}`, `~{1.50 h}` → `~{1.5 h}`). The count of these fixes is reported in the new `quantityOperatorSpacing` field.

View file

@ -8,5 +8,5 @@
**Parser & Kitchen**: Decimal numbers can be written with a comma as well as a point, so `{1,5 kg}` and `{1.5 kg}` are the same quantity:
- Works in every number in braces: ingredients, ranges, relative quantities (`{12,5% &dough}`), cookware, temperatures, timers and section anchors. Scaling, masses and the schedule read it like any other number.
- Gram has no thousands separator. A comma followed by exactly three digits, in any of these numbers (`{1,000 g}`, `{1,000% &dough}`, `~{-1,000h}`), is still read as a decimal (1 g), with a new `AMBIGUOUS_NUMBER` warning saying how it was read, in case a thousand was meant. A point keeps its meaning: `{1.000 kg}` is 1 kg, with no warning.
- `gram fmt` removes trailing zeros after a comma too (`{1,50}` → `{1,5}`), but leaves `{1,000}` as written.
- `gram format` removes trailing zeros after a comma too (`{1,50}` → `{1,5}`), but leaves `{1,000}` as written.
- Numbers written with a comma are shown in the reader's language like the others (`1,5` → `1.5` in English).

View file

@ -4,5 +4,7 @@
---
**Kitchen & Rendering**: The shopping list adds up repeated quantities of an ingredient wherever it can:
- The units of one measuring system add up into one line, in the smallest unit written (`1 cup` and `2 tbsp` give `18 tbsp`, `1 kg` and `200 g` give `1200 g`), so fewer ingredients are flagged as mixed units and more of them work with `gram scale --target`. Two systems (`1 cup` and `100 ml`) or two kinds of amount still get a line each.
- Ranges add up by their bounds (`2-3 g` and `200 g` give `202-203 g`, no longer `202.5 g`). A shopping-list entry keeps the middle in `qty` and gains a `range` field with both bounds.
- The units of one measuring system add up into one line, written the way a cook measures (`1 cup` and `2 tbsp` give `1 cup + 2 tbsp`, `1 kg` and `200 g` give `1.2 kg`), so fewer ingredients are flagged as mixed units and more of them work with `gram scale --target`.
- Two systems (`1 cup` and `100 ml`) or two kinds of amount (a volume and a weight) still get a line each.
- Ranges add up by their bounds (`2-3 g` and `200 g` give `202-203 g`, no longer `202.5 g`).
- In the compiled JSON, a shopping-list entry keeps its total in the smallest unit written (`18 tbsp`, `1200 g`) and, for a range, the middle in `qty` with a new `range` field giving both bounds.

View file

@ -12,7 +12,7 @@
**Parser, Kitchen & Analyzer**: Ingredients and timers can now be written as ratios with units:
- Write `@eggs{1 / 100 g @&flour}` or `@salt{15 g / 1 L @&water}` for an amount that follows another ingredient across units or piece counts, `&stock{250 ml / 100 g @&rice}` for a homemade preparation (a percentage such as `&stock{250% @&rice}`, ignored until now, works too), and `~{15 min / 500 g @&roast}` or `~{4 min / @&cutlet}` for a cooking time that follows a weight or a count.
- Ratios within one unit family or between pieces resolve at compile time; across mass and volume, or between weight and pieces, they use the density or unit weight of the ingredient database, and mismatched units are refused with a warning that says why (`RELATIVE_QUANTITY_UNKNOWN_MASS` now carries a `reason`) instead of guessed.
- A percentage or ratio of a homemade preparation used whole (`Roll out the &dough`) now takes the mass of the section that makes it, marked as an estimate, instead of warning that the mass is unknown.
- Ratios within one unit family or between pieces resolve at compile time; across mass and volume, or between weight and pieces, they use the density or unit weight of the ingredient database, and mismatched units are refused with a warning that says why (`RELATIVE_QUANTITY_UNKNOWN_MASS` now carries a `reason`) instead of guessed; a ratio per nothing (`/ 0 g`) raises `INVALID_QUANTITY` with the new `reason: "zeroRatioDenominator"`.
- A percentage or ratio of a homemade preparation used whole (`Roll out the &dough`) now takes the mass of the section that makes it, marked as an estimate, instead of warning that the mass is unknown; one made by a step (`Mix … ->&dough`) is refused with the new reason `stepProducer`, which asks for the amount used. Inside an imported base, a private intermediate is shown in formulas and warnings by the name its author wrote, never by its internal one (`dough$pate`).
- Scaling a recipe now resolves these ratios again and recalculates the schedule, the total times and the shopping list.
- Views show the resolved amount with its ratio in a tooltip, and the language server highlights ratios, completes their targets, renames an intermediate inside them, and adds hovers and inlay hints with what each one came to.

View file

@ -41,6 +41,7 @@ export const TRUSTED_SYNTAX_FILES: string[] = [
"ingredients",
"intermediate-variables",
"relative-quantities",
"target-states",
"temperatures",
"times",
].flatMap((name) => [

View file

@ -86,14 +86,40 @@ export const SELF_TEST_CASES: SelfTestCase[] = [
bad: "## Bake\n\nBake for ~{45min}.\n",
good: "## Bake\n\nBake for ~_{45min}.\n",
},
{
label: "comma-as-thousands-separator",
bad: "## Prep\n\nAdd @flour{1,000 g} to the bowl.\n",
good: "## Prep\n\nAdd @flour{1000 g} to the bowl.\n",
},
{
label: "decimal-point-for-hours-and-minutes",
bad: "## Bake\n\nBake for ~{1.30 h}.\n",
good: "## Bake\n\nBake for ~{1h30}.\n",
},
{
label: "space-before-ingredient-preparation",
bad: "## Prep\n\nAdd @onion{1} (diced) to the pan.\n",
good: "## Prep\n\nAdd @onion{1}(diced) to the pan.\n",
},
{
label: "space-before-cookware-preparation",
bad: "## Prep\n\nHeat the #pan{} (20cm, non-stick).\n",
good: "## Prep\n\nHeat the #pan{}(20cm, non-stick).\n",
},
{
label: "ratio-without-spaces",
bad: "## Prep\n\nWeigh @flour{500 g}.\n\nAdd @eggs{1/100g @&flour}.\n",
good: "## Prep\n\nWeigh @flour{500 g}.\n\nAdd @eggs{1 / 100 g @&flour}.\n",
},
];
// Raw ❌ glyph count observed in the EN doc as of this transcription. If the
// live count drifts, the doc likely gained (or lost) a mistake example that
// nobody transcribed here yet — print an informational note, don't fail.
// The 4 added in 1.5 (temperature note, target state) are prose mistakes no
// check can flag, so they are counted here rather than transcribed above.
const EXPECTED_BAD_GLYPH_COUNT = 26;
// The 6 prose mistakes added in 1.5 (temperature note, target state, a ratio
// or a proportional time worked out by hand) are ones no check can flag, so
// they are counted here rather than transcribed above.
const EXPECTED_BAD_GLYPH_COUNT = 33;
export function extractSelfTestSnippets(): {
bad: Snippet[];

View file

@ -25,7 +25,7 @@ describe("audit configuration", () => {
});
it("finds every trusted syntax page, in both languages", () => {
expect(TRUSTED_SYNTAX_FILES).toHaveLength(18);
expect(TRUSTED_SYNTAX_FILES).toHaveLength(20);
expect(AI_GENERATION_NOTES_FILES).toHaveLength(2);
for (const file of TRUSTED_SYNTAX_FILES) {
expect(file).toMatch(/\.mdx?$/);

View file

@ -0,0 +1,954 @@
{
"title": "Mod Ratio In Base",
"slug": "mod-ratio-in-base",
"meta": {
"title": "Mod Ratio In Base"
},
"registry": {
"ingredients": {
"flour": {
"id": "flour",
"name": "flour",
"default_unit": "g"
},
"water": {
"id": "water",
"name": "water",
"default_unit": "g"
},
"dough-pate": {
"id": "dough-pate",
"name": "pate",
"is_intermediate": true
},
"dough": {
"id": "dough",
"name": "dough",
"is_intermediate": true
},
"salt": {
"id": "salt",
"name": "salt"
},
"ricotta": {
"id": "ricotta",
"name": "ricotta",
"default_unit": "g"
},
"spinach": {
"id": "spinach",
"name": "spinach",
"default_unit": "g"
},
"pate": {
"id": "pate",
"name": "pate",
"is_intermediate": true
}
},
"cookware": {}
},
"shopping_list": [
{
"id": "flour",
"name": "flour",
"_usageIds": [
"1"
],
"qty": 500,
"unit": "g",
"normalizedMass": 500,
"isEstimate": false,
"conversionMethod": "physical"
},
{
"id": "water",
"name": "water",
"_usageIds": [
"2"
],
"qty": 300,
"unit": "g",
"normalizedMass": 300,
"isEstimate": false,
"conversionMethod": "physical"
},
{
"id": "salt",
"name": "salt",
"_usageIds": [
"3"
],
"relative": true,
"qty": 16,
"unit": "g",
"normalizedMass": 16,
"isEstimate": false,
"conversionMethod": "physical"
},
{
"id": "ricotta",
"name": "ricotta",
"_usageIds": [
"5"
],
"qty": 250,
"unit": "g",
"normalizedMass": 250,
"isEstimate": false,
"conversionMethod": "physical"
},
{
"id": "spinach",
"name": "spinach",
"_usageIds": [
"6"
],
"qty": 200,
"unit": "g",
"normalizedMass": 200,
"isEstimate": false,
"conversionMethod": "physical"
}
],
"cookware": [],
"sections": [
{
"title": "Petrissage",
"ingredients": [
{
"id": "flour",
"_usageId": "1",
"qty": 500,
"unit": "g",
"conversionMethod": "physical",
"isEstimate": false,
"normalizedMass": 500
},
{
"id": "water",
"_usageId": "2",
"qty": 300,
"unit": "g",
"conversionMethod": "physical",
"isEstimate": false,
"normalizedMass": 300
}
],
"cookware": [],
"steps": [
{
"type": "step",
"content": [
"Mix ",
{
"id": "flour",
"_usageId": "1",
"qty": 500,
"unit": "g",
"normalizedMass": 500,
"conversionMethod": "physical",
"isEstimate": false
},
"and ",
{
"id": "water",
"_usageId": "2",
"qty": 300,
"unit": "g",
"normalizedMass": 300,
"conversionMethod": "physical",
"isEstimate": false
},
". ",
{
"type": "declaration",
"name": "dough$pate",
"id": "dough-pate"
}
],
"timings": {
"start": 0,
"end": 2,
"activeDuration": 2
},
"intermediate_preparation": "dough-pate"
}
],
"module": {
"binding": "dough",
"uri": "bases/pate.gram",
"title": "Pate",
"mode": "inline"
},
"metrics": {
"totalMass": 800,
"massStatus": "precise",
"missingMassIngredients": []
}
},
{
"title": "Repos",
"ingredients": [
{
"id": "salt",
"_usageId": "3",
"qty": {
"type": "single",
"value": 16
},
"dependencies": [
"dough-pate"
],
"formula": {
"raw": "2 g / 100 g &pate",
"target": "pate",
"ratio": {
"numerator": {
"value": {
"type": "single",
"value": 2,
"text": "2"
},
"unit": "g"
},
"denominator": {
"value": 100,
"unit": "g"
},
"target": "pate",
"targetId": "dough-pate",
"referenceType": "variable",
"raw": "2 g / 100 g &pate",
"loc": {
"start": 103,
"end": 120
}
},
"isGhost": false
},
"conversionMethod": "physical",
"isEstimate": false,
"normalizedMass": 16,
"unit": "g"
},
{
"type": "reference",
"id": "dough-pate",
"name": "dough$pate",
"_usageId": "4",
"qty": 800,
"unit": "g",
"conversionMethod": "physical",
"isEstimate": false,
"normalizedMass": 800
}
],
"cookware": [],
"steps": [
{
"type": "step",
"content": [
"Work ",
{
"id": "salt",
"_usageId": "3",
"qty": {
"type": "single",
"value": 16
},
"dependencies": [
"dough-pate"
],
"formula": {
"raw": "2 g / 100 g &pate",
"target": "pate",
"ratio": {
"numerator": {
"value": {
"type": "single",
"value": 2,
"text": "2"
},
"unit": "g"
},
"denominator": {
"value": 100,
"unit": "g"
},
"target": "pate",
"targetId": "dough-pate",
"referenceType": "variable",
"raw": "2 g / 100 g &pate",
"loc": {
"start": 103,
"end": 120
}
},
"isGhost": false
},
"unit": "g",
"normalizedMass": 16,
"conversionMethod": "physical",
"isEstimate": false
},
"into the ",
{
"type": "reference",
"id": "dough-pate",
"name": "dough$pate",
"_usageId": "4",
"qty": 800,
"unit": "g",
"normalizedMass": 800,
"conversionMethod": "physical",
"isEstimate": false
},
"."
],
"timings": {
"start": 2,
"end": 4,
"activeDuration": 2
}
},
{
"type": "step",
"content": [
"Rest ",
{
"type": "timer",
"raw": "15 min / 500 g &pate",
"ratio": {
"numerator": {
"value": {
"type": "single",
"value": 15
},
"unit": "min"
},
"denominator": {
"value": 500,
"unit": "g"
},
"target": "pate",
"targetId": "dough-pate",
"referenceType": "variable",
"raw": "15 min / 500 g &pate",
"loc": {
"start": 153,
"end": 173
}
},
"quantity": {
"type": "single",
"value": 24
},
"unit": "min",
"minutes": 24
},
"."
],
"timings": {
"start": 4,
"end": 28,
"activeDuration": 24
}
}
],
"intermediate_preparation": "dough",
"module": {
"binding": "dough",
"uri": "bases/pate.gram",
"title": "Pate",
"mode": "inline"
},
"metrics": {
"totalMass": 816,
"massStatus": "precise",
"missingMassIngredients": []
}
},
{
"title": "Garniture",
"ingredients": [
{
"id": "ricotta",
"_usageId": "5",
"qty": 250,
"unit": "g",
"conversionMethod": "physical",
"isEstimate": false,
"normalizedMass": 250
},
{
"id": "spinach",
"_usageId": "6",
"qty": 200,
"unit": "g",
"conversionMethod": "physical",
"isEstimate": false,
"normalizedMass": 200
}
],
"cookware": [],
"steps": [
{
"type": "step",
"content": [
"Mix ",
{
"id": "ricotta",
"_usageId": "5",
"qty": 250,
"unit": "g",
"normalizedMass": 250,
"conversionMethod": "physical",
"isEstimate": false
},
"and ",
{
"id": "spinach",
"_usageId": "6",
"qty": 200,
"unit": "g",
"normalizedMass": 200,
"conversionMethod": "physical",
"isEstimate": false
},
". ",
{
"type": "declaration",
"name": "pate",
"id": "pate"
}
],
"timings": {
"start": 28,
"end": 30,
"activeDuration": 2
},
"intermediate_preparation": "pate"
}
],
"metrics": {
"totalMass": 450,
"massStatus": "precise",
"missingMassIngredients": []
}
},
{
"title": "Montage",
"ingredients": [
{
"type": "reference",
"id": "dough",
"name": "dough",
"_usageId": "7"
},
{
"type": "reference",
"id": "pate",
"name": "pate",
"_usageId": "8"
}
],
"cookware": [],
"steps": [
{
"type": "step",
"content": [
"Fill the ",
{
"type": "reference",
"id": "dough",
"name": "dough",
"_usageId": "7"
},
"with the ",
{
"type": "reference",
"id": "pate",
"name": "pate",
"_usageId": "8"
},
"."
],
"timings": {
"start": 30,
"end": 32,
"activeDuration": 2
}
}
],
"metrics": {
"totalMass": 0,
"massStatus": "incomplete",
"missingMassIngredients": []
}
}
],
"warnings": [
{
"code": "MISSING_INGREDIENT",
"message": "Ingredient \"flour\" not found in database — nutritional metrics and density conversions unavailable."
},
{
"code": "MISSING_INGREDIENT",
"message": "Ingredient \"water\" not found in database — nutritional metrics and density conversions unavailable."
},
{
"code": "MISSING_INGREDIENT",
"message": "Ingredient \"salt\" not found in database — nutritional metrics and density conversions unavailable."
},
{
"code": "MISSING_INGREDIENT",
"message": "Ingredient \"ricotta\" not found in database — nutritional metrics and density conversions unavailable."
},
{
"code": "MISSING_INGREDIENT",
"message": "Ingredient \"spinach\" not found in database — nutritional metrics and density conversions unavailable."
}
],
"metrics": {
"totalTime": 40,
"totalBreakdown": [
{
"label": "section_active:Petrissage",
"duration": 2
},
{
"label": "section_active:Repos",
"duration": 26
},
{
"label": "section_active:Garniture",
"duration": 2
},
{
"label": "section_active:Montage",
"duration": 2
}
],
"idleTime": 0,
"activeTime": 32,
"activeBreakdown": [
{
"label": "section_active:Petrissage",
"duration": 2
},
{
"label": "section_active:Repos",
"duration": 26
},
{
"label": "section_active:Garniture",
"duration": 2
},
{
"label": "section_active:Montage",
"duration": 2
}
],
"preparationTime": 8,
"prepBreakdown": [
{
"label": "ingredients_overhead",
"duration": 8
}
],
"totalMass": 1266,
"massStatus": "precise",
"missingMassIngredients": [],
"nutrition": {
"total": {
"calories": 0,
"fat": 0,
"carbs": 0,
"protein": 0
},
"isEstimate": false,
"coverage": 0,
"warnings": [
{
"code": "MISSING_INGREDIENT",
"message": "Ingredient \"flour\" not found in database — nutritional metrics and density conversions unavailable."
},
{
"code": "MISSING_INGREDIENT",
"message": "Ingredient \"water\" not found in database — nutritional metrics and density conversions unavailable."
},
{
"code": "MISSING_INGREDIENT",
"message": "Ingredient \"salt\" not found in database — nutritional metrics and density conversions unavailable."
},
{
"code": "MISSING_INGREDIENT",
"message": "Ingredient \"ricotta\" not found in database — nutritional metrics and density conversions unavailable."
},
{
"code": "MISSING_INGREDIENT",
"message": "Ingredient \"spinach\" not found in database — nutritional metrics and density conversions unavailable."
}
]
}
},
"miseEnPlace": [
{
"section": 0,
"duration": 2,
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2
}
]
},
{
"section": 1,
"duration": 2,
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2,
"intermediates": 1
}
]
},
{
"section": 2,
"duration": 2,
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2
}
]
},
{
"section": 3,
"duration": 2,
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2,
"intermediates": 2
}
]
}
],
"tasks": {
"tasks": [
{
"id": "s0.prep",
"kind": "prep",
"section": 0,
"duration": {
"nominal": 2
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2
}
],
"after": []
},
{
"id": "s0.0",
"kind": "step",
"section": 0,
"step": 0,
"duration": {
"nominal": 2
},
"produces": [
"dough$pate"
],
"after": []
},
{
"id": "s1.prep",
"kind": "prep",
"section": 1,
"duration": {
"nominal": 1
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 1,
"duration": 1
}
],
"after": []
},
{
"id": "s1.prep.dough-pate",
"kind": "prep",
"section": 1,
"intermediate": "dough-pate",
"duration": {
"nominal": 1
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 1,
"duration": 1,
"intermediates": 1
}
],
"after": [
"s0.0"
]
},
{
"id": "s1.0",
"kind": "step",
"section": 1,
"step": 0,
"duration": {
"nominal": 2
},
"consumes": [
"dough$pate"
],
"after": [
"s0.0"
]
},
{
"id": "s1.1",
"kind": "step",
"section": 1,
"step": 1,
"duration": {
"nominal": 24
},
"after": [
"s1.0"
]
},
{
"id": "s2.prep",
"kind": "prep",
"section": 2,
"duration": {
"nominal": 2
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2
}
],
"after": []
},
{
"id": "s2.0",
"kind": "step",
"section": 2,
"step": 0,
"duration": {
"nominal": 2
},
"produces": [
"pate"
],
"after": []
},
{
"id": "s3.prep.dough",
"kind": "prep",
"section": 3,
"intermediate": "dough",
"duration": {
"nominal": 1
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 1,
"duration": 1,
"intermediates": 1
}
],
"after": [
"s1.1"
]
},
{
"id": "s3.prep.pate",
"kind": "prep",
"section": 3,
"intermediate": "pate",
"duration": {
"nominal": 1
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 1,
"duration": 1,
"intermediates": 1
}
],
"after": [
"s2.0"
]
},
{
"id": "s3.0",
"kind": "step",
"section": 3,
"step": 0,
"duration": {
"nominal": 2
},
"consumes": [
"dough",
"pate"
],
"after": [
"s1.1",
"s2.0"
]
}
],
"sections": [
{
"day": 0
},
{
"day": 0,
"intermediate": "dough"
},
{
"day": 0
},
{
"day": 0
}
]
},
"schedule": {
"miseEnPlace": "perSection",
"rests": "shortest",
"totalTime": 40,
"activeTime": 32,
"preparationTime": 8,
"idleTime": 0,
"blocks": [
{
"kind": "prep",
"task": "s0.prep",
"section": 0,
"start": 0,
"end": 2
},
{
"kind": "step",
"task": "s0.0",
"section": 0,
"step": 0,
"start": 2,
"end": 4
},
{
"kind": "prep",
"task": "s1.prep",
"section": 1,
"start": 4,
"end": 6
},
{
"kind": "step",
"task": "s1.0",
"section": 1,
"step": 0,
"start": 6,
"end": 8
},
{
"kind": "step",
"task": "s1.1",
"section": 1,
"step": 1,
"start": 8,
"end": 32
},
{
"kind": "prep",
"task": "s2.prep",
"section": 2,
"start": 32,
"end": 34
},
{
"kind": "step",
"task": "s2.0",
"section": 2,
"step": 0,
"start": 34,
"end": 36
},
{
"kind": "prep",
"task": "s3.prep.dough",
"section": 3,
"start": 36,
"end": 38
},
{
"kind": "step",
"task": "s3.0",
"section": 3,
"step": 0,
"start": 38,
"end": 40
}
],
"days": [
{
"day": 0,
"start": 0,
"end": 40,
"sections": [
0,
1,
2,
3
]
}
]
},
"modules": [
{
"binding": "dough",
"uri": "bases/pate.gram",
"title": "Pate",
"meta": {
"title": "Pate"
},
"scaleFactor": 1,
"mode": "inline"
}
]
}

View file

@ -0,0 +1,217 @@
{
"type": "Recipe",
"meta": {
"title": "Mod Ratio In Base"
},
"imports": [
{
"type": "ImportDecl",
"specifier": "./bases/pate.gram",
"bindings": [
{
"exported": "default",
"local": "dough",
"loc": {
"start": 62,
"end": 68
}
}
],
"retroPlanning": null,
"loc": {
"start": 34,
"end": 69
}
}
],
"children": [
{
"type": "Section",
"title": "Garniture",
"retroPlanning": null,
"intermediateDecl": null,
"children": [
{
"type": "Step",
"action": null,
"children": [
{
"type": "Text",
"value": "Mix ",
"loc": {
"start": 84,
"end": 88
}
},
{
"type": "Ingredient",
"name": "ricotta",
"modifiers": [],
"quantity": {
"type": "Quantity",
"value": {
"type": "single",
"value": 250,
"text": "250"
},
"unit": "g",
"fixed": false,
"loc": {
"start": 97,
"end": 102
}
},
"alias": null,
"preparation": null,
"composite": null,
"loc": {
"start": 88,
"end": 103
}
},
{
"type": "Text",
"value": "and ",
"loc": {
"start": 104,
"end": 108
}
},
{
"type": "Ingredient",
"name": "spinach",
"modifiers": [],
"quantity": {
"type": "Quantity",
"value": {
"type": "single",
"value": 200,
"text": "200"
},
"unit": "g",
"fixed": false,
"loc": {
"start": 117,
"end": 122
}
},
"alias": null,
"preparation": null,
"composite": null,
"loc": {
"start": 108,
"end": 123
}
},
{
"type": "Text",
"value": ". ",
"loc": {
"start": 123,
"end": 125
}
},
{
"type": "IntermediateDecl",
"name": "pate",
"loc": {
"start": 125,
"end": 132
}
}
],
"loc": {
"start": 84,
"end": 134
}
}
],
"loc": {
"start": 70,
"end": 134
}
},
{
"type": "Section",
"title": "Montage",
"retroPlanning": null,
"intermediateDecl": null,
"children": [
{
"type": "Step",
"action": null,
"children": [
{
"type": "Text",
"value": "Fill the ",
"loc": {
"start": 146,
"end": 155
}
},
{
"type": "Reference",
"name": "dough",
"quantity": {
"type": "Quantity",
"value": null,
"unit": null,
"fixed": false,
"loc": {
"start": 162,
"end": 162
}
},
"loc": {
"start": 155,
"end": 163
}
},
{
"type": "Text",
"value": "with the ",
"loc": {
"start": 164,
"end": 173
}
},
{
"type": "Reference",
"name": "pate",
"quantity": {
"type": "Quantity",
"value": null,
"unit": null,
"fixed": false,
"loc": {
"start": 179,
"end": 179
}
},
"loc": {
"start": 173,
"end": 180
}
},
{
"type": "Text",
"value": ".",
"loc": {
"start": 180,
"end": 181
}
}
],
"loc": {
"start": 146,
"end": 182
}
}
],
"loc": {
"start": 134,
"end": 182
}
}
]
}

View file

@ -0,0 +1,13 @@
---
title: Pate
---
## Petrissage
Mix @flour{500 g} and @water{300 g}. ->&pate
## Repos
Work @salt{2 g / 100 g &pate} into the &pate{800 g}.
Rest ~{15 min / 500 g &pate}.

View file

@ -0,0 +1,827 @@
{
"title": "Mod Ratio In Base",
"slug": "mod-ratio-in-base",
"meta": {
"title": "Mod Ratio In Base"
},
"registry": {
"ingredients": {
"flour": {
"id": "flour",
"name": "flour",
"default_unit": "g"
},
"water": {
"id": "water",
"name": "water",
"default_unit": "g"
},
"dough-pate": {
"id": "dough-pate",
"name": "pate",
"is_intermediate": true
},
"dough": {
"id": "dough",
"name": "dough",
"is_intermediate": true
},
"salt": {
"id": "salt",
"name": "salt"
},
"ricotta": {
"id": "ricotta",
"name": "ricotta",
"default_unit": "g"
},
"spinach": {
"id": "spinach",
"name": "spinach",
"default_unit": "g"
},
"pate": {
"id": "pate",
"name": "pate",
"is_intermediate": true
}
},
"cookware": {}
},
"shopping_list": [
{
"id": "flour",
"name": "flour",
"_usageIds": [
"1"
],
"qty": 500,
"unit": "g"
},
{
"id": "water",
"name": "water",
"_usageIds": [
"2"
],
"qty": 300,
"unit": "g"
},
{
"id": "salt",
"name": "salt",
"_usageIds": [
"3"
],
"relative": true,
"qty": 16,
"unit": "g"
},
{
"id": "ricotta",
"name": "ricotta",
"_usageIds": [
"5"
],
"qty": 250,
"unit": "g"
},
{
"id": "spinach",
"name": "spinach",
"_usageIds": [
"6"
],
"qty": 200,
"unit": "g"
}
],
"cookware": [],
"sections": [
{
"title": "Petrissage",
"ingredients": [
{
"id": "flour",
"_usageId": "1",
"qty": 500,
"unit": "g"
},
{
"id": "water",
"_usageId": "2",
"qty": 300,
"unit": "g"
}
],
"cookware": [],
"steps": [
{
"type": "step",
"content": [
"Mix ",
{
"id": "flour",
"_usageId": "1",
"qty": 500,
"unit": "g"
},
"and ",
{
"id": "water",
"_usageId": "2",
"qty": 300,
"unit": "g"
},
". ",
{
"type": "declaration",
"name": "dough$pate",
"id": "dough-pate"
}
],
"timings": {
"start": 0,
"end": 2,
"activeDuration": 2
},
"intermediate_preparation": "dough-pate"
}
],
"module": {
"binding": "dough",
"uri": "bases/pate.gram",
"title": "Pate",
"mode": "inline"
}
},
{
"title": "Repos",
"ingredients": [
{
"id": "salt",
"_usageId": "3",
"qty": {
"type": "single",
"value": 16
},
"dependencies": [
"dough-pate"
],
"formula": {
"raw": "2 g / 100 g &pate",
"target": "pate",
"ratio": {
"numerator": {
"value": {
"type": "single",
"value": 2,
"text": "2"
},
"unit": "g"
},
"denominator": {
"value": 100,
"unit": "g"
},
"target": "pate",
"targetId": "dough-pate",
"referenceType": "variable",
"raw": "2 g / 100 g &pate",
"loc": {
"start": 103,
"end": 120
}
},
"isGhost": false
},
"unit": "g"
},
{
"type": "reference",
"id": "dough-pate",
"name": "dough$pate",
"_usageId": "4",
"qty": 800,
"unit": "g"
}
],
"cookware": [],
"steps": [
{
"type": "step",
"content": [
"Work ",
{
"id": "salt",
"_usageId": "3",
"qty": {
"type": "single",
"value": 16
},
"dependencies": [
"dough-pate"
],
"formula": {
"raw": "2 g / 100 g &pate",
"target": "pate",
"ratio": {
"numerator": {
"value": {
"type": "single",
"value": 2,
"text": "2"
},
"unit": "g"
},
"denominator": {
"value": 100,
"unit": "g"
},
"target": "pate",
"targetId": "dough-pate",
"referenceType": "variable",
"raw": "2 g / 100 g &pate",
"loc": {
"start": 103,
"end": 120
}
},
"isGhost": false
},
"unit": "g"
},
"into the ",
{
"type": "reference",
"id": "dough-pate",
"name": "dough$pate",
"_usageId": "4",
"qty": 800,
"unit": "g"
},
"."
],
"timings": {
"start": 2,
"end": 4,
"activeDuration": 2
}
},
{
"type": "step",
"content": [
"Rest ",
{
"type": "timer",
"raw": "15 min / 500 g &pate",
"ratio": {
"numerator": {
"value": {
"type": "single",
"value": 15
},
"unit": "min"
},
"denominator": {
"value": 500,
"unit": "g"
},
"target": "pate",
"targetId": "dough-pate",
"referenceType": "variable",
"raw": "15 min / 500 g &pate",
"loc": {
"start": 153,
"end": 173
}
},
"quantity": {
"type": "single",
"value": 24
},
"unit": "min",
"minutes": 24
},
"."
],
"timings": {
"start": 4,
"end": 28,
"activeDuration": 24
}
}
],
"intermediate_preparation": "dough",
"module": {
"binding": "dough",
"uri": "bases/pate.gram",
"title": "Pate",
"mode": "inline"
}
},
{
"title": "Garniture",
"ingredients": [
{
"id": "ricotta",
"_usageId": "5",
"qty": 250,
"unit": "g"
},
{
"id": "spinach",
"_usageId": "6",
"qty": 200,
"unit": "g"
}
],
"cookware": [],
"steps": [
{
"type": "step",
"content": [
"Mix ",
{
"id": "ricotta",
"_usageId": "5",
"qty": 250,
"unit": "g"
},
"and ",
{
"id": "spinach",
"_usageId": "6",
"qty": 200,
"unit": "g"
},
". ",
{
"type": "declaration",
"name": "pate",
"id": "pate"
}
],
"timings": {
"start": 28,
"end": 30,
"activeDuration": 2
},
"intermediate_preparation": "pate"
}
]
},
{
"title": "Montage",
"ingredients": [
{
"type": "reference",
"id": "dough",
"name": "dough",
"_usageId": "7"
},
{
"type": "reference",
"id": "pate",
"name": "pate",
"_usageId": "8"
}
],
"cookware": [],
"steps": [
{
"type": "step",
"content": [
"Fill the ",
{
"type": "reference",
"id": "dough",
"name": "dough",
"_usageId": "7"
},
"with the ",
{
"type": "reference",
"id": "pate",
"name": "pate",
"_usageId": "8"
},
"."
],
"timings": {
"start": 30,
"end": 32,
"activeDuration": 2
}
}
]
}
],
"warnings": [],
"metrics": {
"totalTime": 40,
"totalBreakdown": [
{
"label": "section_active:Petrissage",
"duration": 2
},
{
"label": "section_active:Repos",
"duration": 26
},
{
"label": "section_active:Garniture",
"duration": 2
},
{
"label": "section_active:Montage",
"duration": 2
}
],
"idleTime": 0,
"activeTime": 32,
"activeBreakdown": [
{
"label": "section_active:Petrissage",
"duration": 2
},
{
"label": "section_active:Repos",
"duration": 26
},
{
"label": "section_active:Garniture",
"duration": 2
},
{
"label": "section_active:Montage",
"duration": 2
}
],
"preparationTime": 8,
"prepBreakdown": [
{
"label": "ingredients_overhead",
"duration": 8
}
]
},
"miseEnPlace": [
{
"section": 0,
"duration": 2,
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2
}
]
},
{
"section": 1,
"duration": 2,
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2,
"intermediates": 1
}
]
},
{
"section": 2,
"duration": 2,
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2
}
]
},
{
"section": 3,
"duration": 2,
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2,
"intermediates": 2
}
]
}
],
"tasks": {
"tasks": [
{
"id": "s0.prep",
"kind": "prep",
"section": 0,
"duration": {
"nominal": 2
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2
}
],
"after": []
},
{
"id": "s0.0",
"kind": "step",
"section": 0,
"step": 0,
"duration": {
"nominal": 2
},
"produces": [
"dough$pate"
],
"after": []
},
{
"id": "s1.prep",
"kind": "prep",
"section": 1,
"duration": {
"nominal": 1
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 1,
"duration": 1
}
],
"after": []
},
{
"id": "s1.prep.dough-pate",
"kind": "prep",
"section": 1,
"intermediate": "dough-pate",
"duration": {
"nominal": 1
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 1,
"duration": 1,
"intermediates": 1
}
],
"after": [
"s0.0"
]
},
{
"id": "s1.0",
"kind": "step",
"section": 1,
"step": 0,
"duration": {
"nominal": 2
},
"consumes": [
"dough$pate"
],
"after": [
"s0.0"
]
},
{
"id": "s1.1",
"kind": "step",
"section": 1,
"step": 1,
"duration": {
"nominal": 24
},
"after": [
"s1.0"
]
},
{
"id": "s2.prep",
"kind": "prep",
"section": 2,
"duration": {
"nominal": 2
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 2,
"duration": 2
}
],
"after": []
},
{
"id": "s2.0",
"kind": "step",
"section": 2,
"step": 0,
"duration": {
"nominal": 2
},
"produces": [
"pate"
],
"after": []
},
{
"id": "s3.prep.dough",
"kind": "prep",
"section": 3,
"intermediate": "dough",
"duration": {
"nominal": 1
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 1,
"duration": 1,
"intermediates": 1
}
],
"after": [
"s1.1"
]
},
{
"id": "s3.prep.pate",
"kind": "prep",
"section": 3,
"intermediate": "pate",
"duration": {
"nominal": 1
},
"items": [
{
"kind": "gather",
"target": "ingredient",
"count": 1,
"duration": 1,
"intermediates": 1
}
],
"after": [
"s2.0"
]
},
{
"id": "s3.0",
"kind": "step",
"section": 3,
"step": 0,
"duration": {
"nominal": 2
},
"consumes": [
"dough",
"pate"
],
"after": [
"s1.1",
"s2.0"
]
}
],
"sections": [
{
"day": 0
},
{
"day": 0,
"intermediate": "dough"
},
{
"day": 0
},
{
"day": 0
}
]
},
"schedule": {
"miseEnPlace": "perSection",
"rests": "shortest",
"totalTime": 40,
"activeTime": 32,
"preparationTime": 8,
"idleTime": 0,
"blocks": [
{
"kind": "prep",
"task": "s0.prep",
"section": 0,
"start": 0,
"end": 2
},
{
"kind": "step",
"task": "s0.0",
"section": 0,
"step": 0,
"start": 2,
"end": 4
},
{
"kind": "prep",
"task": "s1.prep",
"section": 1,
"start": 4,
"end": 6
},
{
"kind": "step",
"task": "s1.0",
"section": 1,
"step": 0,
"start": 6,
"end": 8
},
{
"kind": "step",
"task": "s1.1",
"section": 1,
"step": 1,
"start": 8,
"end": 32
},
{
"kind": "prep",
"task": "s2.prep",
"section": 2,
"start": 32,
"end": 34
},
{
"kind": "step",
"task": "s2.0",
"section": 2,
"step": 0,
"start": 34,
"end": 36
},
{
"kind": "prep",
"task": "s3.prep.dough",
"section": 3,
"start": 36,
"end": 38
},
{
"kind": "step",
"task": "s3.0",
"section": 3,
"step": 0,
"start": 38,
"end": 40
}
],
"days": [
{
"day": 0,
"start": 0,
"end": 40,
"sections": [
0,
1,
2,
3
]
}
]
},
"modules": [
{
"binding": "dough",
"uri": "bases/pate.gram",
"title": "Pate",
"meta": {
"title": "Pate"
},
"scaleFactor": 1,
"mode": "inline"
}
]
}

View file

@ -0,0 +1,13 @@
---
title: Mod Ratio In Base
---
@use "./bases/pate.gram" as &dough
## Garniture
Mix @ricotta{250 g} and @spinach{200 g}. ->&pate
## Montage
Fill the &dough{} with the &pate{}.

View file

@ -643,14 +643,14 @@
"warnings": [
{
"code": "INVALID_QUANTITY",
"message": "Number \"1 / 0 g @&flour\" of \"a\" is not read: a fraction cannot have 0 below the bar (write e.g. 1/2). It is left out, as if no number had been written.",
"message": "\"a\" is per \"0 g\": a ratio cannot be per nothing of its target: write the amount it is per (e.g. / 100 g). It is left out, as if no amount had been written.",
"item": "a",
"loc": {
"start": 79,
"end": 94
},
"data": {
"reason": "zeroDenominator"
"reason": "zeroRatioDenominator"
}
},
{

View file

@ -604,14 +604,14 @@
"warnings": [
{
"code": "INVALID_QUANTITY",
"message": "Number \"1 / 0 g @&flour\" of \"a\" is not read: a fraction cannot have 0 below the bar (write e.g. 1/2). It is left out, as if no number had been written.",
"message": "\"a\" is per \"0 g\": a ratio cannot be per nothing of its target: write the amount it is per (e.g. / 100 g). It is left out, as if no amount had been written.",
"item": "a",
"loc": {
"start": 79,
"end": 94
},
"data": {
"reason": "zeroDenominator"
"reason": "zeroRatioDenominator"
}
},
{

View file

@ -340,7 +340,9 @@ function producersFirst(sections: AnalyzedSection[]): AnalyzedSection[] {
* What an intermediate used whole in `sec` weighs (`Roll out the &dough`,
* no amount written for it in the section): the mass of the section that
* makes it, when that section declares it in its title and its mass is
* complete. Refused when another section uses it too (who takes what?).
* complete. Refused when another section uses it too (who takes what?), and
* when a step makes it (`stepProducer`): what a step makes has no mass of its
* own yet.
* `null` when the section does write an amount for it.
*/
function wholeUseMass(
@ -362,6 +364,17 @@ function wholeUseMass(
s.intermediate_preparation &&
slugify(s.intermediate_preparation) === targetId,
);
if (
!producer &&
sections.some((s) =>
s.steps.some(
(step) =>
step.type === "step" && step.intermediate_preparation === targetId,
),
)
) {
return { reason: "stepProducer" };
}
const metrics = producer?.metrics;
if (!metrics || metrics.massStatus === "incomplete" || !metrics.totalMass) {
return { reason: "producerMassUnknown" };

View file

@ -178,6 +178,21 @@ Mix @flour{500 g} and @water{60% @&flour}.
"mass of the section that makes it is unknown",
);
});
it("says a step makes it, for a ratio, a share and a timer", () => {
const result = run(
"## Dough\n\nMix @flour{500 g} and @water{300 g}. ->&dough\n\n## Bake\n\nRoll out the &dough, add @salt{2 g / 100 g &dough} and @sugar{1% &dough}, bake ~{30 min / 1 kg &dough}.\n",
);
const said = result.warnings.filter(
(w) => w.code === WarningCode.RELATIVE_QUANTITY_UNKNOWN_MASS,
);
expect(said.map((w) => w.item).sort()).toEqual(["Timer", "salt", "sugar"]);
for (const warning of said) {
expect(warning.message).toContain(
"'&dough' is made by a step, not by a whole section",
);
}
});
});
describe("the schedule of a proportional time resolved here", () => {

View file

@ -1016,9 +1016,9 @@ Write durations the way recipes naturally do. Spaces don't matter (`~{1h30}`, `~
[Age] The @ham{1} in the cellar ~_{2d 4h}.
```
- **Compound units** (`~{1h30min}`, `~{2 d 4 h}`, `~{1h + 30min}`): list units from largest to smallest, each once. A trailing number without a unit is allowed right after hours (minutes) or minutes (seconds) if it is a whole number under 60 (`~{1h30}`, `~{2min30}`, not `~{1h75}`). Decimals and fractions only apply to single-unit durations (`~{1.5 h}`, `~{1½ h}`, not `~{1.5h30}`).
- **Compound units** (`~{1h30min}`, `~{2 d 4 h}`, `~{1h + 30min}`): list units from largest to smallest, each once. A trailing number without a unit is allowed right after hours (minutes) or minutes (seconds) if it is a whole number under 60 (`~{1h30}`, `~{2min30}`, not `~{1h75}`). With its unit written out, a number is read as written, even past 60: `~{1 h 75 min}` is 2 h 15 min. Decimals and fractions only apply to single-unit durations (`~{1.5 h}`, `~{1½ h}`, not `~{1.5h30}`).
- **Clock notation** (`~{1:30:00}`, `~{1:30 h}`, `~{4:30 min}`): three parts always work (`hh:mm:ss`); two parts require a leading unit so `1:30` isn't ambiguous between hours and minutes.
- **Prime notation** (`~{5'}`, `~{5'30"}`, `~{45"}`): `'` counts whole minutes and `"` counts whole seconds (typographic quotes `’`, `′`, `″`, and `''` also work).
- **Prime notation** (`~{5'}`, `~{5'30"}`, `~{45"}`): `'` counts whole minutes and `"` counts whole seconds (typographic quotes `’`, `′`, `″`, and `''` also work). Primes read like a clock: after minutes, seconds stay under 60 (`~{6'30"}`, not `~{5'90"}`).
- **Decimals** (`~{1.5 h}`, `~{1,5 h}`): periods and commas both work (see [decimal numbers](/docs/reference/syntax/ingredients/#decimal-numbers)).
:::caution
@ -1645,7 +1645,7 @@ If a ratio cannot be resolved, it remains as written in views and shopping lists
### Scope, intermediates & scaling
- **Same scope as percentages**: target an `@&ingredient` declared earlier in the section (repeated uses sum up), an earlier option in an alternative group, or an `&intermediate`.
- **Whole intermediates**: if a section consumes an intermediate without a quantity (`Roll out the &dough`), ratios and percentages (`@salt{2 g / 100 g &dough}`, `@sugar{5% &dough}`) resolve against the total mass of the section that produces it—provided only that section consumes it.
- **Whole intermediates**: if a section consumes an intermediate without a quantity (`Roll out the &dough`), ratios and percentages (`@salt{2 g / 100 g &dough}`, `@sugar{5% &dough}`) resolve against the total mass of the section that produces it—provided only that section consumes it. An intermediate made by a step (`Mix … ->&dough`) has no mass of its own: write the amount used (`&dough{800 g}`), or make it in its own section.
- **References & composites**: ratios and percentages work on homemade intermediate references (`&stock{250 ml / 100 g @&rice}`), but are not yet supported on composite parents (`@eggs{1}<@box{1 / 100 g @&flour}>`).
- **Scaling**: scaling a recipe recalculates ratios from the scaled targets (unless the target is fixed with `@=`). Marking a ratio itself with `=` is not allowed.
@ -2745,6 +2745,7 @@ For a [ratio with units](/docs/reference/syntax/relative-quantities/#ratios-with
- `incompatibleUnits`: mismatched counts (`2 slices` against cloves), a weight against a named piece, or trailing words (`100 g of`).
- `missingDensity` / `missingUnitWeight`: converting between weight and volume or pieces requires `density` or `unit_weight` in the database.
- `wholeUseAmbiguous` / `producerMassUnknown`: for an intermediate used whole (`&dough`), either another section also consumes it or the producing section's mass is incomplete.
- `stepProducer`: the intermediate used whole is made by a step (`Mix … ->&dough`), not by a whole section, and only a section's mass is weighed. Write the amount used (`&dough{500 g}`), or make it in its own section.
**Fix**: match the target's unit, add `density` or `unit_weight` to the database, or specify the intermediate's used quantity (`&dough{500 g}`).
@ -2778,6 +2779,7 @@ Emitted when a [sum of quantities](/docs/reference/syntax/ingredients/#sums-of-q
| `rangeAfterMinus` | `{1 cup - 1-2 tbsp}` | Put ranges on added terms, or write the total as a range. |
| `minusAcrossFamilies` | `{1 cup - 20 g}` | Subtract only from the same unit family (volume from volume, weight from weight). |
| `zeroDenominator` | `{1/0 cup}`, `{1/0% &dough}`, `#pan{1/0}`, `^{1/0 °C}` | Division by zero is ignored; write a valid fraction (`1/2`). |
| `zeroRatioDenominator` | `{2 g / 0 g @&flour}`, `~{15 min / 0 g @&roast}` | A ratio per nothing is ignored; write the amount it is per (`/ 100 g`). |
| `relativeNotSupported` | `@eggs{3}<@box{50% @&flour}`, `@eggs{1}<@box{1 / 100 g @&flour}` | Percentages and ratios are not supported on composite parents yet; specify the parent's quantity (`@eggs{3}<@box{1}`). |
Subtraction is checked per unit family: `{1 cup - 2 tbsp + 30 g}` is valid (2 tbsp are subtracted from 1 cup), while `{1 cup - 20 g}` has no weight to subtract from.

View file

@ -54,6 +54,7 @@ For a [ratio with units](/docs/reference/syntax/relative-quantities/#ratios-with
- `incompatibleUnits`: mismatched counts (`2 slices` against cloves), a weight against a named piece, or trailing words (`100 g of`).
- `missingDensity` / `missingUnitWeight`: converting between weight and volume or pieces requires `density` or `unit_weight` in the database.
- `wholeUseAmbiguous` / `producerMassUnknown`: for an intermediate used whole (`&dough`), either another section also consumes it or the producing section's mass is incomplete.
- `stepProducer`: the intermediate used whole is made by a step (`Mix … ->&dough`), not by a whole section, and only a section's mass is weighed. Write the amount used (`&dough{500 g}`), or make it in its own section.
**Fix**: match the target's unit, add `density` or `unit_weight` to the database, or specify the intermediate's used quantity (`&dough{500 g}`).
@ -87,6 +88,7 @@ Emitted when a [sum of quantities](/docs/reference/syntax/ingredients/#sums-of-q
| `rangeAfterMinus` | `{1 cup - 1-2 tbsp}` | Put ranges on added terms, or write the total as a range. |
| `minusAcrossFamilies` | `{1 cup - 20 g}` | Subtract only from the same unit family (volume from volume, weight from weight). |
| `zeroDenominator` | `{1/0 cup}`, `{1/0% &dough}`, `#pan{1/0}`, `^{1/0 °C}` | Division by zero is ignored; write a valid fraction (`1/2`). |
| `zeroRatioDenominator` | `{2 g / 0 g @&flour}`, `~{15 min / 0 g @&roast}` | A ratio per nothing is ignored; write the amount it is per (`/ 100 g`). |
| `relativeNotSupported` | `@eggs{3}<@box{50% @&flour}`, `@eggs{1}<@box{1 / 100 g @&flour}` | Percentages and ratios are not supported on composite parents yet; specify the parent's quantity (`@eggs{3}<@box{1}`). |
Subtraction is checked per unit family: `{1 cup - 2 tbsp + 30 g}` is valid (2 tbsp are subtracted from 1 cup), while `{1 cup - 20 g}` has no weight to subtract from.

View file

@ -86,7 +86,7 @@ If a ratio cannot be resolved, it remains as written in views and shopping lists
### Scope, intermediates & scaling
- **Same scope as percentages**: target an `@&ingredient` declared earlier in the section (repeated uses sum up), an earlier option in an alternative group, or an `&intermediate`.
- **Whole intermediates**: if a section consumes an intermediate without a quantity (`Roll out the &dough`), ratios and percentages (`@salt{2 g / 100 g &dough}`, `@sugar{5% &dough}`) resolve against the total mass of the section that produces it—provided only that section consumes it.
- **Whole intermediates**: if a section consumes an intermediate without a quantity (`Roll out the &dough`), ratios and percentages (`@salt{2 g / 100 g &dough}`, `@sugar{5% &dough}`) resolve against the total mass of the section that produces it—provided only that section consumes it. An intermediate made by a step (`Mix … ->&dough`) has no mass of its own: write the amount used (`&dough{800 g}`), or make it in its own section.
- **References & composites**: ratios and percentages work on homemade intermediate references (`&stock{250 ml / 100 g @&rice}`), but are not yet supported on composite parents (`@eggs{1}<@box{1 / 100 g @&flour}>`).
- **Scaling**: scaling a recipe recalculates ratios from the scaled targets (unless the target is fixed with `@=`). Marking a ratio itself with `=` is not allowed.

Some files were not shown because too many files have changed in this diff Show more