cooklang / cookcli

Command line program which provides a suite of tools to create shopping lists and maintain recipes.
https://cooklang.org
MIT License
780 stars 37 forks source link

Adding preperation instructions for ingredients inside `{}` causes undesired output behavior with plural units #71

Closed isobering closed 11 months ago

isobering commented 1 year ago

I apologize in advance if I am not using cooklang in the intended manner, but I think I have discovered a use case that is not included in the specification or example recipes.

In most recipes, physical preparation instructions for ingredients (like dicing, chopping, mincing, cutting on bias, etc.) are specified with the ingredient quantities. For example, a recipe calling for 2 cups of finely chopped carrots would have the following entry for carrots in the Ingredients list:

Ingredients:

  • 2 cups carrot, finely chopped

When I'm writing this recipe in cooklang, I want the preparation instructions for carrots to appear in the Ingredients section of the output of $ cook recipe read. I could include the preparation instructions in a comment, but that wouldn't show up in the output. In order to have the preperation instructions appear in the Ingredients section, I included them inside the curly braces {} after the unit when defining the ingredient. Here's an example:

Add @carrots{2%cup, finely chopped}

The desired output of $ cook recipe read would be:

Ingredients:
    carrots                  2 cups, finely chopped

Steps:
     1. Add carrots
        [carrots: 2 cups]

However, the actual output of $ cook recipe read is:

Ingredients:
    carrots                  2 cup, finely choppeds

Steps:
     1. Add carrots
        [carrots: 2 cup, finely choppeds]

In this example, cooklang thinks that the entire string following the % character inside {} is the unit. When cooklang attempts to use the plural form of the unit (since the recipe requires 2 cups plural of carrots), cooklang appends an "s" to the last word in the string (chopped) instead of the actual unit (cup).

I think I've accidentally uncovered two issues here:

  1. How should users include preparation instructions for ingredients so they appear in the Ingredients section of the output of $ cook recipe read?
  2. Is the unit parser behaving as intended in this case?

One option would be to have cooklang consider only the word immediately after the % character to be the unit, and ignore everything else.

dubadub commented 11 months ago

This was fixed after migration to Rust parser.