separate unit into separate column from measure. they get combined in md generation so no visual change

This commit is contained in:
len0rd 2022-06-22 22:48:11 -04:00
parent fa59d32659
commit e21470b565
8 changed files with 99 additions and 74 deletions

View file

@ -126,6 +126,31 @@ function convertRecipeMarkdown(inputDir, outputDir) {
console.error(err);
return;
}
var ingredientTableRegex = new RegExp(`^(.*?)\\|(.*?)(\\|.*?\\|.*?)\n`, `gm`);
var ingredientDashCheck = new RegExp("^\-+$");
ingredientTableMatcher = ingredientTableRegex.exec(data);
while (ingredientTableMatcher != null) {
meas = ingredientTableMatcher[1];
let unit = ingredientTableMatcher[2].toLowerCase().trim();
if (unit != "unit" && unit && !ingredientDashCheck.test(unit)) {
meas += unit + " ";
}
data = data.replace(ingredientTableMatcher[0], `${meas}${ingredientTableMatcher[3]}\n`);
ingredientTableMatcher = ingredientTableRegex.exec(data);
}
ingredientTableRegex = new RegExp(`^(.*?)\\|(.*?)(\\|.*?\\|.*?)\n`, `gm`);
ingredientTableMatcher = ingredientTableRegex.exec(data);
while (ingredientTableMatcher != null) {
meas = ingredientTableMatcher[1];
let unit = ingredientTableMatcher[2].toLowerCase().trim();
if (unit != "unit" && unit && !ingredientDashCheck.test(unit)) {
meas += unit + " ";
}
data = data.replace(ingredientTableMatcher[0], `${meas}${ingredientTableMatcher[3]}\n`);
ingredientTableMatcher = ingredientTableRegex.exec(data);
}
let tokens = md.parse(data)
let sections = []

View file

@ -4,19 +4,19 @@
## Ingredients
Measure | Weight | Ingredient
--------|--------|-----------
1/4 c | | Cinnamon-Sugar
3 c | | Sugar
3 | | Egg
6 | | Mashed Ripe Banana
3/4 c | | Butter
16 oz | | Sour Cream
2 tsp | | Vanilla
2 tsp | | Cinnamon
1/2 tsp | | Salt
3 tsp | | Baking Soda
4 1/2 c | | Flour
Measure | Unit | Weight | Ingredient
--------|------|--------|-----------
1/4 | c | | Cinnamon-Sugar
3 | c | | Sugar
3 | | | Eggs
6 | | | Banana
3/4 | c | | Butter
16 | oz | | Sour Cream
2 | tsp | | Vanilla
2 | tsp | | Cinnamon
1/2 | tsp | | Salt
3 | tsp | | Baking Soda
4 1/2 | c | | Flour
## Instructions

View file

@ -8,20 +8,20 @@
## Ingredients
Measure | Weight | Ingredient
--------|--------|-----------
1c | | Unsalted Butter
1 1/4c | 290g | Brown Sugar
1/4c | 60g | Sugar
1 | | Egg
1 | | Egg Yolk
2 tbsp | | Whole Milk
1 1/2 tsp | | Vanilla
2 3/4c | 370g | Flour
1 tsp | 7g | Baking Soda
1 tsp | 7g | Salt
1/4 tsp | 1g | Cinnamon
2c | | Chocolate Chip
Measure | Unit | Weight | Ingredient
--------|------|--------|-----------
1 | c | | Unsalted Butter
1 1/4 | c | 290g | Brown Sugar
1/4 | c | 60g | Sugar
1 | | | Egg
1 | | | Egg Yolk
2 | tbsp | | Whole Milk
1 1/2 | tsp | | Vanilla
2 3/4 | c | 370g | Flour
1 | tsp | 7g | Baking Soda
1 | tsp | 7g | Salt
1/4 | tsp | 1g | Cinnamon
2 | c | | Chocolate Chip
## Instructions

View file

