Skip to content

Show exact fractions (5/8, 1 5/8) the same way in the terminal and the web UI #672

Closed

Description

@LeMyst

Follow-up to #432. Since #433, quantities are no longer rounded to a different fraction or converted to another unit: @milk{1 5/8%cup} stays 1.625 cup. What is left from that report is showing exact fractions, the way they are measured in a kitchen, and showing them the same way everywhere.

Today (upstream main)

@milk{1 5/8%cup} and @cocoa{5/8%cup} and @sugar{3/4%cup}.
Quantity cook recipe Web UI
5/8 cup 0.625 cup 5/8 cup
3/4 cup 0.75 cup 3/4 cup
1 5/8 cup 1.625 cup 1.625 cup
  • The web UI (format_number in crates/format/src/number.rs) shows halves, thirds, quarters and eighths as fractions only below 1; above 1 it falls back to a decimal on purpose (decimal_to_fraction returns None when there is a whole part).
  • The terminal (crates/format/src/human.rs) prints cooklang's own Display of the quantity, which is always a decimal.

Proposal

  • Show a mixed fraction when the value is exactly one: 1 5/8, 2 1/3. Otherwise keep the decimal; never show an approximated fraction as if it were exact (the original Inconsistent quantity display: lossy fraction approximation (1 5/8 cup shown as 1 2/3 c) and no control over unit conversion #432 bug).
  • Use the same formatter in every human-readable output — terminal, web UI, Markdown — so a recipe shows the same numbers everywhere.
  • Open question: whether this is the default or opt-in (a preference in the web UI and a flag or config entry for the CLI). Scaling makes it matter: a recipe scaled ×1.5 gives 2 7/16, which should probably stay 2.438.
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