Giter Site home page Giter Site logo

Recipe variants about recipemd HOT 13 OPEN

tstehr avatar tstehr commented on May 31, 2024
Recipe variants

from recipemd.

Comments (13)

AberDerBart avatar AberDerBart commented on May 31, 2024 1

You are right. I cannot think of a better way to resolve this at the moment. I guess if we come up with something, we can still adjust it in future versions.

from recipemd.

tstehr avatar tstehr commented on May 31, 2024

After some discussion we have identified two main use cases:

  1. Swap out a single ingredient (e.g. margarine instead of butter for a vegan version)
  2. Swap out a set/group of ingredients (as in the example linked above)

from recipemd.

tstehr avatar tstehr commented on May 31, 2024

Current proposal

# Recipe Title

This is a yummy recipe

*delicious, omnivore/vegetarian/vegan*

---

# Base

- Flour
- Water

## Vegan: Additional Component

- Soy
- Tofu
- MSG

## Vegetarian: Additional Component

- Butter
- Cheese

## Omnivore: Additional Component

- Beef Mince
- Tomatos

## Topping

- Vegan: *500 g* Fried Onions
- Vegetarian/omnivore: *500 g* Parmesan
- Omnivore: *100 g* Bacon

Notes

  • The existence of variants is indicated by a tag containing one or more slashes: omnivore/vegetarian/vegan
  • Ingredient groups can be marked with a variant they belong to: ## Vegan: Additional Component
  • Similarly, individual ingredients can also be marked: - Vegan: Fried Onions
  • A variant marker may contain multiple variants: - Vegetarian/omnivore: Parmesan
  • The cli tool gains the option -v VAR, --variant VAR to select a variant: recipemd -v vegan example.md. If the option is given all groups not marked with that variant are removed.
  • When getting ingredients (-i), the variant marker is moved to the back so the amount is in front: *500 g* Parmesan (Vegetarian/omnivore)

@dasnessie @AberDerBart any comments?

from recipemd.

AberDerBart avatar AberDerBart commented on May 31, 2024

I assume based on the examples the variants are case-insensitive?

from recipemd.

tstehr avatar tstehr commented on May 31, 2024

@AberDerBart Yes :)

from recipemd.

AberDerBart avatar AberDerBart commented on May 31, 2024

what about the instructions? If there are different instructions for different variants, it would be nice to only include the selected variant (e.g. when using the -v option)

from recipemd.

AberDerBart avatar AberDerBart commented on May 31, 2024

I was thinking that maybe we could support headings like in the ingredients, but that does not work for individual ingredients.

from recipemd.

tstehr avatar tstehr commented on May 31, 2024

@AberDerBart I'm not sure wether we need support for variants in instructions. Right now instructions are completely freeform, so recipe authors can indicate what to do in any way they want. One common pattern is to state the variant at the beginning of the paragraph like this:

Für die vegetarische Variante Parmesan fein reiben und mit Crème Fraîche mischen.

Für die vegane Variante Mandelmus, Hafersahne, Zitronensaft, Hefeflocken, Salz und Pfeffer mischen und abschmecken.

For me this is understandable even if only the ingredients for the selected variant are present in the recipes ingredient list.

from recipemd.

tstehr avatar tstehr commented on May 31, 2024

@AberDerBart In your proposal to use headings variants would be expressed as follows, correct?

## Vegetarisch

Parmesan fein reiben und mit Crème Fraîche mischen.

## Vegan

Mandelmus, Hafersahne, Zitronensaft, Hefeflocken, Salz und Pfeffer mischen und abschmecken.

Wouldn't this run into the problem that there is no way to indicate when the variant part of the instructions is finished and the common instructions continue?

We have a similar problem with ingredient groups (#6). There we can work around by reordering the ingredients to make sure the groups always come after individual ingredients. With instructions this is not an option since the order of tasks is generally fixed.

from recipemd.

AxelBerres avatar AxelBerres commented on May 31, 2024

Keep it simple ... why have all variants in one recipe file?

I would describe each recipe individually. You could give a reference to the basic recipe.

from recipemd.

tstehr avatar tstehr commented on May 31, 2024

why have all variants in one recipe file?

Often it feels excessive to repeat a complete recipe if you just want to sub out a single ingredient/component, for example to make a recipe gluten-free or vegan. This is somewhat analogous to the DRY principle in programming.

In these cases users naturally tend to just put the variants all in one file (example 1, example 2). Currently that leads to a sub-optimal experience, as without spec support the recipemd command line tool doesn't really understand the users' intent.

For example, getting the ingredients via recipemd -i recipe_with_variants.md returns the ingredients for all variants, which isn't very useful if you want to write a shopping list for the recipe. You'll need to manually prune the output to get the ingredients for just the variant you want to use.

I would describe each recipe individually. You could give a reference to the basic recipe.

This is already possible at the moment and will always be possible. But in my personal use as well as when looking at other users I find that some people naturally gravitate to colocating variants in one file.

Note that the current proposal is constructed in a way that it is very unlikely that one would every write a recipe with variants by accident, so users that want to structure their recipe in a WET way are not at all impeded by variants.

from recipemd.

tstehr avatar tstehr commented on May 31, 2024

In the course of implementing the plan from this comment I found an issue with it for ingredients without amounts.

For these part of the ingredient can unintentionally become the variant marker, leading to weird behavior. Take the following ingredients found in the wild.

- Gelierzucker 3:1
- Wurzelgemüse nach Belieben, z.B.:
    - Pastinaken
    - Rote Beete
    - Kohlrabi
    - Staudensellerie
    - Möhren
- zum Servieren: Pinienkerne, geröstet und/oder Parmesan
- optional: Vanillezucker
- optional: Tonkabohne
- optional: Speck, Äpfel, Zitronenschale
- Deko: Lebensmittelfarbe, Schokolade
- Optional: Körner
- Deko: Puderzucker, Zitronensaft, Lebensmittelfarbe, Schokolade, etc
- Auf Wunsch: Minze fūr die Garnitur
- Vorbestellen: Beinscheiben für Gulasch
- Vorbestellen: Räuchertofu für Linsen & Spätzle

All of these are interpreted as ingredients with a variant marker. For the first one, the variant marker is "Gelierzucker 3", while the ingredient name is "1". For the second one the whole first line is the variant marker. Similar stuff happens for the other ingredients. It's slightly less weird there, since some of the prefixes could at least with some imagination be considered variants.

This leads to variant markers being used in the ingredients which aren't declared in the ingredient's tags and weird behavior when using tools that operate on ingredients.

I see two options to work around this:

  1. We could use markup for variant markers after all. The only real option here is **bold**, since italics is already used for
    amounts:

    • Vegan: 500 g Fried Onions
    - **Vegan:** *500 g* Fried Onions

    I like neither the rendered not the source look of this, both feel pretty noisy to me.

  2. I was planning on making undeclared variant markers an error, so we can warn the user on typos. Instead we could only parse
    variant markers that are present in the tags and treat other text that looks like variant markers as part of the ingredient
    name.

That would be fully backwards compatible, but typos in variant markers would silently lead to the ingredient in question
appearing in both variants, and the amount being parsed as part if the ingredient name not the amount.

Overall I slightly prefer option 2, but am not extremely thrilled with either of them.

from recipemd.

tstehr avatar tstehr commented on May 31, 2024

I think I'll go with option 2 for now

from recipemd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.