SelfscribeDownloadOpen the app

Recipe card

Ingredients beside the method, with quantities and timers picked out of what you would type anyway.

Document · Simple · uses markup

Edit it in the playgroundRead the file

What it shows

Write a recipe card with marks a cook would type anyway.

What you learn

Blocks inside blocks for a two-column card, a line split into pills, a mark for quantities, a mark for timers, numbered steps drawn with a counter, a tip box.

Try this

  • Change warm in the palette to #6741d9, and the band, the quantities, the step numbers and the pills turn purple.
  • Add a line - [1 tsp] vanilla extract under the milk, and a new ruled line appears with its amount in colour.
examples/recipe.self · 105 lines
~~~ selfscribe
# Lesson: Write a recipe card with marks a cook would type anyway.
# You learn: blocks inside blocks for a two-column card, a line split into pills, a mark for quantities, a mark for timers, numbered steps drawn with a counter, a tip box.
# Try this: change `warm` in the palette to #6741d9, and the band, the quantities, the step numbers and the pills turn purple.
# Try this: add a line `- [1 tsp] vanilla extract` under the milk, and a new ruled line appears with its amount in colour.
# summary: Ingredients beside the method, with quantities and timers picked out of what you would type anyway.
# category: writing
# tags: document, simple, home
# uses: markup
use markdown
set title Recipe card

# ---- Colours, each with its shade for dark pages -------------------------------------------
palette
  warm   #c2410c  dark #ff8a4c
  timer  #0c7c7b  dark #3cc7c6
  honey  #f59f00
  line   color-mix(in srgb, currentColor 10%, transparent)

# ---- The card, with ingredients and method side by side ------------------------------------
# Blocks inside blocks need different fences (+++, ::::, :::), so each closing line is clear.
block  +++ card ... +++       -> article.card    { max-width: 46em; margin: 0.5em auto; padding: 2.1em 2.3em 1.5em; border-radius: 18px; border: 1px solid var(--line); background: color-mix(in srgb, var(--warm) 3%, transparent); box-shadow: 0 14px 34px -20px color-mix(in srgb, var(--warm) 55%, transparent); overflow: hidden }  as rc-card
# A band across the top of the card, in the two warm colours.
class  card::before  { content: ""; display: block; height: 7px; margin: -2.1em -2.3em 1.9em; background: linear-gradient(90deg, var(--warm), var(--honey)) }
block  :::: columns ... ::::  -> div.columns     { display: flex; flex-wrap: wrap; gap: 1.4em 2.2em; margin-top: 1.6em; padding-top: 1.5em; border-top: 1px solid var(--line) }  as rc-columns
block  ::: side ... :::       -> div.side        { flex: 1 1 13em; font-size: 0.92em }  as rc-side
block  ::: main ... :::       -> div.main        { flex: 2.3 1 19em }  as rc-main

# ---- The header: "kicker …", "= Dish", "> a line about it", "facts a | b | c" --------------
line   kicker _       -> div.kicker     { font: 700 0.72em/1 var(--doc-font-ui); letter-spacing: 0.18em; text-transform: uppercase; color: var(--warm) }  as rc-kicker
line   = _            -> div.dish       { margin: 0.3em 0 0.35em; font: 600 2.5em/1.05 var(--doc-font, Georgia, serif); letter-spacing: -0.02em }  as rc-dish
line   > _            -> div.blurb      { max-width: 34em; font-style: italic; line-height: 1.5; opacity: 0.78 }  as rc-blurb
# split cuts the facts line at each bar, and the class styles each piece as a pill.
line   facts _        -> div.facts      split "|" span.rc-fact  { display: flex; flex-wrap: wrap; gap: 0.5em; margin-top: 1.3em }  as rc-facts
class  rc-fact  { padding: 0.55em 0.95em; border-radius: 999px; background: color-mix(in srgb, var(--warm) 11%, transparent); font: 600 0.78em/1 var(--doc-font-ui) }

