Instructions and Examples on Syntax of Cooklang
Additional notes about the recip
π₯ Ingredients
- milk 4* cup
- salt
- ground black pepper
- potato 2*
- bacon strips 1* kg
- syrup 1/2* tbsp
- onion 1*
- garlic 2* cloves
- fireeggs 2-4*
- ominous sauce 200-300* ml
- water 1.5-2* l
- darkflour 100* g
- &darkflour 200-400* g
- cream 1/2* cup
- liquid 1|2|3 cup
- eggs 2*
- tomato sauce 200 ml
- flour 200* g
- &flour 300* g
- brownflour 200* g
- &(2)thing
- &(=2)thing
- white wine|wine
- shomato sauce|shauce
- tipo zero flour
- &tipo zero flour|tzflour
π³ Cookware
- pot
- potato masher
- baking sheet
- oven
- oven
A section is defined by placing a = at the beginning of a line.
If the = is followed by words, they become the section title as shown in the next section.
cooking steps
Each paragraph in a recipe file is a cooking step. Cooking steps are separated with an empty line.
-
1A step, the same step.
-
2A different step.
-
3A multiline step using \ to insert newlines as such: substep 3.1 substep 3.2 substep 3.3
annotations
This line is NOT a cooking step because it begins with a >. This is an annotation.
Annotations can be broken into multiple lines by placing a \ at the end of a line as such for example
comments
A comment is defined as text which begins with two dashes '--'. The next line will be a comment. If this text is rendered, then the comment will not be visible:
BEGIN COMMENT
END COMMENT
A block comment is defined as text which begins with '[-' and ends with '-]'. If the following text is rendered, the text between the curly braces will not be visible:
-
1Slowly add milk {}, keep mixing
ingredients
To define an ingredient, use the @ symbol. If the ingredientβs name contains multiple words, indicate the end of the name with {}.
To indicate the quantity of an item, place the quantity inside {} after the name.
To use a unit of an item, such as weight or volume, add a % between the quantity and unit.
Many recipes involve repetitive ingredient preparations, such as peeling or chopping. To simplify this, you can define these common preparations directly within the ingredient reference using shorthand syntax:
These preparations will be clearly displayed in the ingredient list, allowing you to get everything ready before you start cooking.
Recipes are not always exact. This is a little improvement that should help comunicating that in some cases.
###SCALABILITY
Can automatically scale ingredient quantities with *. This will multiply the quantity given by the number of servings selected.
Alternatively, you can manually specify ingredient quantities for each serving size. This is useful for non-linear scaling.
-
1Then add salt and ground black pepper to taste.
-
2Poke holes in potato .
-
3Place bacon strips on a baking sheet and glaze with syrup .
-
4Mix onion and garlic into paste.
-
5fireeggs
-
6ominous sauce -- works with units
-
7water -- with decimal numbers too
-
8darkflour ... &darkflour -- the total will be 300-500 g
-
9Add cream and mix until smooth.
-
10Add liquid and mix until smooth.
cookware
-
1You can define any necessary cookware with #. Like ingredients, you donβt need to use braces if itβs a single word.
-
2Place the potatoes into a pot . Mash the potatoes with a potato masher .
timer
You can define a timer using ~.
Timers can have a name too:
Applications can use this name in notifications.
-
1Lay the potatoes on a baking sheet and place into the oven . Bake for 25 minutes .
-
2Boil eggs for 3 minutes .
shopping lists
To support the creation of shopping lists by apps and the command line tool, Cooklang includes a specification for a configuration file to define how ingredients should be grouped on the final shopping list. You can use [] to define a category name. These names are arbitrary, so you can customize them to meet your needs. For example, each category could be an aisle or section of the store, such as [produce] and [deli].
[produce] potatoes [dairy] milk butter
Or, you might be going to multiple stores, in which case you might use [Tesco] and [Costco].
[Costco] potatoes milk butter
[Tesco] bread salt
You can also define synonyms with |.
[produce] potatoes
[dairy] milk butter
[deli] chicken
[canned goods] tuna|chicken of the sea
pictures
You can add images to your recipe by including a supported image file (.png,.jpg) matching the name of the recipe recipe in the same directory.
./baked_potato.cook ./baked_potato.jpg
You can also add images for specific steps by including a step number before the file extension.
./chicken.cook ./chicken.0.jpg ./chicken.3.jpg
metadata
If this page is rendered, metadata should appear at the top before the ingredients section.
Recipes are more than just steps and ingredientsβthey also include context, such as preparation times, authorship, and dietary relevance. You can add metadata to your recipe using YAML front matter, add --- at the beginning of a file and --- at the end of the front matter block.
Here's the metadata used for this recipe file:
--- title: Instructions and Examples on Syntax of Cooklang description: Additional notes about the recip source: https://example.org/recipe author: mama yield: 2,15 cups worth course: dinner duration: 1h30m time.prep: 2h30m time.cook: 0h10m difficulty: easy cuisine: mexican diet: halal image: https://example.org/recipe_image.jpg locale: en_CA tags: - template - instructions - syntax - example ---
modifiers
With the ingredient modifiers you can alter the behaviour of ingredients. There are 5 modifiers:
- @ **Recipe**. References another recipe by it's name.
- `&` **Reference**. References another ingredient with the same name. If a quantity is given, the amount can be added. The ingredient must be defined before. If there are multiple definitions, use the last one.
- `-` **Hidden**. Hidden in the list, only appears inline.
- `?` **Optional**. Mark the ingredient as optional.
- `+` **New**. Forces to create a new ingredient. This works with the [modes](#modes) extension.
This also works (except recipe) for cookware.
-
1Add @ tomato sauce .
-
2Add flour [...], then add more &flour .
-
3Add some @-secretspice.
-
4Now you can add @?thyme.
intermediate preparations
You can refer to intermediate preparations as ingredients. For example:
Here, dough is refering to whatever was prepared one step back. These ingredients will not appear in the list.
There are more syntax variations:
Only past steps from the current section can be referenced. It can only be combined with the optional (?) modifier. Text steps can't be referenced. In relative references, text steps are ignored. Enabling this extension automatically enables the modifiers extension.
-
1Add brownflour and @&water. Mix until combined.
-
2Let the @&( timer rest for 1 hour .
-
3@&( timer
-
4&(2)thing
-
5&(=2)thing
-
6@&(= timer
aliases
Add an alias to an ingredient to display a different name.
This can be useful with references. Here, the references will be displayed as flour even though the ingredient it's refering is tipo zero flour.
This also works for cookware.
-
1white wine|wine
-
2@ shomato sauce|shauce -- works with modifiers too
-
3Add the tipo zero flour
-
4Add more &tipo zero flour|tzflour
modes
Add new special metadata keys that control some of the other extensions. The special keys are between square brackets.
>> [special key]: value
[mode] | [define] all | default. This is the default mode, same as the original cooklang. ingredients | components. In this mode only components can be defined, all regular text is omitted. Useful for writing an ingredient list manually at the beginning of the recipe if you want to do so. steps. All the ingredients are references. To force a new ingredient, use the new (+) modifier. text. All steps are text blocks
duplicate new | default. When a ingredient with the same name is found, create a new one. This is the original cooklang behaviour. reference | ref. Ingredients have implicit references when needed. So ingredients with the same name will be references. To force a new ingredient, use the new (+) modifier. >> [duplicate]: ref @water{1} @water{2} -- is the same as >> [duplicate]: default @water{1} @&water{2}
temperature
Find temperatures in the text, without any markers. In the future this may be extended to any unit.
For example, the temperature here will be parsed not as text, but as an inline quantity.
-
1Preheat the oven to 180 ΒΊC.