@ -6,22 +6,22 @@
## Ingredients
Measure | Weight | Ingredient
--------|--------|-----------
4 3/4 c | | Flour
1 1/2 tsp | | Salt
1/3 c | | Sugar
1/3 c | | Oil
2 | | Beaten Eggs
1 1/4c | | Warm water (110F)
2 tbsp | | Yeast
4 tbsp | | Melted Butter
1/2 c | | Cinnamon Sugar
Measure | Unit | Weight | Ingredient
--------|------|--------|-----------
4 3/4 | c | | Flour
1 1/2 | tsp | | Salt
1/3 | c | | Sugar
1/3 | c | | Oil
2 | | | Eggs
1 1/4 | c | | Warm water (110F)
2 | tbsp | | Yeast
4 | tbsp | | Melted Butter
1/2 | c | | Cinnamon Sugar
## Instructions
1. Mix sugar, water and yeast. Let bloom 5m. Add oil, egg, salt, 2c flour. Mix well
1. Mix sugar, water and yeast. Let bloom 5m. Beat Eggs. Add oil, egg, salt, 2c flour. Mix well
2. Add the rest of the flour until you have a stiff dough. Hand knead 5min. Let rise 15m
3. Roll out into rectangular shape on floured surface. Brush with butter, sprinkle with cinnamon sugar
4. Roll up dough and cut in 1-1/2” slices. Place in rectangular pan and press.

View file

@ -4,14 +4,14 @@
## Ingredients
Measure | Weight | Ingredient
--------|--------|-----------
3 | | Bananas
1/3 c | | Brandy or Rum
Dash | | Cinnamon
1/2 c | | Butter
1 c | | Brown Sugar
1 tsp | | Vanilla
Measure | Unit | Weight | Ingredient
--------|------|--------|-----------
3 | | | Bananas
1/3 | c | | Brandy or Rum
Dash | | | Cinnamon
1/2 | c | | Butter
1 | c | | Brown Sugar
1 | tsp | | Vanilla
## Instructions

View file

@ -4,15 +4,15 @@
## Ingredients
Measure | Weight | Ingredient
--------|--------|-----------
4 | | Biscuit Cans
2/3 c | | Sugar
1 1/2 tsp | | Cinnamon
**Sauce**| |
1 1/8 c | | Butter
1 1/2 c | | Sugar
1 1/2 tsp | | Cinnamon
Measure | Unit | Weight | Ingredient
--------|------|--------|-----------
4 | | | Biscuit Cans
2/3 | c | | Sugar
1 1/2 | tsp | | Cinnamon
**Sauce** | | |
1 1/8 | c | | Butter
1 1/2 | c | | Sugar
1 1/2 | tsp | | Cinnamon
## Instructions

View file

@ -4,14 +4,14 @@
## Ingredients
Measure | Weight | Ingredient
--------|--------|-----------
2 1/2c | | Flour
1 tsp | 7g | Salt
1 tsp | | Sugar
2 tbsp | | Olive Oil
1 c | | Warm Water (110F)
2 1/3 tsp | | Yeast
Measure | Unit | Weight | Ingredient
--------|------|--------|-----------
2 1/2 | c | | Flour
1 | tsp | 7g | Salt
1 | tsp | | Sugar
2 | tbsp | | Olive Oil
1 | c | | Warm Water (110F)
2 1/3 | tsp | | Yeast
## Instructions

View file

@ -4,16 +4,16 @@
## Ingredients
Measure | Weight | Ingredient
--------|--------|-----------
1 3/4 c | | Flour
1/2 tsp | | Salt
3 tsp | | Baking Powder
1/2 c | | Instant Dry Milk
2 | | Eggs
1/2 c | | Oil
1 3/4 c | | Water
Dash | | Cinnamon
Measure | Unit | Weight | Ingredient
--------|------|--------|-----------
1 3/4 | c | | Flour
1/2 | tsp | | Salt
3 | tsp | | Baking Powder
1/2 | c | | Instant Dry Milk
2 | | | Eggs
1/2 | c | | Oil
1 3/4 | c | | Water
Dash | | | Cinnamon
## Instructions