# ---- Labels and ingredients ---------------------------------------------------------------
line   ## _           -> div.label      { margin: 0 0 0.8em; font: 700 0.72em/1 var(--doc-font-ui); letter-spacing: 0.16em; text-transform: uppercase; opacity: 0.6 }  as rc-label
# "- [120 g] butter": a ruled line, with the amount in square brackets set in colour.
line   - _            -> div.ingredient { display: grid; grid-template-columns: 4.2em 1fr; align-items: baseline; padding: 0.45em 0; border-bottom: 1px solid var(--line) }  as rc-ingredient
inline [_]            -> b.qty          { font: 600 0.88em var(--doc-font-ui); color: var(--warm) }  as rc-qty

# ---- "1. Melt …": a numbered step, its number drawn in a disc ------------------------------
# _# matches the number, and group gathers the steps in one list that counts them.
line   _#. _          -> li.rc-step     group ol.rc-steps  { position: relative; padding: 0.1em 0 0.75em 2.5em }  as rc-step
class  rc-steps  { margin: 0; padding: 0; list-style: none; counter-reset: step }
class  rc-step::before  { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0.1em; width: 1.75em; height: 1.75em; border-radius: 50%; background: var(--warm); color: var(--on-warm); font: 700 0.8em/1.75em var(--doc-font-ui); text-align: center }
# "[[5 min]]" in a step: a timer pill.
inline [[_]]          -> span.timer     { padding: 0.25em 0.6em; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--timer) 50%, transparent); color: var(--timer); font: 600 0.78em/1 var(--doc-font-ui); white-space: nowrap }  as rc-timer

# ---- "::: tip … :::" with "Tip:" at its start: the cook's tip ------------------------------
block  ::: tip ... :::        -> aside.tip       { margin-top: 1.1em; padding: 0.9em 1.1em 0.1em; border-radius: 12px; background: color-mix(in srgb, var(--honey) 13%, transparent) }  as rc-tip
word   Tip:           -> strong.tip-head { color: var(--warm) }  as rc-tip-head
~~~
+++ card
kicker Autumn baking · Serves 8
= Brown butter pear cake
> A soft, nutty sponge with pears sunk into the top. Better on the second day, if it lasts that long.
facts ⏱ 20 min prep | 🔥 45 min bake | 🍐 3 ripe pears | 🌡 180 °C, fan 160 °C

:::: columns
::: side
## Ingredients
- [120 g] butter
- [150 g] light brown sugar
- [3] eggs, at room temperature
- [180 g] plain flour
- [1½ tsp] baking powder
- [½ tsp] ground cardamom
- [80 ml] whole milk
- [3] ripe pears, halved and cored
- [2 tbsp] demerara sugar
:::
::: main
## Method
1. Melt the butter in a light pan and keep it moving until it smells of toasted nuts and flecks of brown appear [[5 min]]. Tip it into a bowl and let it cool a little.
2. Heat the oven to 180 °C and line a 23 cm tin with baking paper.
3. Whisk the sugar and eggs until pale and thick [[3 min]], then pour in the brown butter in a thin stream.
4. Fold in the flour, baking powder and cardamom, then the milk, until just combined.
5. Scrape into the tin, press the pear halves in cut side down, and scatter over the demerara.
6. Bake until golden and a skewer comes out clean [[45 min]]. Cool in the tin [[15 min]].
:::
::::

::: tip
Tip: Pears that are still slightly firm keep their shape; very ripe ones melt into the sponge. Both are good. The cake keeps for three days in a tin.
:::
+++

## How it's made

Nothing on this card is built in. Each ingredient is a line that starts with a dash, `- [120 g] butter`, and the amount in square brackets is set in colour on the left.

Each step starts with its number, `1. Melt …`, and a counter draws it in a disc. A time in double square brackets, `[[5 min]]`, becomes a timer pill.

The two columns are a `:::: columns` block holding a `::: side` and a `::: main`, all inside the `+++ card` block. The band across the top is the card's `::before`, in a gradient of two palette colours.

## Try it yourself

1. Add a line `- [1 tsp] vanilla extract` under the milk. A new ruled line appears, with its amount in orange.
2. Add a timer to step 5 by writing `[[2 min]]` after "demerara". A teal pill appears in the step.
3. Add `| 🥄 one bowl` at the end of the facts line. A fifth pill appears under the title.
4. Delete the line `:::: columns` and the line `::::` under the method. Ingredients and method stack one above the other.

Next: *Travel journal* makes a card for each day of a trip; *Group chat* turns a chat into bubbles.