Comments (13)
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.
After some discussion we have identified two main use cases:
- Swap out a single ingredient (e.g. margarine instead of butter for a vegan version)
- Swap out a set/group of ingredients (as in the example linked above)
from recipemd.
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.
I assume based on the examples the variants are case-insensitive?
from recipemd.
@AberDerBart Yes :)
from recipemd.
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.
I was thinking that maybe we could support headings like in the ingredients, but that does not work for individual ingredients.
from recipemd.
@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.
@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.
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.
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.
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:
-
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.
-
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.
I think I'll go with option 2 for now
from recipemd.
Related Issues (20)
- Indentation on recipemd.org HOT 1
- Github is near impossible to find on the mobile view of recipemd.org
- Recursive recipes cause unhandled exception
- recipemd-find is complex to use for simply searching recipes HOT 1
- crash when writing to same file HOT 2
- Add times for specification HOT 3
- crash since last python update HOT 1
- Investigate including test files in distribution HOT 1
- Bug when trying to use "flatten"? HOT 2
- Fenced code blocks at the end of instructions are cut off HOT 1
- Fix inconsistent treatment of amounts without factors HOT 4
- Proposal: Git pre-commit hook for RecipeMD format validation HOT 1
- A Link reference defintion is dropped HOT 3
- Discuss syntax for pair-shaped metadata HOT 1
- Approximate amount specifier HOT 2
- Alternative ingredients HOT 9
- Optional amount specifier
- the command line tool does not support writing to the same file it is reading from HOT 2
- Reference implementation/testcases differ from specification
- Ignore YAML Frontmatter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recipemd.