SelfscribeDownloadOpen the app

Recipe

Recipes with fact chips, a tidy column of quantities and timer pills, from lines a cook would type anyway.

A rulebook. Save it in the app's library, then start any document with use recipe.

Edit it in the playgroundRead the file

What it shows

Add a cook's marks to Markdown: fact chips, quantities and timers.

What you learn

Borrowing Markdown and replacing its "- " rule, a line split into chips, ingredient lines gathered into a card, a grid for each line, two bracket marks of different lengths, a labelled tip line.

Try this

  • Change the [400 g] of tomatoes to [800 g], and the quantity column stays lined up.
examples/rulebooks/recipe.self · 86 lines
~~~ selfscribe
# Recipe: quantities, timers and steps for cooks. Use it with:  use recipe
# Lesson: Add a cook's marks to Markdown: fact chips, quantities and timers.
# You learn: borrowing Markdown and replacing its "- " rule, a line split into chips, ingredient lines gathered into a card, a grid for each line, two bracket marks of different lengths, a labelled tip line.
# Try this: change the [400 g] of tomatoes to [800 g], and the quantity column stays lined up.
# summary: Recipes with fact chips, a tidy column of quantities and timer pills, from lines a cook would type anyway.
# category: syntax
set title Recipe

# ---- Markdown for headings, numbered steps and the rest -------------------------------
use markdown

# ---- Colours, each with its shade for dark pages -------------------------------------
palette
  warm   #c2410c  dark #ff8a4c
  timer  #0b7f86  dark #3bc9db
  honey  #e8a100  dark #ffd43b

# ---- "= Dish" on its own line: the recipe's title --------------------------------------
line   = _           -> div.dish        { font: 650 2.3em/1.08 var(--doc-font-heading, var(--doc-font, Georgia, serif)); letter-spacing: -0.02em; margin: 0.1em 0 0.35em }  as rc-dish

# ---- "facts 30 min | Serves 2": a row of chips, one for each part between the | marks ---
line   facts _       -> div.facts       split "|" span.rc-fact  { display: flex; flex-wrap: wrap; gap: 0.45em; margin: 0 0 1.6em }  as rc-facts
class rc-fact  { font: 600 0.78em/1 var(--doc-font-ui); padding: 0.55em 0.9em; border-radius: 999px; background: color-mix(in srgb, var(--warm) 12%, transparent) }

# ---- "- [400 g] chopped tomatoes": an ingredient, its quantity in a column of its own ----
# This replaces Markdown's "- " list item, so every "- " line here is an ingredient, and
# neighbouring ones gather into one card of two columns.
class rc-list  { columns: 2 15em; column-gap: 2em; margin: 0 0 1.4em; padding: 0.5em 1.2em; border-radius: 14px; background: color-mix(in srgb, var(--warm) 6%, transparent) }
line   - _           -> div.ingredient  group div.rc-list  { display: grid; grid-template-columns: 5.4em 1fr; align-items: baseline; padding: 0.4em 0; border-bottom: 1px solid color-mix(in srgb, currentColor 9%, transparent); break-inside: avoid }  as rc-ingredient
inline [_]           -> b.qty           { font: 650 0.88em var(--doc-font-ui); color: var(--warm) }  as rc-qty

# ---- [[12 min]] in a step: a timer pill ------------------------------------------------
# Two brackets are a longer pattern than one, so a timer is never read as a quantity.
inline [[_]]         -> span.timer      { font: 600 0.78em/1 var(--doc-font-ui); padding: 0.28em 0.65em; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--timer) 50%, transparent); color: var(--timer); white-space: nowrap }  as rc-timer

# ---- "Tip: …" at the start of a line: a honey-coloured box ------------------------------
line   Tip: _        -> div.tip         keep { margin-top: 0.8em; padding: 0.75em 1.1em; border-radius: 12px; background: color-mix(in srgb, var(--honey) 14%, transparent) }  as rc-tip
~~~
= Shakshuka with feta
*Eggs baked in a spiced tomato and pepper sauce, all in one pan.*

facts ⏱ 30 min | 🍽 Serves 2 | 🌶 Mildly spicy | 🍳 One pan

## You need

- [2 tbsp] olive oil
- [1] onion, sliced
- [1] red pepper, sliced
- [2 cloves] garlic, crushed
- [1 tsp] ground cumin
- [1 tsp] smoked paprika
- [½ tsp] chilli flakes
- [400 g] chopped tomatoes
- [4] eggs
- [60 g] feta
- [1 handful] coriander
- [4 slices] crusty bread

## Method

1. Warm the oil in a wide frying pan over a medium heat. Add the onion and pepper, and cook until soft, [[8 min]].
2. Stir in the garlic, cumin, paprika and chilli. Cook until they smell toasty, [[1 min]].
3. Add the tomatoes and a pinch of salt, and simmer until thick, [[10 min]].
4. Make four hollows with a spoon and crack an egg into each. Cover, and cook until the whites are set, [[6 min]].
5. Crumble the feta over, scatter the coriander, and take the pan to the table with the bread.

Tip: For runny yolks, take the pan off the heat while the whites still wobble a little. They finish cooking on the way to the table.

Tip: No feta? A spoon of thick yoghurt on each plate does the same job.

## How it's made

* The dish name, the chips and the ingredient lines are rules of this rulebook. Everything else is Markdown.
* A quantity sits in single square brackets and a timer in double ones, so the cook sees each at a glance. The longer pattern wins, so a timer is never read as a quantity.
* Each `- ` line is an ingredient. Its rule draws a grid, quantity on the left, and gathers the lines next to each other into one card.
* `facts` and the parts between `|` marks make the row of chips under the title.

## Try it yourself

1. Change `400 g` to `800 g` and `Serves 2` to `Serves 4`. The chip and the quantity follow, and the column stays lined up.
2. Add a line `- [1 pinch] salt` under the chilli flakes. It joins the card.
3. Write `[[2 min]]` in step 5. A timer pill appears.
4. Change `warm` in the palette to `#2f9e44`. The quantities and chips turn green.

**Next:** *Recipe card* in the examples is a whole recipe page; *How Selfscribe works* shows every kind of rule.