tstehr / RecipeMD

Markdown recipe format and cli tool
https://recipemd.org
GNU Lesser General Public License v3.0
53 stars 7 forks source link

Approximate amount specifier #48

Open tstehr opened 1 year ago

tstehr commented 1 year ago

In #38 a did a survey of recipes that will be considered invalid once we fix the incorrect treatment of amounts without factors. On thing that came out of that is users like to mark amounts as approximate, in particular for the yield amount of a recipe.

Of the 43 recipes that had an error, 12 were instances of approximate yields. Additionally there was one recipe using an approximate ingredient amount.

Use cases

The survey turned up 3 use cases:

  1. indicate that a yield is using an inexact unit (mostly servings, where a serving size can vary wildly), see also "Lerngruppz" for a related approach
  2. for yields of a certain number of pieces (e.g. cookies or muffins), indicate that it's normal if you don't exactly reach that number
  3. recipes where you add an ingredient as needed (e.g. add flour until a certain consistency is reached)

I've also wanted a syntax like this in my own use from time to time, mostly for uses cases 2 and 3.

Syntax and spec ideas

For syntax 9 recipes used ~ as a prefix for the amount (~3 Portionen) the remaining 4 used ca/ca.. I'd also prefer using ~ independently of existing use as it is not language specific.

For the spec right now my idea is to allow an optional ~ prefix for amounts in yields and ingredients. This translates into a boolean approximate flag added to the amount data type. The semantics of that flag would be "The recipe author has indicated that the amount is approximate". If a more detailed explanation of what that entails is required authors need to put that in the instructions.

tstehr commented 1 year ago

@AberDerBart and I checked the case of multiple approximate yields (commonmark dingus, babelmark). It produces good markdown output in commonmark implementations

blabug commented 1 year ago

for compability/customization purposes we could also allow just an arbitrary Prefix and only require that exactly one number is contained in the amout. This would allow things like ca. 4 Cookies and about 4 Cookies, while some Cookies and 3 - 4 Cookies would be invalid