syntax

Instructions and Examples on Syntax of Cooklang

Additional notes about the recip

#template #instructions #syntax #example

πŸ₯˜ 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.

  1. 1
    A step, the same step.
  2. 2
    A different step.
  3. 3
    A 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:

  1. 1
    Slowly 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.

  1. 1
    Then add salt and ground black pepper to taste.
  2. 2
    Poke holes in potato .
  3. 3
    Place bacon strips on a baking sheet and glaze with syrup .
  4. 4
    Mix onion and garlic into paste.
  5. 5
    fireeggs
  6. 6
    ominous sauce -- works with units
  7. 7
    water -- with decimal numbers too
  8. 8
    darkflour ... &darkflour -- the total will be 300-500 g
  9. 9
    Add cream and mix until smooth.
  10. 10
    Add liquid and mix until smooth.

cookware

  1. 1
    You can define any necessary cookware with #. Like ingredients, you don’t need to use braces if it’s a single word.
  2. 2
    Place 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.

  1. 1
    Lay the potatoes on a baking sheet and place into the oven . Bake for 25 minutes .
  2. 2
    Boil 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.

  1. 1
    Add @ tomato sauce .
  2. 2
    Add flour [...], then add more &flour .
  3. 3
    Add some @-secretspice.
  4. 4
    Now 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.

  1. 1
    Add brownflour and @&water. Mix until combined.
  2. 2
    Let the @&( timer rest for 1 hour .
  3. 3
    @&( timer
  4. 4
    &(2)thing
  5. 5
    &(=2)thing
  6. 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.

  1. 1
    white wine|wine
  2. 2
    @ shomato sauce|shauce -- works with modifiers too
  3. 3
    Add the tipo zero flour
  4. 4
    Add 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.

  1. 1
    Preheat the oven to 180 ΒΊC.

Actions

πŸ“₯ Download .cook File πŸ”— View Original