Skip to content

Bold, italic and links in recipe notes (spec 0022) #863

Backlog

Description

@dubadub

What

Support inline formatting in recipe notes: bold, italic and links, as defined by spec proposal 0022 (accepted). Show them in the web UI and cooking mode, and write them in every output format.

> **Make ahead:** the dough keeps *up to 3 days* in the fridge.
> See the [shaping guide](https://example.com/shaping), or [Spinach pie](<./Spinach pie.cook>).

Why

Notes are the prose part of a recipe, and people already type Markdown in them (**Gluten-free option:** …). Today the asterisks show as written, and a note can only link a bare URL (through link_urls). The parser now reads the formatting, so CookCLI needs no Markdown library.

Depends on

  • feat!: inline formatting in notes (spec proposal 0022) cooklang-rs#170, which isn't released yet. cooklang::Content::Text changes from String to Note { items: Vec<TextRun> }, with TextRun { value, strong, emphasis, link: Option<String> }. note.text() (or Display) gives the plain text.
  • A cooklang-reports release for the same cooklang version. It matches cooklang::Content::Text(value) => Self::Text(value) (model/content.rs:37, and in item.rs and step.rs), and CookCLI calls it from crates/core/src/report.rs:41. cooklang-language-server depends on cooklang too.

What breaks on the upgrade (compile errors)

  • src/web/builders.rs:791-795: text.trim() → RecipeSectionItem::Note(String)
  • crates/format/src/human.rs:507-532
  • crates/format/src/cooklang_source.rs:138 (w_text_block(w, &str)) and the test helper at :516
  • crates/format/src/markdown.rs:449-457, latex.rs:381-385, typst.rs:353-357

src/server/handlers/recipe_image.rs:273 and crates/format/src/schema.rs:425 skip notes and need no change.

Behaviour

Web UI (templates/recipe.html:429-433, RecipeSectionItem::Note at src/web/templates.rs:1064)

  • RecipeSectionItem::Note carries the runs, not a string. Render strong as <strong>, emphasis as <em>, and consecutive runs with the same link as one <a>. Escape every value and destination, as link_urls does today.
  • .recipe-note is italic (static/css/components.css:612-621), so emphasis must still show, for example by switching back to upright text.
  • Links, following the proposal's Opening links:
    • http:, https: and mailto: become <a target="_blank" rel="noopener noreferrer">.
    • A destination with no scheme that doesn't start with // is percent-decoded and resolved like a recipe reference. If it names a recipe in the collection (with or without .cook), it links to that recipe's page. A path that leaves the collection (../, absolute) or doesn't resolve shows its text only.
    • Anything else (javascript:, data:, file:, //host, empty) shows its text only.
  • Keep link_urls auto-linking bare URLs in the plain runs (the proposal allows it), but not inside a run that is already a link.

Cooking mode (templates.rs:506-509 emits {"type":"note","text": …}; static/js/cooking-mode.js:79-91, 130-150 noteHTML())

cook recipe -f … (src/recipe/read.rs:209-259)

  • json / yaml: no code change. The recipe is serialized with serde, and cooklang-rs#170 keeps {"type":"text","value":"<plain text>"} and adds "items": [...]. Add a test that pins this shape.
  • human: bold and italic where the terminal supports them; a link prints as its text followed by the destination in parentheses.
  • markdown: write **, * and [text](destination) yourself. escape_md_line (markdown.rs:577-604) escapes exactly these characters, so escape each run's value and then wrap it.
  • latex / typst: \textbf/\textit/\href, and *…*/_…_/#link. In typst the note is already inside _Note: …_, so nested emphasis needs care. The snapshots at tests/snapshots/document_formats_test__latex_output.snap:84 and typst_output.snap:58 will change.
  • cooklang (w_text_block, cooklang_source.rs:229-243): write the runs back as **, * and [text](<destination>) (angle brackets when the destination has a space). Escape with \ any literal *, _, [, ] and \ in a value that would otherwise be read as formatting. No such helper exists yet (cooklang's escape_text is private and covers other characters). Keep a link's text from wrapping across > lines, using the component_word_separator pattern at :245-298.

API docs

  • /api/recipes/{path} returns items with no change, since ApiRecipe flattens the cooklang Recipe. Document a text block in src/web/api_docs.rs (today it only shows a step) and regenerate docs/api.md.

To decide

  • Whether a note link to a recipe that doesn't resolve shows as text (the proposal's rule) or as a link that 404s. The proposal says text.
  • What a path is relative to: the recipe's folder or the collection root. The iOS and Android apps resolve recipe references from the collection root. Pick the same rule as the server's recipe references, and keep the three apps consistent.

Acceptance

  • The note above renders with "Make ahead:" bold, "up to 3 days" italic, the shaping guide as an external link and "Spinach pie" linking to its recipe page, both on the recipe page and in cooking mode.
  • > [x](javascript:alert(1)) and > [x](../../etc/passwd) render the text "x" with no link.
  • cook recipe -f cooklang on a note with formatting, escaped asterisks (2\*250 g) and a link with spaces gives a file that parses to the same runs (round-trip test).
  • cook recipe -f json includes "value" (plain) and "items" for each note.

Activity

  1. added
    area: server
    area: cli
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cliarea: serverfeature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions