feat: notes on temperatures, ^{160°C}(fan) #169
37 changed files with 1576 additions and 56 deletions
14
.changeset/temperature-note.md
Normal file
14
.changeset/temperature-note.md
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
"@gram-lang/parser": minor
|
||||
"@gram-lang/kitchen": minor
|
||||
"@gram-lang/analyzer": minor
|
||||
"@gram-lang/renderer": minor
|
||||
"@gram-lang/cli": minor
|
||||
---
|
||||
|
||||
**Parser & Kitchen**: A temperature can carry a note in parentheses glued to its closing brace, such as the oven mode or where it is measured: `^{160°C}(fan)`, `^oven{180°C}(grill)`, `^{63°C}(internal)`, `^{high heat}(covered)`:
|
||||
- Only a parenthesis that touches the `}` is a note, and it ends on the same line: `^{180°C} (the oven must be hot)` keeps its parenthesis in the sentence, as before.
|
||||
- The note is shown next to the temperature in every view, on screen, in Markdown, in plain text and in print, and in `gram cook`. `gram cook` now shows temperatures the way the views do (`180 °C`), including those in words (`^{high}`).
|
||||
- The AST and the compiled JSON have a new `note` field on temperatures, left out when there is none. `gram diff` reports a note that was added, removed or changed.
|
||||
- For integrators, `formatTemperature` (`@gram-lang/renderer`) displays a compiled temperature the way the views do, and the new `temperatureGroup` class holds a temperature and its note together in HTML.
|
||||
- `gram import` keeps the oven mode found in a source recipe as a note instead of leaving it in the prose.
|
||||
|
|
@ -70,6 +70,11 @@ function walk(node: unknown, shapes: Set<string>, ctx: WalkContext): void {
|
|||
if (record.preparation) shapes.add("Composite:hasPreparation");
|
||||
break;
|
||||
}
|
||||
case "Temperature": {
|
||||
// The note glued to the brace (`^{160°C}(fan)`, 1.5).
|
||||
if (record.note) shapes.add("Temperature:hasNote");
|
||||
break;
|
||||
}
|
||||
case "Timer":
|
||||
shapes.add(`Timer:isPassive=${Boolean(record.isPassive)}`);
|
||||
addDurationShapes(record.raw, "Timer", shapes);
|
||||
|
|
|
|||
363
conformance/cases/047-temperature-note/analyzed.json
Normal file
363
conformance/cases/047-temperature-note/analyzed.json
Normal file
|
|
@ -0,0 +1,363 @@
|
|||
{
|
||||
"title": "Temperature Note",
|
||||
"slug": "temperature-note",
|
||||
"meta": {
|
||||
"title": "Temperature Note"
|
||||
},
|
||||
"registry": {
|
||||
"ingredients": {},
|
||||
"cookware": {}
|
||||
},
|
||||
"shopping_list": [],
|
||||
"cookware": [],
|
||||
"sections": [
|
||||
{
|
||||
"title": "Bake",
|
||||
"ingredients": [],
|
||||
"cookware": [],
|
||||
"steps": [
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Preheat ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"quantity": {
|
||||
"type": "single",
|
||||
"value": 160,
|
||||
"text": "160"
|
||||
},
|
||||
"unit": "°C",
|
||||
"note": "chaleur tournante"
|
||||
},
|
||||
"."
|
||||
],
|
||||
"timings": {
|
||||
"start": 0,
|
||||
"end": 2,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Roast in the ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"name": "oven",
|
||||
"quantity": {
|
||||
"type": "single",
|
||||
"value": 180,
|
||||
"text": "180"
|
||||
},
|
||||
"unit": "°C",
|
||||
"note": "gril"
|
||||
},
|
||||
"."
|
||||
],
|
||||
"timings": {
|
||||
"start": 2,
|
||||
"end": 4,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Simmer on ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"text": "vif",
|
||||
"note": "à couvert"
|
||||
},
|
||||
"."
|
||||
],
|
||||
"timings": {
|
||||
"start": 4,
|
||||
"end": 6,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Bake at ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"quantity": {
|
||||
"type": "single",
|
||||
"value": 180,
|
||||
"text": "180"
|
||||
},
|
||||
"unit": "°C"
|
||||
},
|
||||
"(four préchauffé)."
|
||||
],
|
||||
"timings": {
|
||||
"start": 6,
|
||||
"end": 8,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Rest at ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"quantity": {
|
||||
"type": "single",
|
||||
"value": 20,
|
||||
"text": "20"
|
||||
},
|
||||
"unit": "°C"
|
||||
},
|
||||
"."
|
||||
],
|
||||
"timings": {
|
||||
"start": 8,
|
||||
"end": 10,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Cook at ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"quantity": {
|
||||
"type": "single",
|
||||
"value": 200,
|
||||
"text": "200"
|
||||
},
|
||||
"unit": "°C"
|
||||
},
|
||||
"(about 20 min"
|
||||
],
|
||||
"timings": {
|
||||
"start": 10,
|
||||
"end": 12,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Serve (hot)."
|
||||
],
|
||||
"timings": {
|
||||
"start": 12,
|
||||
"end": 14,
|
||||
"activeDuration": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"metrics": {
|
||||
"totalMass": 0,
|
||||
"massStatus": "incomplete",
|
||||
"missingMassIngredients": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"warnings": [],
|
||||
"metrics": {
|
||||
"totalTime": 14,
|
||||
"totalBreakdown": [
|
||||
{
|
||||
"label": "section_active:Bake",
|
||||
"duration": 14
|
||||
}
|
||||
],
|
||||
"idleTime": 0,
|
||||
"activeTime": 14,
|
||||
"activeBreakdown": [
|
||||
{
|
||||
"label": "section_active:Bake",
|
||||
"duration": 14
|
||||
}
|
||||
],
|
||||
"preparationTime": 0,
|
||||
"totalMass": 0,
|
||||
"massStatus": "incomplete",
|
||||
"missingMassIngredients": [],
|
||||
"nutrition": {
|
||||
"total": {
|
||||
"calories": 0,
|
||||
"fat": 0,
|
||||
"carbs": 0,
|
||||
"protein": 0
|
||||
},
|
||||
"isEstimate": false,
|
||||
"coverage": 0
|
||||
}
|
||||
},
|
||||
"miseEnPlace": [],
|
||||
"tasks": {
|
||||
"tasks": [
|
||||
{
|
||||
"id": "s0.0",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 0,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": []
|
||||
},
|
||||
{
|
||||
"id": "s0.1",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 1,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "s0.2",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 2,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "s0.3",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 3,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "s0.4",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 4,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "s0.5",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 5,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.4"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "s0.6",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 6,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.5"
|
||||
]
|
||||
}
|
||||
],
|
||||
"sections": [
|
||||
{
|
||||
"day": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"schedule": {
|
||||
"miseEnPlace": "perSection",
|
||||
"rests": "shortest",
|
||||
"totalTime": 14,
|
||||
"activeTime": 14,
|
||||
"preparationTime": 0,
|
||||
"idleTime": 0,
|
||||
"blocks": [
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.0",
|
||||
"section": 0,
|
||||
"step": 0,
|
||||
"start": 0,
|
||||
"end": 2
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.1",
|
||||
"section": 0,
|
||||
"step": 1,
|
||||
"start": 2,
|
||||
"end": 4
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.2",
|
||||
"section": 0,
|
||||
"step": 2,
|
||||
"start": 4,
|
||||
"end": 6
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.3",
|
||||
"section": 0,
|
||||
"step": 3,
|
||||
"start": 6,
|
||||
"end": 8
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.4",
|
||||
"section": 0,
|
||||
"step": 4,
|
||||
"start": 8,
|
||||
"end": 10
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.5",
|
||||
"section": 0,
|
||||
"step": 5,
|
||||
"start": 10,
|
||||
"end": 12
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.6",
|
||||
"section": 0,
|
||||
"step": 6,
|
||||
"start": 12,
|
||||
"end": 14
|
||||
}
|
||||
],
|
||||
"days": [
|
||||
{
|
||||
"day": 0,
|
||||
"start": 0,
|
||||
"end": 14,
|
||||
"sections": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
277
conformance/cases/047-temperature-note/ast.json
Normal file
277
conformance/cases/047-temperature-note/ast.json
Normal file
|
|
@ -0,0 +1,277 @@
|
|||
{
|
||||
"type": "Recipe",
|
||||
"meta": {
|
||||
"title": "Temperature Note"
|
||||
},
|
||||
"imports": [],
|
||||
"children": [
|
||||
{
|
||||
"type": "Section",
|
||||
"title": "Bake",
|
||||
"retroPlanning": null,
|
||||
"intermediateDecl": null,
|
||||
"children": [
|
||||
{
|
||||
"type": "Step",
|
||||
"action": null,
|
||||
"children": [
|
||||
{
|
||||
"type": "Text",
|
||||
"value": "Preheat ",
|
||||
"loc": {
|
||||
"start": 42,
|
||||
"end": 50
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Temperature",
|
||||
"name": null,
|
||||
"loc": {
|
||||
"start": 50,
|
||||
"end": 77
|
||||
},
|
||||
"note": "chaleur tournante",
|
||||
"value": {
|
||||
"type": "single",
|
||||
"value": 160,
|
||||
"text": "160"
|
||||
},
|
||||
"unit": "°C"
|
||||
},
|
||||
{
|
||||
"type": "Text",
|
||||
"value": ".",
|
||||
"loc": {
|
||||
"start": 77,
|
||||
"end": 78
|
||||
}
|
||||
}
|
||||
],
|
||||
"loc": {
|
||||
"start": 42,
|
||||
"end": 80
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Step",
|
||||
"action": null,
|
||||
"children": [
|
||||
{
|
||||
"type": "Text",
|
||||
"value": "Roast in the ",
|
||||
"loc": {
|
||||
"start": 80,
|
||||
"end": 93
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Temperature",
|
||||
"name": "oven",
|
||||
"loc": {
|
||||
"start": 93,
|
||||
"end": 111
|
||||
},
|
||||
"note": "gril",
|
||||
"value": {
|
||||
"type": "single",
|
||||
"value": 180,
|
||||
"text": "180"
|
||||
},
|
||||
"unit": "°C"
|
||||
},
|
||||
{
|
||||
"type": "Text",
|
||||
"value": ".",
|
||||
"loc": {
|
||||
"start": 111,
|
||||
"end": 112
|
||||
}
|
||||
}
|
||||
],
|
||||
"loc": {
|
||||
"start": 80,
|
||||
"end": 114
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Step",
|
||||
"action": null,
|
||||
"children": [
|
||||
{
|
||||
"type": "Text",
|
||||
"value": "Simmer on ",
|
||||
"loc": {
|
||||
"start": 114,
|
||||
"end": 124
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Temperature",
|
||||
"name": null,
|
||||
"loc": {
|
||||
"start": 124,
|
||||
"end": 141
|
||||
},
|
||||
"note": "à couvert",
|
||||
"text": "vif"
|
||||
},
|
||||
{
|
||||
"type": "Text",
|
||||
"value": ".",
|
||||
"loc": {
|
||||
"start": 141,
|
||||
"end": 142
|
||||
}
|
||||
}
|
||||
],
|
||||
"loc": {
|
||||
"start": 114,
|
||||
"end": 144
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Step",
|
||||
"action": null,
|
||||
"children": [
|
||||
{
|
||||
"type": "Text",
|
||||
"value": "Bake at ",
|
||||
"loc": {
|
||||
"start": 144,
|
||||
"end": 152
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Temperature",
|
||||
"name": null,
|
||||
"loc": {
|
||||
"start": 152,
|
||||
"end": 160
|
||||
},
|
||||
"value": {
|
||||
"type": "single",
|
||||
"value": 180,
|
||||
"text": "180"
|
||||
},
|
||||
"unit": "°C"
|
||||
},
|
||||
{
|
||||
"type": "Text",
|
||||
"value": "(four préchauffé).",
|
||||
"loc": {
|
||||
"start": 161,
|
||||
"end": 179
|
||||
}
|
||||
}
|
||||
],
|
||||
"loc": {
|
||||
"start": 144,
|
||||
"end": 181
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Step",
|
||||
"action": null,
|
||||
"children": [
|
||||
{
|
||||
"type": "Text",
|
||||
"value": "Rest at ",
|
||||
"loc": {
|
||||
"start": 181,
|
||||
"end": 189
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Temperature",
|
||||
"name": null,
|
||||
"loc": {
|
||||
"start": 189,
|
||||
"end": 198
|
||||
},
|
||||
"value": {
|
||||
"type": "single",
|
||||
"value": 20,
|
||||
"text": "20"
|
||||
},
|
||||
"unit": "°C"
|
||||
},
|
||||
{
|
||||
"type": "Text",
|
||||
"value": ".",
|
||||
"loc": {
|
||||
"start": 198,
|
||||
"end": 199
|
||||
}
|
||||
}
|
||||
],
|
||||
"loc": {
|
||||
"start": 181,
|
||||
"end": 201
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Step",
|
||||
"action": null,
|
||||
"children": [
|
||||
{
|
||||
"type": "Text",
|
||||
"value": "Cook at ",
|
||||
"loc": {
|
||||
"start": 201,
|
||||
"end": 209
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Temperature",
|
||||
"name": null,
|
||||
"loc": {
|
||||
"start": 209,
|
||||
"end": 217
|
||||
},
|
||||
"value": {
|
||||
"type": "single",
|
||||
"value": 200,
|
||||
"text": "200"
|
||||
},
|
||||
"unit": "°C"
|
||||
},
|
||||
{
|
||||
"type": "Text",
|
||||
"value": "(about 20 min",
|
||||
"loc": {
|
||||
"start": 217,
|
||||
"end": 230
|
||||
}
|
||||
}
|
||||
],
|
||||
"loc": {
|
||||
"start": 201,
|
||||
"end": 232
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Step",
|
||||
"action": null,
|
||||
"children": [
|
||||
{
|
||||
"type": "Text",
|
||||
"value": "Serve (hot).",
|
||||
"loc": {
|
||||
"start": 232,
|
||||
"end": 244
|
||||
}
|
||||
}
|
||||
],
|
||||
"loc": {
|
||||
"start": 232,
|
||||
"end": 245
|
||||
}
|
||||
}
|
||||
],
|
||||
"loc": {
|
||||
"start": 33,
|
||||
"end": 245
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
345
conformance/cases/047-temperature-note/compiled.json
Normal file
345
conformance/cases/047-temperature-note/compiled.json
Normal file
|
|
@ -0,0 +1,345 @@
|
|||
{
|
||||
"title": "Temperature Note",
|
||||
"slug": "temperature-note",
|
||||
"meta": {
|
||||
"title": "Temperature Note"
|
||||
},
|
||||
"registry": {
|
||||
"ingredients": {},
|
||||
"cookware": {}
|
||||
},
|
||||
"shopping_list": [],
|
||||
"cookware": [],
|
||||
"sections": [
|
||||
{
|
||||
"title": "Bake",
|
||||
"ingredients": [],
|
||||
"cookware": [],
|
||||
"steps": [
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Preheat ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"quantity": {
|
||||
"type": "single",
|
||||
"value": 160,
|
||||
"text": "160"
|
||||
},
|
||||
"unit": "°C",
|
||||
"note": "chaleur tournante"
|
||||
},
|
||||
"."
|
||||
],
|
||||
"timings": {
|
||||
"start": 0,
|
||||
"end": 2,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Roast in the ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"name": "oven",
|
||||
"quantity": {
|
||||
"type": "single",
|
||||
"value": 180,
|
||||
"text": "180"
|
||||
},
|
||||
"unit": "°C",
|
||||
"note": "gril"
|
||||
},
|
||||
"."
|
||||
],
|
||||
"timings": {
|
||||
"start": 2,
|
||||
"end": 4,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Simmer on ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"text": "vif",
|
||||
"note": "à couvert"
|
||||
},
|
||||
"."
|
||||
],
|
||||
"timings": {
|
||||
"start": 4,
|
||||
"end": 6,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Bake at ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"quantity": {
|
||||
"type": "single",
|
||||
"value": 180,
|
||||
"text": "180"
|
||||
},
|
||||
"unit": "°C"
|
||||
},
|
||||
"(four préchauffé)."
|
||||
],
|
||||
"timings": {
|
||||
"start": 6,
|
||||
"end": 8,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Rest at ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"quantity": {
|
||||
"type": "single",
|
||||
"value": 20,
|
||||
"text": "20"
|
||||
},
|
||||
"unit": "°C"
|
||||
},
|
||||
"."
|
||||
],
|
||||
"timings": {
|
||||
"start": 8,
|
||||
"end": 10,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Cook at ",
|
||||
{
|
||||
"type": "temperature",
|
||||
"quantity": {
|
||||
"type": "single",
|
||||
"value": 200,
|
||||
"text": "200"
|
||||
},
|
||||
"unit": "°C"
|
||||
},
|
||||
"(about 20 min"
|
||||
],
|
||||
"timings": {
|
||||
"start": 10,
|
||||
"end": 12,
|
||||
"activeDuration": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "step",
|
||||
"content": [
|
||||
"Serve (hot)."
|
||||
],
|
||||
"timings": {
|
||||
"start": 12,
|
||||
"end": 14,
|
||||
"activeDuration": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"warnings": [],
|
||||
"metrics": {
|
||||
"totalTime": 14,
|
||||
"totalBreakdown": [
|
||||
{
|
||||
"label": "section_active:Bake",
|
||||
"duration": 14
|
||||
}
|
||||
],
|
||||
"idleTime": 0,
|
||||
"activeTime": 14,
|
||||
"activeBreakdown": [
|
||||
{
|
||||
"label": "section_active:Bake",
|
||||
"duration": 14
|
||||
}
|
||||
],
|
||||
"preparationTime": 0
|
||||
},
|
||||
"miseEnPlace": [],
|
||||
"tasks": {
|
||||
"tasks": [
|
||||
{
|
||||
"id": "s0.0",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 0,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": []
|
||||
},
|
||||
{
|
||||
"id": "s0.1",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 1,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "s0.2",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 2,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "s0.3",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 3,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "s0.4",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 4,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.3"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "s0.5",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 5,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.4"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "s0.6",
|
||||
"kind": "step",
|
||||
"section": 0,
|
||||
"step": 6,
|
||||
"duration": {
|
||||
"nominal": 2
|
||||
},
|
||||
"after": [
|
||||
"s0.5"
|
||||
]
|
||||
}
|
||||
],
|
||||
"sections": [
|
||||
{
|
||||
"day": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"schedule": {
|
||||
"miseEnPlace": "perSection",
|
||||
"rests": "shortest",
|
||||
"totalTime": 14,
|
||||
"activeTime": 14,
|
||||
"preparationTime": 0,
|
||||
"idleTime": 0,
|
||||
"blocks": [
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.0",
|
||||
"section": 0,
|
||||
"step": 0,
|
||||
"start": 0,
|
||||
"end": 2
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.1",
|
||||
"section": 0,
|
||||
"step": 1,
|
||||
"start": 2,
|
||||
"end": 4
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.2",
|
||||
"section": 0,
|
||||
"step": 2,
|
||||
"start": 4,
|
||||
"end": 6
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.3",
|
||||
"section": 0,
|
||||
"step": 3,
|
||||
"start": 6,
|
||||
"end": 8
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.4",
|
||||
"section": 0,
|
||||
"step": 4,
|
||||
"start": 8,
|
||||
"end": 10
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.5",
|
||||
"section": 0,
|
||||
"step": 5,
|
||||
"start": 10,
|
||||
"end": 12
|
||||
},
|
||||
{
|
||||
"kind": "step",
|
||||
"task": "s0.6",
|
||||
"section": 0,
|
||||
"step": 6,
|
||||
"start": 12,
|
||||
"end": 14
|
||||
}
|
||||
],
|
||||
"days": [
|
||||
{
|
||||
"day": 0,
|
||||
"start": 0,
|
||||
"end": 14,
|
||||
"sections": [
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
19
conformance/cases/047-temperature-note/input.gram
Normal file
19
conformance/cases/047-temperature-note/input.gram
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
---
|
||||
title: Temperature Note
|
||||
---
|
||||
|
||||
## Bake
|
||||
|
||||
Preheat ^{160°C}(chaleur tournante).
|
||||
|
||||
Roast in the ^oven{180°C}(gril).
|
||||
|
||||
Simmer on ^{vif}(à couvert).
|
||||
|
||||
Bake at ^{180°C} (four préchauffé).
|
||||
|
||||
Rest at ^{20°C}().
|
||||
|
||||
Cook at ^{200°C}(about 20 min
|
||||
|
||||
Serve (hot).
|
||||
|
|
@ -38,6 +38,11 @@ const ADDED_SINCE_1_3_0 = new Set([
|
|||
// the duration in minutes.
|
||||
const TIMER_ADDED_SINCE_1_3_0 = new Set(["raw", "minutes"]);
|
||||
|
||||
// Added after 1.3.0 inside a step's temperature token (1.5): the note glued
|
||||
// to its brace (`^{160°C}(fan)`). Left out when absent, so no case of the tag
|
||||
// moves; listed so a note never moves a digest.
|
||||
const TEMPERATURE_ADDED_SINCE_1_3_0 = new Set(["note"]);
|
||||
|
||||
// Added after 1.3.0 on any ingredient, reference or composite parent (1.5):
|
||||
// the terms of a sum of quantities (`{1 cup + 1 tbsp}`). A sum did not parse
|
||||
// in 1.3.0, so no case of the tag has one; listed so a sum never moves a digest.
|
||||
|
|
@ -52,9 +57,12 @@ const isShoppingRange = (value: object, key: string): boolean =>
|
|||
function canonical(value: unknown): string {
|
||||
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
||||
if (value && typeof value === "object") {
|
||||
const isTimer = (value as { type?: unknown }).type === "timer";
|
||||
const type = (value as { type?: unknown }).type;
|
||||
const isTimer = type === "timer";
|
||||
const isTemperature = type === "temperature";
|
||||
const entries = Object.entries(value as Record<string, unknown>)
|
||||
.filter(([k]) => !(isTimer && TIMER_ADDED_SINCE_1_3_0.has(k)))
|
||||
.filter(([k]) => !(isTemperature && TEMPERATURE_ADDED_SINCE_1_3_0.has(k)))
|
||||
.filter(([k]) => !QUANTITY_ADDED_SINCE_1_3_0.has(k))
|
||||
.filter(([k]) => !isShoppingRange(value, k))
|
||||
.sort(([a], [b]) => (a < b ? -1 : 1))
|
||||
|
|
|
|||
|
|
@ -87,8 +87,16 @@ export interface TemperatureDelta {
|
|||
section: string | null;
|
||||
name?: string;
|
||||
change: "added" | "removed" | "changed";
|
||||
from?: { value: number; unit: string; range?: { min: number; max: number } };
|
||||
to?: { value: number; unit: string; range?: { min: number; max: number } };
|
||||
from?: TemperatureValue;
|
||||
to?: TemperatureValue;
|
||||
}
|
||||
|
||||
/** A temperature as `diffTemperatures` compares it. `note` since 1.5.0. */
|
||||
export interface TemperatureValue {
|
||||
value: number;
|
||||
unit: string;
|
||||
range?: { min: number; max: number };
|
||||
note?: string;
|
||||
}
|
||||
|
||||
export interface TimerDelta {
|
||||
|
|
@ -257,11 +265,7 @@ function fmtTimerQty(
|
|||
return `?${u}`;
|
||||
}
|
||||
|
||||
function getTempValue(token: ProcessedTemperature): {
|
||||
value: number;
|
||||
unit: string;
|
||||
range?: { min: number; max: number };
|
||||
} | null {
|
||||
function getTempValue(token: ProcessedTemperature): TemperatureValue | null {
|
||||
const q = token.quantity;
|
||||
if (!q) return null;
|
||||
const value =
|
||||
|
|
@ -277,7 +281,12 @@ function getTempValue(token: ProcessedTemperature): {
|
|||
typeof q === "object" && "type" in q && q.type === "range" && q.range
|
||||
? q.range
|
||||
: undefined;
|
||||
return { value, unit: token.unit ?? "°", range };
|
||||
return {
|
||||
value,
|
||||
unit: token.unit ?? "°",
|
||||
range,
|
||||
...(token.note ? { note: token.note } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function isProcessedTimer(token: StepToken): token is ProcessedTimer {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,19 @@ describe("diffRecipes — temperature ranges", () => {
|
|||
expect(temperatures[0]?.to?.range).toEqual({ min: 100, max: 400 });
|
||||
});
|
||||
|
||||
it("detects a change of note on the same value (1.5)", () => {
|
||||
const a = compileRecipe("## Section\n\nBake at ^{180C}(fan).\n");
|
||||
const b = compileRecipe("## Section\n\nBake at ^{180C}(grill).\n");
|
||||
const { temperatures } = diffRecipes(a, b);
|
||||
expect(temperatures).toHaveLength(1);
|
||||
expect(temperatures[0]?.from).toMatchObject({ value: 180, note: "fan" });
|
||||
expect(temperatures[0]?.to).toMatchObject({ value: 180, note: "grill" });
|
||||
const c = compileRecipe("## Section\n\nBake at ^{180C}.\n");
|
||||
const added = diffRecipes(c, a).temperatures;
|
||||
expect(added).toHaveLength(1);
|
||||
expect(added[0]?.from && "note" in added[0].from).toBe(false);
|
||||
});
|
||||
|
||||
it("reports no change when both value and range are identical", () => {
|
||||
const a = compileRecipe("## Section\nBake at ^{200-300C}.\n");
|
||||
const b = compileRecipe("## Section\nBake at ^{200-300C}.\n");
|
||||
|
|
|
|||
|
|
@ -432,7 +432,7 @@ RULE — active vs passive vs sequential:
|
|||
|
||||
### Temperatures
|
||||
|
||||
Syntax: \`^name?{value}\`
|
||||
Syntax: \`^name?{value}(note)?\`
|
||||
|
||||
\`^\` is the ONLY valid temperature sigil — never \`°\`, which is not a recognized element trigger. The degree sign is still used inside the unit itself (\`°C\`/\`°F\`), and is also accepted bare (\`C\`/\`F\`), case-insensitively.
|
||||
|
||||
|
|
@ -441,10 +441,13 @@ Syntax: \`^name?{value}\`
|
|||
| Exact | \`^{180C}\` | Numeric temperature; unit mandatory, one of \`C\`, \`F\`, \`°C\`, \`°F\` (case-insensitive) |
|
||||
| Semantic | \`^{medium heat}\` | Stove settings, water state, etc. |
|
||||
| Named | \`^oven{180C}\` | When multiple heat sources are active |
|
||||
| With note | \`^{160C}(fan)\` | Cooking mode, probe target, or condition that goes with the temperature |
|
||||
|
||||
Range: \`^{180-200C}\`
|
||||
The compiler stores the raw numeric value and normalizes the unit to \`°C\`/\`°F\`; the display engine handles further formatting. Only Celsius and Fahrenheit are supported — no Kelvin or other scales.
|
||||
|
||||
Note: when the source gives the oven mode or what the temperature is measured on (fan, convection, broil, conventional, internal, covered), keep it in the note glued to the brace — \`^{160C}(fan)\`, \`^{63C}(internal)\`, \`^{high heat}(covered)\` — instead of leaving it in the prose. Keep the note in the recipe's language. The parenthesis must touch the \`}\`: \`^{180C} (preheated)\` with a space is ordinary text. One line, no nested parentheses.
|
||||
|
||||
|
||||
═════════════════════════════════════════
|
||||
SECTION 6 — INTERMEDIATE PREPARATIONS
|
||||
|
|
|
|||
|
|
@ -1,24 +1,15 @@
|
|||
import React from "react";
|
||||
import { Box, Text } from "ink";
|
||||
import chalk from "chalk";
|
||||
import { formatTimerDuration } from "@gram-lang/renderer";
|
||||
import { formatTemperature, formatTimerDuration } from "@gram-lang/renderer";
|
||||
import type { ActiveTimer, FlatStep } from "./types";
|
||||
import type { CompilationResult } from "@gram-lang/kitchen";
|
||||
import { fmtQty, fmtMass, fmtCountdown, shouldShowMass } from "./prepare";
|
||||
|
||||
function getQtyText(q: any): string {
|
||||
if (!q) return "";
|
||||
if (typeof q === "number") return String(q);
|
||||
return (
|
||||
q.text ??
|
||||
(q.value != null
|
||||
? String(typeof q.value === "object" ? q.value.value : q.value)
|
||||
: "")
|
||||
);
|
||||
}
|
||||
|
||||
function getTempDisplay(token: any): string {
|
||||
return `${getQtyText(token.quantity)}${token.unit ?? "°"}`;
|
||||
/** A temperature as the views show it (`180 °C`, `vif`), with its note. */
|
||||
export function getTempDisplay(token: any): string {
|
||||
const value = formatTemperature(token);
|
||||
return token.note ? `${value} (${token.note})` : value;
|
||||
}
|
||||
|
||||
/** A timer as the views show it (`1 h 30 min`, `1–2 h`), or as written when refused. */
|
||||
|
|
|
|||
|
|
@ -29,9 +29,13 @@ function fmtMetaValue(v: unknown): string {
|
|||
return String(v);
|
||||
}
|
||||
|
||||
function fmtTempValue(v?: { value: number; unit: string }): string {
|
||||
function fmtTempValue(v?: {
|
||||
value: number;
|
||||
unit: string;
|
||||
note?: string;
|
||||
}): string {
|
||||
if (!v) return "?";
|
||||
return `${v.value}${v.unit}`;
|
||||
return `${v.value}${v.unit}${v.note ? ` (${v.note})` : ""}`;
|
||||
}
|
||||
|
||||
const TIMING_LABELS: Record<string, string> = {
|
||||
|
|
|
|||
28
packages/cli/tests/cook-temperatures.test.ts
Normal file
28
packages/cli/tests/cook-temperatures.test.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { describe, expect, it } from "bun:test";
|
||||
import { compile } from "@gram-lang/kitchen";
|
||||
import { getAST } from "@gram-lang/parser";
|
||||
import { getTempDisplay } from "../src/ui/cook/StepView";
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: reading a compiled step token.
|
||||
const temperatureOf = (step: string): any =>
|
||||
compile(getAST(`## A\n\n${step}\n`)).sections[0]?.steps[0]?.content.find(
|
||||
// biome-ignore lint/suspicious/noExplicitAny: reading a compiled step token.
|
||||
(c: any) => c?.type === "temperature",
|
||||
);
|
||||
|
||||
// `gram cook` shows a temperature the way the views do, with its note.
|
||||
describe("gram cook temperatures", () => {
|
||||
it("shows the value and unit like the views", () => {
|
||||
expect(getTempDisplay(temperatureOf("Bake at ^{180°C}."))).toBe("180 °C");
|
||||
});
|
||||
|
||||
it("shows a temperature in words", () => {
|
||||
expect(getTempDisplay(temperatureOf("Cook on ^{high}."))).toBe("high");
|
||||
});
|
||||
|
||||
it("shows the note after the value (1.5)", () => {
|
||||
expect(getTempDisplay(temperatureOf("Bake at ^{160°C}(fan)."))).toBe(
|
||||
"160 °C (fan)",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
@ -1085,6 +1085,33 @@ When the Gram compiler inspects a `^temperature` token:
|
|||
- If it starts with non-numeric text, it is treated as a **Semantic temperature** string.
|
||||
:::
|
||||
|
||||
## Cooking mode and notes
|
||||
*(since v1.5.0)*
|
||||
|
||||
A note in parentheses, right after the closing brace, says what goes with the temperature: the oven mode, where it is measured, how to cook. It works on exact and semantic temperatures, named or not, the way a preparation follows an ingredient.
|
||||
|
||||
```gram
|
||||
Preheat the #oven to ^{160°C}(fan).
|
||||
|
||||
Roast until the meat reaches ^{63°C}(internal).
|
||||
|
||||
Cook on ^stove{high heat}(uncovered) for ~{5min}.
|
||||
```
|
||||
|
||||
The note is always shown next to the temperature, on screen and on paper, since baking at 160 °C fan or conventional is not the same thing. It is words for the cook, in the recipe's language: Gram keeps it as written and never reads it.
|
||||
|
||||
:::caution[No space before the parenthesis]
|
||||
Only a parenthesis that touches the `}` is a note, and it ends on the same line. With a space, the parenthesis stays part of the sentence:
|
||||
|
||||
```gram
|
||||
Bake at ^{180°C}(fan).
|
||||
|
||||
Bake at ^{180°C} (the oven must be hot).
|
||||
```
|
||||
|
||||
The first temperature has the note `fan`; the second has none, and `(the oven must be hot)` is ordinary text.
|
||||
:::
|
||||
|
||||
## Error handling
|
||||
|
||||
Only Celsius and Fahrenheit temperature scales are supported. The compiler emits structured warnings when encountering malformed temperature values:
|
||||
|
|
@ -1540,6 +1567,7 @@ Specialized patterns for flexible culinary instructions:
|
|||
| **Passive timer** | `~_` | `~_{1h}` | Represents resting/rising time without blocking the cook. |
|
||||
| **Named timer** | `~name{...}` | `~eggs{3min}`, `~_oven{45min}` | Queues resource-constrained steps (named tracks). |
|
||||
| **Semantic temperature** | `^{text}` | `^{medium heat}`, `^{simmer}` | Expresses qualitative stove settings. |
|
||||
| **Temperature note** | `^{...}(note)` | `^{160°C}(fan)`, `^{63°C}(internal)` | Oven mode or condition, always shown; the parenthesis touches the brace. Since 1.5.0. |
|
||||
| **Fractions** | `n/d` or Unicode | `@flour{1 1/2 cups}`, `@sugar{½ cup}` | Fully supported across imperial and metric systems. |
|
||||
| **Sum of quantities** | `a + b`, `a - b` | `@flour{1 cup + 1 tbsp}`, `@sugar{1 cup - 2 tbsp}`, `@rice{1 cup + 20 g}` | Kept as written and added up; a volume and a weight stay side by side. Since 1.5.0. |
|
||||
|
||||
|
|
@ -1661,6 +1689,15 @@ Quantities and timers need a real number (or empty braces for "to taste"); fuzzy
|
|||
```
|
||||
Write an amount the recipe gives in several measures as a [sum](/docs/reference/syntax/ingredients/#sums-of-quantities), exactly as the source says it: "1 cup plus 1 tablespoon" is `{1 cup + 1 tbsp}`, "1 cup minus 2 tablespoons" is `{1 cup - 2 tbsp}`, and a volume next to a weight is fine (`{1 cup + 20 g}`). Don't work it out into one number either (`{1.0625 cup}`, `{17 tbsp}`): Gram adds the terms itself and shows them as the cook measures them. Every term needs its unit, and a term is only an amount: no percentage (`{100g + 10%}`), no multiplication (`{2 x 100g}`), no range after `-` (a range may be a term that is added: `{1 cup + 1-2 tbsp}`).
|
||||
|
||||
### The oven mode left in the prose
|
||||
*(since v1.5.0)*
|
||||
|
||||
```gram
|
||||
❌ Bake at ^{160°C} fan. → ✅ Bake at ^{160°C}(fan).
|
||||
❌ Bake at ^{180°C} (fan). → ✅ Bake at ^{180°C}(fan).
|
||||
```
|
||||
What goes with a temperature (the oven mode, "internal", "covered") belongs in a [note](/docs/reference/syntax/temperatures/#cooking-mode-and-notes) glued to the closing brace, in the recipe's language. With a space before it, the parenthesis is ordinary text and the note is lost.
|
||||
|
||||
### Using `@&` on the first occurrence
|
||||
|
||||
```gram
|
||||
|
|
|
|||
|
|
@ -79,6 +79,15 @@ Quantities and timers need a real number (or empty braces for "to taste"); fuzzy
|
|||
```
|
||||
Write an amount the recipe gives in several measures as a [sum](/docs/reference/syntax/ingredients/#sums-of-quantities), exactly as the source says it: "1 cup plus 1 tablespoon" is `{1 cup + 1 tbsp}`, "1 cup minus 2 tablespoons" is `{1 cup - 2 tbsp}`, and a volume next to a weight is fine (`{1 cup + 20 g}`). Don't work it out into one number either (`{1.0625 cup}`, `{17 tbsp}`): Gram adds the terms itself and shows them as the cook measures them. Every term needs its unit, and a term is only an amount: no percentage (`{100g + 10%}`), no multiplication (`{2 x 100g}`), no range after `-` (a range may be a term that is added: `{1 cup + 1-2 tbsp}`).
|
||||
|
||||
### The oven mode left in the prose
|
||||
<Since v="1.5.0" />
|
||||
|
||||
```gram
|
||||
❌ Bake at ^{160°C} fan. → ✅ Bake at ^{160°C}(fan).
|
||||
❌ Bake at ^{180°C} (fan). → ✅ Bake at ^{180°C}(fan).
|
||||
```
|
||||
What goes with a temperature (the oven mode, "internal", "covered") belongs in a [note](/docs/reference/syntax/temperatures/#cooking-mode-and-notes) glued to the closing brace, in the recipe's language. With a space before it, the parenthesis is ordinary text and the note is lost.
|
||||
|
||||
### Using `@&` on the first occurrence
|
||||
|
||||
```gram
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ Specialized patterns for flexible culinary instructions:
|
|||
| **Passive timer** | `~_` | `~_{1h}` | Represents resting/rising time without blocking the cook. |
|
||||
| **Named timer** | `~name{...}` | `~eggs{3min}`, `~_oven{45min}` | Queues resource-constrained steps (named tracks). |
|
||||
| **Semantic temperature** | `^{text}` | `^{medium heat}`, `^{simmer}` | Expresses qualitative stove settings. |
|
||||
| **Temperature note** | `^{...}(note)` | `^{160°C}(fan)`, `^{63°C}(internal)` | Oven mode or condition, always shown; the parenthesis touches the brace. Since 1.5.0. |
|
||||
| **Fractions** | `n/d` or Unicode | `@flour{1 1/2 cups}`, `@sugar{½ cup}` | Fully supported across imperial and metric systems. |
|
||||
| **Sum of quantities** | `a + b`, `a - b` | `@flour{1 cup + 1 tbsp}`, `@sugar{1 cup - 2 tbsp}`, `@rice{1 cup + 20 g}` | Kept as written and added up; a volume and a weight stay side by side. Since 1.5.0. |
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ description: "Define exact or semantic ^temperatures in Celsius or Fahrenheit, w
|
|||
---
|
||||
|
||||
import { CardGrid, LinkCard, Tabs, TabItem } from '@astrojs/starlight/components';
|
||||
import Since from '../../../../../components/Since.astro';
|
||||
|
||||
You can declare thermal instructions in your recipes using the `^` symbol.
|
||||
|
||||
|
|
@ -46,6 +47,33 @@ When the Gram compiler inspects a `^temperature` token:
|
|||
- If it starts with non-numeric text, it is treated as a **Semantic temperature** string.
|
||||
:::
|
||||
|
||||
## Cooking mode and notes
|
||||
<Since v="1.5.0" />
|
||||
|
||||
A note in parentheses, right after the closing brace, says what goes with the temperature: the oven mode, where it is measured, how to cook. It works on exact and semantic temperatures, named or not, the way a preparation follows an ingredient.
|
||||
|
||||
```gram
|
||||
Preheat the #oven to ^{160°C}(fan).
|
||||
|
||||
Roast until the meat reaches ^{63°C}(internal).
|
||||
|
||||
Cook on ^stove{high heat}(uncovered) for ~{5min}.
|
||||
```
|
||||
|
||||
The note is always shown next to the temperature, on screen and on paper, since baking at 160 °C fan or conventional is not the same thing. It is words for the cook, in the recipe's language: Gram keeps it as written and never reads it.
|
||||
|
||||
:::caution[No space before the parenthesis]
|
||||
Only a parenthesis that touches the `}` is a note, and it ends on the same line. With a space, the parenthesis stays part of the sentence:
|
||||
|
||||
```gram
|
||||
Bake at ^{180°C}(fan).
|
||||
|
||||
Bake at ^{180°C} (the oven must be hot).
|
||||
```
|
||||
|
||||
The first temperature has the note `fan`; the second has none, and `(the oven must be hot)` is ordinary text.
|
||||
:::
|
||||
|
||||
## Error handling
|
||||
|
||||
Only Celsius and Fahrenheit temperature scales are supported. The compiler emits structured warnings when encountering malformed temperature values:
|
||||
|
|
|
|||
|
|
@ -79,6 +79,15 @@ Les quantités et les minuteurs ont besoin d'un vrai nombre (ou d'accolades vide
|
|||
```
|
||||
Une quantité que la recette donne en plusieurs mesures s'écrit en [somme](/fr/docs/reference/syntax/ingredients/#sommes-de-quantités), telle que la source la formule : « 1 tasse plus 1 cuillère à soupe » donne `{1 cup + 1 tbsp}`, « 1 tasse moins 2 cuillères à soupe » donne `{1 cup - 2 tbsp}`, et un volume peut côtoyer une masse (`{1 cup + 20 g}`). Ne la convertissez pas non plus en un seul nombre (`{1.0625 cup}`, `{17 tbsp}`) : Gram additionne les termes lui-même et les affiche comme on les mesure. Chaque terme a son unité, et un terme n'est qu'une quantité : pas de pourcentage (`{100g + 10%}`), pas de multiplication (`{2 x 100g}`), pas de fourchette après un `-` (une fourchette peut être un terme ajouté : `{1 cup + 1-2 tbsp}`).
|
||||
|
||||
### Le mode du four laissé dans la phrase
|
||||
<Since v="1.5.0" />
|
||||
|
||||
```gram
|
||||
❌ Cuire à ^{160°C} chaleur tournante. → ✅ Cuire à ^{160°C}(chaleur tournante).
|
||||
❌ Cuire à ^{180°C} (chaleur tournante). → ✅ Cuire à ^{180°C}(chaleur tournante).
|
||||
```
|
||||
Ce qui accompagne une température (le mode du four, « à cœur », « à couvert ») va dans une [précision](/fr/docs/reference/syntax/temperatures/#mode-de-cuisson-et-précisions) collée à l'accolade fermante, dans la langue de la recette. Avec un espace devant, la parenthèse reste du texte et la précision est perdue.
|
||||
|
||||
### Utiliser `@&` dès la première occurrence
|
||||
|
||||
```gram
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ Formulations complémentaires pour enrichir la description des étapes :
|
|||
| **Minuteur passif** | `~_` | `~_{1h}` | Modélise un repos ou une pousse sans monopoliser le cuisinier. |
|
||||
| **Minuteur nommé** | `~nom{...}` | `~œufs{3min}`, `~_four{45min}` | Linéarise l'accès à un équipement partagé (piste dédiée). |
|
||||
| **Température sémantique** | `^{texte}` | `^{feu moyen}`, `^{frémissement}` | Exprime une intensité de chauffe qualitative. |
|
||||
| **Précision de température** | `^{...}(précision)` | `^{160°C}(chaleur tournante)`, `^{63°C}(à cœur)` | Mode du four ou condition, toujours affichée ; la parenthèse est collée à l'accolade. Depuis la 1.5.0. |
|
||||
| **Fractions** | `n/d` ou Unicode | `@farine{1 1/2 tasse}`, `@sucre{½ tasse}` | Prises en charge complètes en système métrique comme impérial. |
|
||||
| **Somme de quantités** | `a + b`, `a - b` | `@farine{1 kg + 200 g}`, `@lait{1 l - 10 cl}`, `@riz{1 tasse + 20 g}` | Gardée telle qu'écrite et additionnée ; un volume et une masse restent côte à côte. Depuis la 1.5.0. |
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ description: "Définissez des ^températures exactes ou sémantiques en Celsius
|
|||
---
|
||||
|
||||
import { CardGrid, LinkCard, Tabs, TabItem } from '@astrojs/starlight/components';
|
||||
import Since from '../../../../../../components/Since.astro';
|
||||
|
||||
Les consignes thermiques de cuisson se déclarent au sein des étapes de recette à l'aide du symbole `^`.
|
||||
|
||||
|
|
@ -46,6 +47,33 @@ Lorsque le compilateur Gram traite un élément `^température` :
|
|||
- S'il commence par une lettre ou un mot, l'ensemble du contenu est traité comme une **température sémantique**.
|
||||
:::
|
||||
|
||||
## Mode de cuisson et précisions
|
||||
<Since v="1.5.0" />
|
||||
|
||||
Une précision entre parenthèses, collée à l'accolade fermante, accompagne la température : le mode du four, l'endroit où on la mesure, la façon de cuire. Elle s'écrit sur les températures exactes comme sémantiques, nommées ou non, comme la préparation d'un ingrédient.
|
||||
|
||||
```gram
|
||||
Préchauffer le #four à ^{160°C}(chaleur tournante).
|
||||
|
||||
Rôtir jusqu'à ^{63°C}(à cœur).
|
||||
|
||||
Faire revenir sur ^plaque{feu vif}(à découvert) pendant ~{5min}.
|
||||
```
|
||||
|
||||
La précision s'affiche toujours à côté de la température, à l'écran comme sur papier : cuire à 160 °C en chaleur tournante ou en statique, ce n'est pas la même chose. C'est un mot pour le cuisinier, dans la langue de la recette : Gram la garde telle quelle et ne l'interprète jamais.
|
||||
|
||||
:::caution[Pas d'espace avant la parenthèse]
|
||||
Seule une parenthèse collée à la `}` est une précision, et elle se termine sur la même ligne. Avec un espace, la parenthèse reste dans la phrase :
|
||||
|
||||
```gram
|
||||
Cuire à ^{180°C}(chaleur tournante).
|
||||
|
||||
Cuire à ^{180°C} (le four doit être bien chaud).
|
||||
```
|
||||
|
||||
La première température porte la précision `chaleur tournante` ; la seconde n'en a pas, et `(le four doit être bien chaud)` reste du texte.
|
||||
:::
|
||||
|
||||
## Gestion des erreurs
|
||||
|
||||
Seules les échelles Celsius et Fahrenheit sont prises en charge. Le compilateur émet des avertissements structurés en présence de formats inattendus :
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue